当前位置: 首页>>代码示例>>Java>>正文


Java IJavaSearchScope.SOURCES属性代码示例

本文整理汇总了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[] {};

}
 
开发者ID:eclipse,项目名称:cft,代码行数:16,代码来源:JavaTypeResolver.java

示例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()]);
}
 
开发者ID:JanKoehnlein,项目名称:XRobot,代码行数:19,代码来源:LaunchEV3Shortcut.java

示例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;
}
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:13,代码来源:MainClassDetector.java

示例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);
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:32,代码来源:XmlCompletionProposalComputer.java

示例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;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:49,代码来源:ProposalComputorHelper.java


注:本文中的org.eclipse.jdt.core.search.IJavaSearchScope.SOURCES属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。