本文整理汇总了Java中org.eclipse.jdt.core.search.IJavaSearchScope.SOURCES属性的典型用法代码示例。如果您正苦于以下问题:Java IJavaSearchScope.SOURCES属性的具体用法?Java IJavaSearchScope.SOURCES怎么用?Java IJavaSearchScope.SOURCES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.search.IJavaSearchScope
的用法示例。
在下文中一共展示了IJavaSearchScope.SOURCES属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMainTypes
public IType[] getMainTypes(IProgressMonitor monitor) {
IJavaProject javaProject = getJavaProject();
if (javaProject != null) {
// Returns main method types
boolean includeSubtypes = true;
MainMethodSearchEngine engine = new MainMethodSearchEngine();
int constraints = IJavaSearchScope.SOURCES;
constraints |= IJavaSearchScope.APPLICATION_LIBRARIES;
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(
new IJavaElement[] { javaProject }, constraints);
return engine.searchMainMethods(monitor, scope, includeSubtypes);
}
return new IType[] {};
}
示例2: findTypes
@Override
protected IType[] findTypes(Object[] elements, IRunnableContext context)
throws InterruptedException, CoreException
{
if(elements.length == 1)
{
IType type = getMainMethodType(elements[0]);
if(type != null)
return new IType[] { type };
}
int constraints = IJavaSearchScope.SOURCES;
IJavaElement[] javaElements = getJavaElements(elements);
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(javaElements, constraints);
ArrayList<IType> result = new ArrayList<IType>();
new MainMethodSearchHelper().searchMainMethods(context, scope, result);
return result.toArray(new IType[result.size()]);
}
示例3: findMainClasses
public static Collection<String> findMainClasses(IJavaProject p, IProgressMonitor monitor) {
MainMethodSearchEngine engine = new MainMethodSearchEngine();
int constraints = IJavaSearchScope.SOURCES;
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{p}, constraints);
IType[] types = engine.searchMainMethods(monitor, scope, false);
List<String> mains = Stream.of(types)
.filter(t -> hasContainerImport(t))
.map(IType::getFullyQualifiedName)
.collect(Collectors.toList());
mains.add(IWildFlySwarmConstants.DEFAULT_MAIN_CLASS);
return mains;
}
示例4: proposePackage
private void proposePackage(final ContentAssistRequest contentAssistRequest,
IJavaProject project, String matchString, final int start, final int length)
throws CoreException
{
final List<ICompletionProposal> results = new ArrayList<ICompletionProposal>();
final Set<String> foundPkgs = new HashSet<String>();
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.SYSTEM_LIBRARIES;
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[]{
project
}, includeMask);
SearchRequestor requestor = new SearchRequestor()
{
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException
{
PackageFragment element = (PackageFragment)match.getElement();
String pkg = element.getElementName();
if (pkg != null && pkg.length() > 0 && !foundPkgs.contains(pkg))
{
foundPkgs.add(pkg);
results.add(new CompletionProposal(pkg, start, length, pkg.length(),
Activator.getIcon(), pkg, null, null));
}
}
};
searchPackage(matchString, scope, requestor);
addProposals(contentAssistRequest, results);
}
示例5: proposeJavaType
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;
}