Example usage for org.eclipse.jdt.core.search IJavaSearchConstants DECLARATIONS

List of usage examples for org.eclipse.jdt.core.search IJavaSearchConstants DECLARATIONS

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search IJavaSearchConstants DECLARATIONS.

Prototype

int DECLARATIONS

To view the source code for org.eclipse.jdt.core.search IJavaSearchConstants DECLARATIONS.

Click Source Link

Document

The search result is a declaration.

Usage

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodGenericArgDeclaration3() throws Exception {
    createCU("Other.java", "abstract class Other { abstract void xxx(java.util.List<String> x); }");
    ICompilationUnit unit = createCU("Aspect.aj",
            "aspect Aspect {\n void Java.xxx(java.util.List<String> x) { } }");
    createCU("Java.java", "class Java extends Other { }");

    IntertypeElement itd = findFirstITD(unit);

    List<SearchMatch> matches = findSearchMatches(itd, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(1, matches);
    assertDeclarationMatches(itd, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodGenericArgDeclaration4() throws Exception {
    ICompilationUnit unit = createCU("Aspect.aj",
            "aspect Aspect {\n void Java.xxx(java.util.List<String> x) { } }");
    createCU("Java.java", "class Java { }");
    ICompilationUnit other = createCU("Other.java",
            "class Other extends Java { void xxx(java.util.List<String> x) { } }");

    IntertypeElement itd = findFirstITD(unit);
    IMember method = findFirstChild(other);

    List<SearchMatch> matches = findSearchMatches(method, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(2, matches);
    assertDeclarationMatches(itd, matches);
    assertDeclarationMatches(method, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodGenericArgDeclaration5() throws Exception {
    ICompilationUnit other = createCU("Other.java",
            "abstract class Other { abstract void xxx(java.util.List<String> x); }");
    ICompilationUnit unit = createCU("Aspect.aj",
            "aspect Aspect {\n void Java.xxx(java.util.List<String> x) { } }");
    createCU("Java.java", "class Java extends Other { }");

    IntertypeElement itd = findFirstITD(unit);
    IMember method = findFirstChild(other);

    List<SearchMatch> matches = findSearchMatches(method, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(2, matches);
    assertDeclarationMatches(itd, matches);
    assertDeclarationMatches(method, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodLocalArgDeclaration1() throws Exception {
    ICompilationUnit unit = createCU("Aspect.aj", "aspect Aspect {\n void Java.xxx(Java x) { } }");
    createCU("Java.java", "class Java { }");

    IntertypeElement itd = findFirstITD(unit);

    List<SearchMatch> matches = findSearchMatches(itd, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(1, matches);
    assertDeclarationMatches(itd, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodLocalArgDeclaration2() throws Exception {
    ICompilationUnit unit = createCU("Aspect.aj", "aspect Aspect {\n void Java.xxx(Java x) { } }");
    createCU("Java.java", "class Java { }");
    ICompilationUnit other = createCU("Other.java", "class Other extends Java { void xxx(Java x) { } }");

    IntertypeElement itd = findFirstITD(unit);
    IMember method = findFirstChild(other);

    List<SearchMatch> matches = findSearchMatches(itd, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(2, matches);
    assertDeclarationMatches(itd, matches);
    assertDeclarationMatches(method, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodLocalArgDeclaration3() throws Exception {
    createCU("Other.java", "abstract class Other { abstract void xxx(Java x); }");
    ICompilationUnit unit = createCU("Aspect.aj", "aspect Aspect {\n void Java.xxx(Java x) { } }");
    createCU("Java.java", "class Java extends Other { }");

    IntertypeElement itd = findFirstITD(unit);

    List<SearchMatch> matches = findSearchMatches(itd, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(1, matches);
    assertDeclarationMatches(itd, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodLocalArgDeclaration4() throws Exception {
    ICompilationUnit unit = createCU("Aspect.aj", "aspect Aspect {\n void Java.xxx(Java x) { } }");
    createCU("Java.java", "class Java { }");
    ICompilationUnit other = createCU("Other.java", "class Other extends Java { void xxx(Java x) { } }");

    IntertypeElement itd = findFirstITD(unit);
    IMember method = findFirstChild(other);

    List<SearchMatch> matches = findSearchMatches(method, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(2, matches);
    assertDeclarationMatches(itd, matches);
    assertDeclarationMatches(method, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchMethodLocalArgDeclaration5() throws Exception {
    ICompilationUnit other = createCU("Other.java", "abstract class Other { abstract void xxx(Java x); }");
    ICompilationUnit unit = createCU("Aspect.aj", "aspect Aspect {\n void Java.xxx(Java x) { } }");
    createCU("Java.java", "class Java extends Other { }");

    IntertypeElement itd = findFirstITD(unit);
    IMember method = findFirstChild(other);

    List<SearchMatch> matches = findSearchMatches(method, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(2, matches);
    assertDeclarationMatches(itd, matches);
    assertDeclarationMatches(method, matches);
}

From source file:org.eclipse.ajdt.core.tests.search.ITDAwareDeclarationSearchTests.java

License:Open Source License

public void testITDSearchConstructorDeclaration1() throws Exception {
    ICompilationUnit unit = createCU("Aspect.aj", "aspect Aspect {\n \nJava.new(int x) { } }");
    createCU("Java.java", "class Java { \nJava() { } }");
    createCU("Other.java", "class Other extends Java { Other(int x) { super(); } }");

    IntertypeElement itd = findFirstITD(unit);
    List<SearchMatch> matches = findSearchMatches(itd, this.getName(), IJavaSearchConstants.DECLARATIONS);
    assertExpectedNumberOfMatches(1, matches);
    assertDeclarationMatches(itd, matches);
}

From source file:org.eclipse.ajdt.internal.ui.refactoring.RippleMethodFinder2.java

License:Open Source License

private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException {
    fDeclarations = new ArrayList();

    class MethodRequestor extends SearchRequestor {
        public void acceptSearchMatch(SearchMatch match) throws CoreException {
            IMethod method = (IMethod) match.getElement();
            boolean isBinary = method.isBinary();
            if (fBinaryRefs != null || !(fExcludeBinaries && isBinary)) {
                fDeclarations.add(method);
            }/*  w w  w .ja v  a  2  s .  co  m*/
            if (isBinary && fBinaryRefs != null) {
                fDeclarationToMatch.put(method, match);
            }
        }
    }

    int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE
            | IJavaSearchConstants.IGNORE_RETURN_TYPE;
    int matchRule = SearchPattern.R_ERASURE_MATCH | SearchPattern.R_CASE_SENSITIVE;
    SearchPattern pattern = SearchPattern.createPattern(fMethod, limitTo, matchRule);
    SearchParticipant[] participants = SearchUtils.getDefaultSearchParticipants();
    IJavaSearchScope scope = RefactoringScopeFactory.createRelatedProjectsScope(fMethod.getJavaProject(),
            IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES
                    | IJavaSearchScope.SYSTEM_LIBRARIES);
    MethodRequestor requestor = new MethodRequestor();
    SearchEngine searchEngine = owner != null ? new SearchEngine(owner) : new SearchEngine();

    searchEngine.search(pattern, participants, scope, requestor, monitor);
}