Example usage for org.eclipse.jdt.core.search TypeNameRequestor TypeNameRequestor

List of usage examples for org.eclipse.jdt.core.search TypeNameRequestor TypeNameRequestor

Introduction

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

Prototype

TypeNameRequestor

Source Link

Usage

From source file:at.bestsolution.efxclipse.tooling.fxml.editors.FXMLCompletionProposalComputer.java

License:Open Source License

private void createSubtypeProposals(final ContentAssistRequest contentAssistRequest,
        final CompletionProposalInvocationContext context, IType superType) {
    IJavaProject jproject = findProject(contentAssistRequest);

    try {/*from w w  w. j a  va 2 s  . c om*/
        IJavaSearchScope hierarchyScope = SearchEngine.createHierarchyScope(superType);
        IJavaSearchScope projectScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { jproject });
        IJavaSearchScope scope = new IntersectingJavaSearchScope(projectScope, hierarchyScope);
        SearchEngine searchEngine = new SearchEngine();

        char[] typeName = null;
        char[] packageName = null;
        if (!contentAssistRequest.getMatchString().isEmpty()) {
            typeName = contentAssistRequest.getMatchString().toCharArray();
        }

        searchEngine.searchAllTypeNames(packageName, SearchPattern.R_PATTERN_MATCH, typeName,
                SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CAMELCASE_MATCH, IJavaSearchConstants.CLASS,
                scope, new TypeNameRequestor() {
                    @Override
                    public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                            char[][] enclosingTypeNames, String path) {
                        String sPackageName = new String(packageName);
                        int priority = PRIORITY_LOWER_1;
                        if (sPackageName.startsWith("com.sun.javafx")) {
                            priority -= 10;
                        }
                        StyledString s = new StyledString(new String(simpleTypeName));
                        s.append(" - " + sPackageName, StyledString.QUALIFIER_STYLER);
                        FXMLCompletionProposal prop = createElementProposal(contentAssistRequest, context,
                                sPackageName + "." + new String(simpleTypeName) + " ", s, false, priority,
                                IconKeys.getIcon(IconKeys.CLASS_KEY), FQN_MATCHER);

                        if (prop != null) {
                            prop.setMatcher(FQN_MATCHER);
                            prop.setTextApplier(new IReplacementTextApplier() {

                                @Override
                                public void apply(IDocument document, ConfigurableCompletionProposal proposal)
                                        throws BadLocationException {
                                    String proposalReplacementString = proposal.getReplacementString();
                                    List<String> s = getImportedTypes(contentAssistRequest);
                                    String shortened = proposalReplacementString
                                            .substring(proposalReplacementString.lastIndexOf('.') + 1);

                                    if (s.contains(proposalReplacementString.trim())) {
                                        proposal.setCursorPosition(shortened.length());
                                        document.replace(proposal.getReplacementOffset(),
                                                proposal.getReplacementLength(), shortened);
                                    } else {
                                        DocumentRewriteSession rewriteSession = null;
                                        try {
                                            if (document instanceof IDocumentExtension4) {
                                                rewriteSession = ((IDocumentExtension4) document)
                                                        .startRewriteSession(
                                                                DocumentRewriteSessionType.UNRESTRICTED_SMALL);
                                            }

                                        } finally {
                                            if (rewriteSession != null) {
                                                ((IDocumentExtension4) document)
                                                        .stopRewriteSession(rewriteSession);
                                            }
                                            // if (viewerExtension != null)
                                            // viewerExtension.setRedraw(true);
                                        }

                                        boolean startWithLineBreak = true;
                                        boolean endWithLineBreak = false;
                                        Document xmlDoc = contentAssistRequest.getNode().getOwnerDocument();
                                        NodeList list = xmlDoc.getChildNodes();
                                        int offset = 0;
                                        List<Node> prs = new ArrayList<Node>();
                                        for (int i = 0; i < list.getLength(); i++) {
                                            Node n = list.item(i);
                                            if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
                                                prs.add(n);
                                            }
                                        }

                                        if (!prs.isEmpty()) {
                                            offset = ((IDOMNode) prs.get(prs.size() - 1)).getEndOffset();
                                        }

                                        offset = Math.min(proposal.getReplacementOffset(), offset);
                                        proposal.setCursorPosition(shortened.length());
                                        document.replace(proposal.getReplacementOffset(),
                                                proposal.getReplacementLength(), shortened);

                                        String importStatement = (startWithLineBreak ? "\n<?import "
                                                : "import ") + proposalReplacementString.trim();
                                        importStatement += "?>";

                                        if (endWithLineBreak)
                                            importStatement += "\n\n";
                                        document.replace(offset, 0, importStatement.toString());
                                        proposal.setCursorPosition(
                                                proposal.getCursorPosition() + importStatement.length());
                                    }
                                }
                            });
                            contentAssistRequest.addProposal(prop);
                        }
                    }
                }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
    } catch (JavaModelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:at.bestsolution.efxclipse.tooling.fxml.editors.FXMLCompletionProposalComputer.java

License:Open Source License

@Override
protected void addAttributeValueProposals(final ContentAssistRequest contentAssistRequest,
        final CompletionProposalInvocationContext context) {
    IDOMNode n = (IDOMNode) contentAssistRequest.getNode();

    if (Character.isUpperCase(n.getNodeName().charAt(0))) {
        NamedNodeMap m = n.getAttributes();
        IDOMNode attribute = null;// w  w  w . jav  a  2s .  c  o  m
        for (int i = 0; i < m.getLength(); i++) {
            IDOMNode a = (IDOMNode) m.item(i);
            if (a.contains(contentAssistRequest.getStartOffset())) {
                attribute = a;
            }
        }

        if (attribute != null) {
            if ("http://javafx.com/fxml".equals(attribute.getNamespaceURI())) {
                if ("constant".equals(attribute.getLocalName())) {
                    IType type = findType(n.getNodeName(), contentAssistRequest, context);
                    if (type != null) {
                        try {
                            List<IField> fields = new ArrayList<IField>();
                            collectStaticFields(fields, type);

                            for (IField f : fields) {
                                StyledString s = new StyledString(f.getElementName() + " : "
                                        + Signature.getSimpleName(Signature.toString(f.getTypeSignature())));
                                String owner = ((IType) f.getAncestor(IJavaElement.TYPE)).getElementName();
                                s.append(" - " + Signature.getSimpleName(owner), StyledString.QUALIFIER_STYLER);

                                FXMLCompletionProposal cp = createProposal(contentAssistRequest, context,
                                        "\"" + f.getElementName(), s, IconKeys.getIcon(IconKeys.CLASS_KEY),
                                        CLASS_ATTRIBUTE_MATCHER);

                                if (cp != null) {
                                    contentAssistRequest.addProposal(cp);
                                }
                            }

                        } catch (JavaModelException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                } else if ("controller".equals(attribute.getLocalName())) {
                    IJavaProject jproject = findProject(contentAssistRequest);

                    char[] typeName = null;
                    char[] packageName = null;
                    if (!contentAssistRequest.getMatchString().isEmpty()) {
                        if (contentAssistRequest.getMatchString().startsWith("\"")) {
                            typeName = contentAssistRequest.getMatchString().substring(1).toCharArray();
                        } else {
                            typeName = contentAssistRequest.getMatchString().toCharArray();
                        }
                    }

                    IJavaSearchScope searchScope = SearchEngine
                            .createJavaSearchScope(new IJavaElement[] { jproject });
                    SearchEngine searchEngine = new SearchEngine();
                    try {
                        searchEngine.searchAllTypeNames(packageName, SearchPattern.R_PATTERN_MATCH, typeName,
                                SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CAMELCASE_MATCH,
                                IJavaSearchConstants.TYPE, searchScope, new TypeNameRequestor() {
                                    public void acceptType(int modifiers, char[] packageName,
                                            char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
                                        String sPackageName = new String(packageName);
                                        int priority = PRIORITY_LOWER_1;
                                        if (sPackageName.startsWith("com.sun")) {
                                            priority -= 10;
                                        }
                                        StyledString s = new StyledString(new String(simpleTypeName));
                                        s.append(" - " + sPackageName, StyledString.QUALIFIER_STYLER);

                                        FXMLCompletionProposal cp = createProposal(contentAssistRequest,
                                                context, "\"" + sPackageName + "." + new String(simpleTypeName),
                                                s, IconKeys.getIcon(IconKeys.CLASS_KEY),
                                                CLASS_ATTRIBUTE_MATCHER);

                                        if (cp != null) {
                                            contentAssistRequest.addProposal(cp);
                                        }
                                    }
                                }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
                    } catch (JavaModelException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            } else if (attribute.getNodeName().contains(".")) {
                String[] parts = attribute.getNodeName().split("\\.");

                IType type = findType(parts[0], contentAssistRequest, context);
                if (type != null) {
                    IFXClass fxClass = FXPlugin.getClassmodel().findClass(type.getJavaProject(), type);
                    if (fxClass != null) {
                        IFXProperty p = fxClass.getStaticProperty(parts[1]);
                        if (p instanceof IFXPrimitiveProperty) {
                            createAttributeValuePrimitiveProposals(contentAssistRequest, context,
                                    (IFXPrimitiveProperty) p);
                        } else if (p instanceof IFXEnumProperty) {
                            createAttributeValueEnumProposals(contentAssistRequest, context,
                                    (IFXEnumProperty) p);
                        } else if (p instanceof IFXObjectProperty) {
                            createAttributeValueObjectProposals(contentAssistRequest, context,
                                    (IFXObjectProperty) p);
                        }
                    }
                }
            } else {
                IType type = findType(n.getNodeName(), contentAssistRequest, context);
                if (type != null) {
                    IFXClass fxClass = FXPlugin.getClassmodel().findClass(type.getJavaProject(), type);
                    if (fxClass != null) {
                        IFXProperty p = fxClass.getProperty(attribute.getNodeName());
                        if (p instanceof IFXPrimitiveProperty) {
                            createAttributeValuePrimitiveProposals(contentAssistRequest, context,
                                    (IFXPrimitiveProperty) p);
                        } else if (p instanceof IFXEnumProperty) {
                            createAttributeValueEnumProposals(contentAssistRequest, context,
                                    (IFXEnumProperty) p);
                        } else if (p instanceof IFXObjectProperty) {
                            createAttributeValueObjectProposals(contentAssistRequest, context,
                                    (IFXObjectProperty) p);
                        } else if (p instanceof IFXEventHandlerProperty) {
                            createAttributeValueEventHandlerProposals(contentAssistRequest, context,
                                    (IFXEventHandlerProperty) p);
                        }
                    }
                }
            }
        }
    }
}

From source file:bndtools.editor.components.ComponentNameProposalProvider.java

License:Open Source License

@Override
protected List<IContentProposal> doGenerateProposals(String contents, int position) {
    final String prefix = contents.substring(0, position);
    IJavaProject javaProject = searchContext.getJavaProject();
    final List<IContentProposal> result = new ArrayList<IContentProposal>(100);

    // Resource matches
    IProject project = javaProject.getProject();
    try {/* ww w . ja  va  2s.  com*/
        project.accept(new IResourceProxyVisitor() {
            public boolean visit(IResourceProxy proxy) throws CoreException {
                if (proxy.getType() == IResource.FILE) {
                    if (proxy.getName().toLowerCase().startsWith(prefix)
                            && proxy.getName().toLowerCase().endsWith(XML_SUFFIX)) {
                        result.add(new ResourceProposal(proxy.requestResource()));
                    }
                    return false;
                }
                // Recurse into everything else
                return true;
            }
        }, 0);
    } catch (CoreException e) {
        Plugin.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error searching for resources.", e));
    }

    // Class matches
    final IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
    final TypeNameRequestor requestor = new TypeNameRequestor() {
        @Override
        public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                char[][] enclosingTypeNames, String path) {
            if (!Flags.isAbstract(modifiers) && (Flags.isPublic(modifiers) || Flags.isProtected(modifiers))) {
                result.add(new JavaContentProposal(new String(packageName), new String(simpleTypeName), false));
            }
        };
    };
    final IRunnableWithProgress runnable = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                new SearchEngine().searchAllTypeNames(null, 0, prefix.toCharArray(),
                        SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.CLASS, scope, requestor,
                        IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, monitor);
            } catch (JavaModelException e) {
                throw new InvocationTargetException(e);
            }
        }
    };
    IRunnableContext runContext = searchContext.getRunContext();
    try {
        if (runContext != null) {
            runContext.run(false, false, runnable);
        } else {
            runnable.run(new NullProgressMonitor());
        }
    } catch (InvocationTargetException e) {
        Plugin.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error searching for classes.",
                e.getTargetException()));
    } catch (InterruptedException e) {
        // Reset the interruption status and continue
        Thread.currentThread().interrupt();
    }
    return result;
}

From source file:bndtools.editor.components.SvcInterfaceProposalProvider.java

License:Open Source License

@Override
protected List<IContentProposal> doGenerateProposals(String contents, int position) {
    final String prefix = contents.substring(0, position);
    final IJavaSearchScope scope = SearchEngine
            .createJavaSearchScope(new IJavaElement[] { searchContext.getJavaProject() });
    final ArrayList<IContentProposal> result = new ArrayList<IContentProposal>(100);
    final TypeNameRequestor typeNameRequestor = new TypeNameRequestor() {
        @Override/*from w w  w .  j  a  v  a  2s .  c  om*/
        public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                char[][] enclosingTypeNames, String path) {
            boolean isInterface = Flags.isInterface(modifiers);
            result.add(
                    new JavaContentProposal(new String(packageName), new String(simpleTypeName), isInterface));
        }
    };
    IRunnableWithProgress runnable = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                new SearchEngine().searchAllTypeNames(null, 0, prefix.toCharArray(),
                        SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.CLASS_AND_INTERFACE, scope,
                        typeNameRequestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, monitor);
            } catch (JavaModelException e) {
                throw new InvocationTargetException(e);
            }
        }
    };

    try {
        if (searchContext.getRunContext() == null) {
            runnable.run(new NullProgressMonitor());
        } else {
            searchContext.getRunContext().run(false, false, runnable);
        }
    } catch (InvocationTargetException e) {
        Plugin.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error searching for Java types.",
                e.getTargetException()));
        return Collections.emptyList();
    } catch (InterruptedException e) {
        // Reset interrupted status and return empty
        Thread.currentThread().interrupt();
        return Collections.emptyList();
    }
    return result;
}

From source file:ca.ubc.cs.ferret.tests.support.TestProject.java

License:Open Source License

public void waitForIndexer() throws JavaModelException {
    new SearchEngine().searchAllTypeNames(null, null, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.CLASS,
            SearchEngine.createJavaSearchScope(new IJavaElement[0]), new TypeNameRequestor() {
                // nothing needs to be done here...we accept everything
            }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
}

From source file:com.siteview.mde.internal.ui.editor.contentassist.TypePackageCompletionProcessor.java

License:Open Source License

protected void generateTypeProposals(String currentContent, IProject project, final Collection c,
        final int startOffset, final int length, int typeScope) {
    // Dynamically adjust the search scope depending on the current
    // state of the project
    IJavaSearchScope scope = PDEJavaHelper.getSearchScope(project);
    char[] packageName = null;
    char[] typeName = null;
    int index = currentContent.lastIndexOf('.');

    if (index == -1) {
        // There is no package qualification
        // Perform the search only on the type name
        typeName = currentContent.toCharArray();
    } else if ((index + 1) == currentContent.length()) {
        // There is a package qualification and the last character is a
        // dot//from  w  ww  . ja v  a2s.  c o m
        // Perform the search for all types under the given package
        // Pattern for all types
        typeName = "".toCharArray(); //$NON-NLS-1$
        // Package name without the trailing dot
        packageName = currentContent.substring(0, index).toCharArray();
    } else {
        // There is a package qualification, followed by a dot, and 
        // a type fragment
        // Type name without the package qualification
        typeName = currentContent.substring(index + 1).toCharArray();
        // Package name without the trailing dot
        packageName = currentContent.substring(0, index).toCharArray();
    }

    try {
        TypeNameRequestor req = new TypeNameRequestor() {
            public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                    char[][] enclosingTypeNames, String path) {
                // Accept search results from the JDT SearchEngine
                String cName = new String(simpleTypeName);
                String pName = new String(packageName);
                String label = cName + " - " + pName; //$NON-NLS-1$
                String content = pName + "." + cName; //$NON-NLS-1$
                Image image = (Flags.isInterface(modifiers))
                        ? MDEPluginImages.get(MDEPluginImages.OBJ_DESC_GENERATE_INTERFACE)
                        : MDEPluginImages.get(MDEPluginImages.OBJ_DESC_GENERATE_CLASS);
                addProposalToCollection(c, startOffset, length, label, content, image);
            }
        };
        // Note:  Do not use the search() method, its performance is
        // bad compared to the searchAllTypeNames() method
        fSearchEngine.searchAllTypeNames(packageName, SearchPattern.R_EXACT_MATCH, typeName,
                SearchPattern.R_PREFIX_MATCH, typeScope, scope, req,
                IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
    } catch (CoreException e) {
        fErrorMessage = e.getMessage();
    }
}

From source file:de.jcup.egradle.eclipse.gradleeditor.jdt.JDTDataAccess.java

License:Apache License

/**
 * Scan for package names// w  w  w.j  av a2 s .com
 * 
 * @param type
 * @param scope
 * @param packageNames
 *            - can be <code>null</code>
 * @return list with java types
 */
public List<String> scanForJavaType(String type, IJavaSearchScope scope, String... packageNames) {
    SearchEngine engine = new SearchEngine();
    List<String> foundList = new ArrayList<>();
    try {
        // int packageFlags=0;
        // String packPattern = "org.gradle.api";
        // String typePattern = "Project";
        // int matchRule;
        // int elementKind;
        // IJavaSearchScope searchScope;
        // TypeNameRequestor requestor;
        // IProgressMonitor progressMonitor;
        // engine.searchAllTypeNames((packPattern == null) ? null :
        // packPattern.toCharArray(),
        // packageFlags,
        // typePattern.toCharArray(), matchRule,
        // IJavaElement.TYPE, searchScope, requestor, 3,
        // progressMonitor);

        List<char[]> groovyAutomaticImports = new ArrayList<>();
        if ("BigDecimal".equals(type) || "BigInteger".equals(type)) {
            addImport(groovyAutomaticImports, "java.math");
        } else {
            addImport(groovyAutomaticImports, "java.lang");
            addImport(groovyAutomaticImports, "java.util");
            addImport(groovyAutomaticImports, "java.net");
            addImport(groovyAutomaticImports, "java.io");
            if (packageNames != null && packageNames.length > 0) {
                for (String packageName : packageNames) {
                    if (packageName != null && !packageName.isEmpty()) {
                        addImport(groovyAutomaticImports, packageName);
                    }
                }
            }
        }
        char[][] qualifications = new char[groovyAutomaticImports.size()][];
        for (int i = 0; i < groovyAutomaticImports.size(); i++) {
            qualifications[i] = groovyAutomaticImports.get(i);
        }

        char[][] typeNames = new char[1][];
        typeNames[0] = type.toCharArray();
        TypeNameRequestor nameRequestor = new TypeNameRequestor() {

            @Override
            public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                    char[][] enclosingTypeNames, String path) {
                String simpleName = new String(simpleTypeName);
                String simplePackageName = new String(packageName);
                foundList.add(simplePackageName + "." + simpleName);
            }
        };

        int policiy = IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH;
        IProgressMonitor progressMonitor = new NullProgressMonitor();

        engine.searchAllTypeNames(qualifications, typeNames, scope, nameRequestor, policiy, progressMonitor);

    } catch (JavaModelException e) {
        EGradleUtil.log(e);
        ;
    }
    return foundList;

}

From source file:de.loskutov.anyedit.jdt.JdtUtils.java

License:Open Source License

/**
 * Finds a type by the simple name./* w  ww  .ja  v  a  2  s .  c o  m*/
 * see org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation
 * @return null, if no types was found, empty array if more then one type was found,
 * or only one element, if single match exists
 */
/* @Nonnull */
private static IType[] getTypeForName(String simpleTypeName, final IJavaSearchScope searchScope,
        IProgressMonitor monitor) throws JavaModelException {
    final IType[] result = new IType[1];
    final TypeFactory fFactory = new TypeFactory();
    TypeNameRequestor requestor = new TypeNameRequestor() {
        boolean done;
        boolean found;

        @Override
        public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName1,
                char[][] enclosingTypeNames, String path) {
            if (done) {
                return;
            }
            IType type = fFactory.create(packageName, simpleTypeName1, enclosingTypeNames, modifiers, path,
                    searchScope, found);
            if (type != null) {
                if (found) {
                    // more then one match => we do not need anymore
                    done = true;
                    result[0] = null;
                } else {
                    found = true;
                    result[0] = type;
                }
            }
        }
    };
    new SearchEngine().searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, simpleTypeName.toCharArray(),
            SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, searchScope, requestor,
            IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);

    return result;
}

From source file:de.loskutov.bco.ui.JdtUtils.java

License:Open Source License

/**
 * Finds a type by the simple name.// www  .j  av  a2 s .c  om
 * see org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation
 * @return null, if no types was found, empty array if more then one type was found,
 * or only one element, if single match exists
 */
public static IType[] getTypeForName(String simpleTypeName, final IJavaSearchScope searchScope,
        IProgressMonitor monitor) throws JavaModelException {
    final List<IType> result = new ArrayList<IType>();
    final TypeFactory fFactory = new TypeFactory();
    TypeNameRequestor requestor = new TypeNameRequestor() {
        @Override
        public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName1,
                char[][] enclosingTypeNames, String path) {
            IType type = fFactory.create(packageName, simpleTypeName1, enclosingTypeNames, modifiers, path,
                    searchScope);
            if (type != null) {
                result.add(type);
            }
        }
    };
    int matchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
    new SearchEngine().searchAllTypeNames(null, matchRule, simpleTypeName.toCharArray(), matchRule,
            IJavaSearchConstants.TYPE, searchScope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
            monitor);

    return result.toArray(new IType[result.size()]);
}

From source file:edu.buffalo.cse.green.test.core.Project.java

License:Open Source License

/**
 * Waits for idle./*from w  w w . jav  a 2  s.  co  m*/
 */
private void waitForIndexer() throws JavaModelException {
    new SearchEngine().searchAllTypeNames(null, null, SearchPattern.R_EXACT_MATCH,
            SearchPattern.R_CASE_SENSITIVE, SearchEngine.createJavaSearchScope(new IJavaElement[0]),
            new TypeNameRequestor() {
            }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
}