Example usage for org.eclipse.jdt.core JavaCore getWorkingCopies

List of usage examples for org.eclipse.jdt.core JavaCore getWorkingCopies

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore getWorkingCopies.

Prototype

public static ICompilationUnit[] getWorkingCopies(WorkingCopyOwner owner) 

Source Link

Document

Returns the working copies that have the given owner.

Usage

From source file:org.codehaus.groovy.eclipse.codebrowsing.tests.ASTFragmentTests.java

License:Apache License

@Override
protected void setUp() throws Exception {
    System.out.println(JavaCore.getWorkingCopies(null));
    super.setUp();
}

From source file:org.codehaus.groovy.eclipse.codebrowsing.tests.ASTFragmentTests.java

License:Apache License

public void testASTSubFragment1b() throws Exception {
    System.out.println(JavaCore.getWorkingCopies(null));
    IASTFragment first = createFragmentFromText("a.b.c");
    String contents = "z.a.b.c.d";
    IASTFragment second = createFragmentFromText(contents, 2, contents.indexOf(".d"));
    assertEquals("Wrong number of fragments: " + second, 3, second.fragmentLength());
    // fragments should not match because property-based fragments only
    // match from the beginning
    assertFragmentDifferent(first, second);
    new TestFragmentVisitor().checkExpectedKinds(first, ASTFragmentKind.PROPERTY, ASTFragmentKind.PROPERTY,
            ASTFragmentKind.SIMPLE_EXPRESSION);
    new TestFragmentVisitor().checkExpectedKinds(second, ASTFragmentKind.PROPERTY, ASTFragmentKind.PROPERTY,
            ASTFragmentKind.SIMPLE_EXPRESSION);
}

From source file:org.codehaus.groovy.eclipse.codebrowsing.tests.BrowsingTestCase.java

License:Open Source License

@Override
protected void tearDown() throws Exception {
    super.tearDown();
    ICompilationUnit[] wcs = new ICompilationUnit[0];
    int i = 0;/*from   w  w  w. j  a va 2  s. c  o m*/
    do {
        wcs = JavaCore.getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY);
        for (ICompilationUnit workingCopy : wcs) {
            try {
                workingCopy.discardWorkingCopy();
                workingCopy.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        i++;
        if (i > 20) {
            fail("Could not delete working copies " + wcs);
        }
    } while (wcs.length > 0);
}

From source file:org.eclipse.xtext.common.types.xtext.ui.JdtValidationJobScheduler.java

License:Open Source License

@Override
protected boolean isDirty(URI uri) {
    if (uri == null)
        return false;
    if (URIHelperConstants.PROTOCOL.equals(uri.scheme())) {
        String path = uri.path();
        if (URIHelperConstants.PRIMITIVES.equals(path))
            return false;
        String topLevelTypeName = path.substring(URIHelperConstants.OBJECTS.length());
        ICompilationUnit[] workingCopies = JavaCore.getWorkingCopies(null);
        for (ICompilationUnit cu : workingCopies) {
            try {
                if (cu.hasUnsavedChanges()) {
                    IType primaryType = cu.findPrimaryType();
                    if (primaryType != null) {
                        if (topLevelTypeName.equals(primaryType.getFullyQualifiedName())) {
                            return true;
                        }//from w w w. j a  va2  s  . c o  m
                    }
                }
            } catch (JavaModelException e) {
                // ignore
            }
        }
    }
    return super.isDirty(uri);
}