Java 类org.eclipse.jdt.core.search.TypeNameRequestor 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:FilteredTypesSelectionDialog.java   
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
    try {
        new SearchEngine().searchAllTypeNames(
                null,
                0,
                // make sure we search a concrete name. This is faster according to Kent
                "_______________".toCharArray(), //$NON-NLS-1$
                SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
                IJavaSearchConstants.ENUM,
                SearchEngine.createWorkspaceScope(),
                new TypeNameRequestor() { /* dummy */},
                IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
                monitor);
    } catch (JavaModelException e) {
        throw new InvocationTargetException(e);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FilteredTypesSelectionDialog.java   
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
    try {
        new SearchEngine().searchAllTypeNames(
                null,
                0,
                // make sure we search a concrete name. This is faster according to Kent
                "_______________".toCharArray(), //$NON-NLS-1$
                SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
                IJavaSearchConstants.ENUM,
                SearchEngine.createWorkspaceScope(),
                new TypeNameRequestor() {},
                IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
                monitor);
    } catch (JavaModelException e) {
        throw new InvocationTargetException(e);
    }
}
项目:mybatipse    文件:ProposalComputorHelper.java   
public static void searchJavaType(String matchString, IJavaSearchScope scope,
    TypeNameRequestor requestor) throws JavaModelException
{
    char[] searchPkg = null;
    char[] searchType = null;
    if (matchString != null && matchString.length() > 0)
    {
        char[] match = matchString.toCharArray();
        int lastDotPos = matchString.lastIndexOf('.');
        if (lastDotPos == -1)
        {
            searchType = match;
        }
        else
        {
            if (lastDotPos + 1 < match.length)
            {
                searchType = CharOperation.lastSegment(match, '.');
            }
            searchPkg = Arrays.copyOfRange(match, 0, lastDotPos);
        }
    }
    SearchEngine searchEngine = new SearchEngine();
    searchEngine.searchAllTypeNames(searchPkg, SearchPattern.R_PREFIX_MATCH, searchType,
        SearchPattern.R_CAMELCASE_MATCH, IJavaSearchConstants.CLASS, scope, requestor,
        IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
}
项目:txtUML    文件:XtxtUMLReferenceProposalTypeScope.java   
/**
 * Returns an appropriate scope consisting of allowed Java class types
 * {@link Boolean}, {@link Double}, {@link Integer} and {@link String}.
 */
@Override
protected Iterable<IEObjectDescription> internalGetAllElements() {
    IJavaProject javaProject = getTypeProvider().getJavaProject();
    if (javaProject == null)
        return Collections.emptyList();
    final List<IEObjectDescription> allScopedElements = Lists.newArrayListWithExpectedSize(25000);
    try {
        IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });

        // don't add primitives, we handle them as keywords

        TypeNameRequestor nameMatchRequestor = new TypeNameRequestor() {
            @Override
            public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                    char[][] enclosingTypeNames, String path) {
                StringBuilder fqName = new StringBuilder(packageName.length + simpleTypeName.length + 1);
                if (packageName.length != 0) {
                    fqName.append(packageName);
                    fqName.append('.');
                }
                for (char[] enclosingType : enclosingTypeNames) {
                    fqName.append(enclosingType);
                    fqName.append('.');
                }
                fqName.append(simpleTypeName);
                String fullyQualifiedName = fqName.toString();
                InternalEObject proxy = createProxy(fullyQualifiedName);
                Map<String, String> userData = null;
                if (enclosingTypeNames.length == 0) {
                    userData = ImmutableMap.of("flags", String.valueOf(modifiers));
                } else {
                    userData = ImmutableMap.of("flags", String.valueOf(modifiers), "inner", "true");
                }
                IEObjectDescription eObjectDescription = EObjectDescription
                        .create(getQualifiedNameConverter().toQualifiedName(fullyQualifiedName), proxy, userData);
                if (eObjectDescription != null)
                    allScopedElements.add(eObjectDescription);
            }
        };

        // start of modified code

        for (String allowedType : allowedJavaClassTypes) {
            new SearchEngine().searchAllTypeNames("java.lang".toCharArray(), SearchPattern.R_EXACT_MATCH,
                    allowedType.toCharArray(), SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.CLASS, searchScope,
                    nameMatchRequestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor());
        }

        // end of modified code

    } catch (JavaModelException e) {
        // ignore
    }
    return allScopedElements;
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeNameRequestorWrapper.java   
public TypeNameRequestorWrapper(TypeNameRequestor requestor) {
    this.requestor = requestor;
}
项目:mybatipse    文件:ProposalComputorHelper.java   
public static List<ICompletionProposal> proposeJavaType(IJavaProject project, final int start,
    final int length, boolean includeAlias, String matchString)
{
    final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
    if (includeAlias)
    {
        Map<String, String> aliasMap = TypeAliasCache.getInstance().searchTypeAliases(project,
            matchString);
        for (Entry<String, String> entry : aliasMap.entrySet())
        {
            String qualifiedName = entry.getKey();
            String alias = entry.getValue();
            proposals.add(new JavaCompletionProposal(alias, start, length, alias.length(),
                Activator.getIcon("/icons/mybatis-alias.png"), alias + " - " + qualifiedName, null,
                null, 200));
        }
    }

    int includeMask = IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS;
    // Include application libraries only when package is specified (for better performance).
    boolean pkgSpecified = matchString != null && matchString.indexOf('.') > 0;
    if (pkgSpecified)
        includeMask |= IJavaSearchScope.APPLICATION_LIBRARIES;
    IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[]{
        project
    }, includeMask);
    TypeNameRequestor requestor = new JavaTypeNameRequestor()
    {
        @Override
        public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
            char[][] enclosingTypeNames, String path)
        {
            if (Flags.isAbstract(modifiers) || Flags.isInterface(modifiers))
                return;

            addJavaTypeProposal(proposals, start, length, packageName, simpleTypeName,
                enclosingTypeNames);
        }
    };
    try
    {
        searchJavaType(matchString, scope, requestor);
    }
    catch (JavaModelException e)
    {
        Activator.log(Status.ERROR, e.getMessage(), e);
    }
    return proposals;
}
项目:mybatipse    文件:ProposalComputorHelper.java   
private static List<ICompletionProposal> proposeImplementation(IJavaProject project,
    final int start, final int length, String matchString, String interfaceFqn)
{
    final List<ICompletionProposal> results = new ArrayList<ICompletionProposal>();
    IType interfaceType;
    IJavaSearchScope scope;
    try
    {
        interfaceType = project.findType(interfaceFqn);
        if (interfaceType == null)
            return results;
        scope = SearchEngine.createHierarchyScope(interfaceType);
        final Map<String, String> aliasMap = TypeAliasCache.getInstance()
            .searchTypeAliases(project, matchString);
        TypeNameRequestor requestor = new JavaTypeNameRequestor()
        {
            @Override
            public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName,
                char[][] enclosingTypeNames, String path)
            {
                // Ignore abstract classes.
                if (Flags.isAbstract(modifiers) || Arrays.equals(JAVA_LANG, packageName))
                    return;

                addJavaTypeProposal(results, start, length, packageName, simpleTypeName,
                    enclosingTypeNames);

                String qualifiedName = NameUtil.buildQualifiedName(packageName, simpleTypeName,
                    enclosingTypeNames, true);
                String alias = aliasMap.get(qualifiedName);
                if (alias != null)
                {
                    results.add(new JavaCompletionProposal(alias, start, length, alias.length(),
                        Activator.getIcon("/icons/mybatis-alias.png"), alias + " - " + qualifiedName,
                        null, null, 200));
                }
            }
        };
        searchJavaType(matchString, scope, requestor);
    }
    catch (JavaModelException e)
    {
        Activator.log(Status.ERROR, e.getMessage(), e);
    }
    return results;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeNameRequestorWrapper.java   
public TypeNameRequestorWrapper(TypeNameRequestor requestor) {
    this.requestor = requestor;
}