List of usage examples for org.eclipse.jdt.core.search TypeNameMatch getSimpleTypeName
public String getSimpleTypeName()
From source file:org.codehaus.groovy.eclipse.refactoring.actions.TypeSearch.java
License:Apache License
/** * Use a SearchEngine to look for the types * This will not find inner types, however * * @see OrganizeImportsOperation.TypeReferenceProcessor#process(org.eclipse.core.runtime.IProgressMonitor) * @param missingType/* www . java 2 s.c o m*/ * @throws JavaModelException */ public void searchForTypes(GroovyCompilationUnit unit, Map<String, OrganizeGroovyImports.UnresolvedTypeData> missingTypes) throws JavaModelException { char[][] allTypes = new char[missingTypes.size()][]; int i = 0; for (String simpleName : missingTypes.keySet()) { allTypes[i++] = simpleName.toCharArray(); } final List<TypeNameMatch> typesFound = new ArrayList<TypeNameMatch>(); TypeNameMatchCollector collector = new TypeNameMatchCollector(typesFound); IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { unit.getJavaProject() }); new SearchEngine().searchAllTypeNames(null, allTypes, scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); for (TypeNameMatch match : typesFound) { UnresolvedTypeData data = missingTypes.get(match.getSimpleTypeName()); if (data == null) { GroovyCore.logException( "GRECLIPSE-735: Match not found in missing types: " + match.getFullyQualifiedName(), new Exception()); continue; } if (isOfKind(match, data.isAnnotation)) { data.addInfo(match); } } }
From source file:org.flowerplatform.editor.model.java.JavaTypeNameRequestor.java
License:Open Source License
@Override public void acceptTypeNameMatch(TypeNameMatch match) { String fullyQualifiedName = match.getFullyQualifiedName(); String simpleName = match.getSimpleTypeName(); String pck = match.getPackageName(); String containerType = match.getTypeContainerName(); if (containerType.length() > 0) { pck = containerType;/*from ww w. j a v a 2s .co m*/ } String iconUrl = getIconUrl(match.getType()); ContentAssistItem item = new ContentAssistItem(fullyQualifiedName, simpleName, pck, iconUrl); matches.add(item); if (matches.size() == IContentAssist.MAX_TYPES_COUNT) { progressMonitor.setCanceled(true); } }
From source file:org.jboss.tools.vscode.java.internal.handlers.WorkspaceSymbolHandler.java
License:Open Source License
private List<SymbolInformation> search(String query) { try {/*from ww w. j av a 2s . com*/ ArrayList<SymbolInformation> symbols = new ArrayList<SymbolInformation>(); new SearchEngine().searchAllTypeNames(null, SearchPattern.R_PATTERN_MATCH, query.toCharArray(), SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, createSearchScope(), new TypeNameMatchRequestor() { @Override public void acceptTypeNameMatch(TypeNameMatch match) { SymbolInformation symbolInformation = new SymbolInformation(); symbolInformation.setContainerName(match.getTypeContainerName()); symbolInformation.setName(match.getSimpleTypeName()); symbolInformation.setKind(new Double(DocumentSymbolHandler.mapKind(match.getType()))); Location location = new Location(); location.setUri(match.getType().getResource().getLocationURI().toString()); location.setRange(new Range() .withEnd(new Position().withLine(Double.valueOf(0)) .withCharacter(Double.valueOf(0))) .withStart(new Position().withLine(Double.valueOf(0)) .withCharacter(Double.valueOf(0)))); symbols.add(symbolInformation.withLocation(location)); } }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, new NullProgressMonitor()); return symbols; } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Problem getting search for" + query, e); } return Collections.emptyList(); }