本文整理汇总了Java中org.eclipse.jdt.core.search.SearchEngine.createJavaSearchScope方法的典型用法代码示例。如果您正苦于以下问题:Java SearchEngine.createJavaSearchScope方法的具体用法?Java SearchEngine.createJavaSearchScope怎么用?Java SearchEngine.createJavaSearchScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.search.SearchEngine
的用法示例。
在下文中一共展示了SearchEngine.createJavaSearchScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMainTypes
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
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: search
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
private static List<Controller> search(IJavaProject project, SearchPattern namePattern) throws JavaModelException, CoreException {
List<Controller> controllers = new ArrayList<Controller>();
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(project.getPackageFragments());
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) {
if (match.getElement() instanceof IJavaElement) {
IJavaElement element = (IJavaElement) match.getElement();
controllers.add(new Controller((IType) element));
}
}
};
SearchEngine searchEngine = new SearchEngine();
searchEngine.search(namePattern, new SearchParticipant[] {SearchEngine
.getDefaultSearchParticipant()}, scope, requestor,
null);
return controllers;
}
示例3: create
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
/**
* Creates a new search scope with all compilation units possibly referencing <code>javaElement
* </code>.
*
* @param javaElement the java element
* @param considerVisibility consider visibility of javaElement iff <code>true</code>
* @param sourceReferencesOnly consider references in source only (no references in binary)
* @return the search scope
* @throws JavaModelException if an error occurs
*/
public static IJavaSearchScope create(
IJavaElement javaElement, boolean considerVisibility, boolean sourceReferencesOnly)
throws JavaModelException {
if (considerVisibility & javaElement instanceof IMember) {
IMember member = (IMember) javaElement;
if (JdtFlags.isPrivate(member)) {
if (member.getCompilationUnit() != null)
return SearchEngine.createJavaSearchScope(
new IJavaElement[] {member.getCompilationUnit()});
else return SearchEngine.createJavaSearchScope(new IJavaElement[] {member});
}
// Removed code that does some optimizations regarding package visible members. The problem is
// that
// there can be a package fragment with the same name in a different source folder or project.
// So we
// have to treat package visible members like public or protected members.
}
IJavaProject javaProject = javaElement.getJavaProject();
return SearchEngine.createJavaSearchScope(
getAllScopeElements(javaProject, sourceReferencesOnly), false);
}
示例4: getReferencedFields
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
/**
* Blocks current thread until search is done
*/
public List<IField> getReferencedFields(IProgressMonitor monitor) throws CoreException {
boolean searchOnlyStatics = conf.get(ISearchConfiguration.SEARCH_STATICS_ONLY);
searchOnlyStatics = searchOnlyStatics && searchRoot.isVisibleRoot();
FieldReferencesRequestor searchRequestor = SearchUtils.createFieldRequestor(conf,
searchOnlyStatics);
IType[] typesForAllElements = SearchUtils.getAlSuperTypesForAllElements(
searchRoot, monitor);
IJavaElement javaElement = searchRoot.getJavaElement();
if(typesForAllElements.length == 0
|| javaElement instanceof IPackageFragmentRoot
|| javaElement instanceof IPackageFragment){
pattern = SearchHelper.createAnyFieldPattern();
scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{javaElement}, IJavaSearchScope.SOURCES);
} else {
pattern = SearchHelper.createAnyFieldPattern(typesForAllElements);
scope = SearchEngine.createJavaSearchScope(typesForAllElements, IJavaSearchScope.SOURCES);
}
return search(searchRequestor, monitor);
}
示例5: find
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
@Override
public void find() {
SearchEngine engine = new SearchEngine();
IJavaSearchScope workspaceScope = null;
if(getProject() != null) {
workspaceScope = SearchEngine.createJavaSearchScope(createSearchScope());
} else {
workspaceScope = SearchEngine.createWorkspaceScope();
}
SearchPattern pattern = SearchPattern.createPattern(
getElement().getPrimaryElement().getElementName().replace(Constants.JAVA_EXTENSION, Constants.EMPTY_STRING),
IJavaSearchConstants.TYPE,
IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH);
SearchParticipant[] participant = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
try {
engine.search(pattern, participant, workspaceScope, createSearchRequestor(), new NullProgressMonitor());
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: chooseIntermediaryType
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
private IType chooseIntermediaryType() {
IJavaProject proj= getIntroduceIndirectionRefactoring().getProject();
if (proj == null)
return null;
IJavaElement[] elements= new IJavaElement[] { proj };
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
int elementKinds= JavaModelUtil.is18OrHigher(proj) ? IJavaSearchConstants.CLASS_AND_INTERFACE : IJavaSearchConstants.CLASS;
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false, getWizard().getContainer(), scope, elementKinds);
dialog.setTitle(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class);
dialog.setMessage(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class_long);
if (dialog.open() == Window.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:IntroduceIndirectionInputPage.java
示例7: browseForAccessorClass
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
protected void browseForAccessorClass() {
IProgressService service= PlatformUI.getWorkbench().getProgressService();
IPackageFragmentRoot root= fAccessorPackage.getSelectedFragmentRoot();
IJavaSearchScope scope= root != null ? SearchEngine.createJavaSearchScope(new IJavaElement[] { root }) : SearchEngine.createWorkspaceScope();
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog (getShell(), false,
service, scope, IJavaSearchConstants.CLASS);
dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Accessor_Selection);
dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_accessor_file);
dialog.setInitialPattern("*Messages"); //$NON-NLS-1$
if (dialog.open() == Window.OK) {
IType selectedType= (IType) dialog.getFirstResult();
if (selectedType != null) {
fAccessorClassName.setText(selectedType.getElementName());
fAccessorPackage.setSelected(selectedType.getPackageFragment());
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:NLSAccessorConfigurationDialog.java
示例8: chooseSuperClass
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
/**
* Opens a selection dialog that allows to select a super class.
*
* @return returns the selected type or <code>null</code> if the dialog has been canceled.
* The caller typically sets the result to the super class input field.
* <p>
* Clients can override this method if they want to offer a different dialog.
* </p>
*
* @since 3.2
*/
protected IType chooseSuperClass() {
IJavaProject project= getJavaProject();
if (project == null) {
return null;
}
IJavaElement[] elements= new IJavaElement[] { project };
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
getWizard().getContainer(), scope, IJavaSearchConstants.CLASS);
dialog.setTitle(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_title);
dialog.setMessage(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_message);
dialog.setInitialPattern(getSuperClass());
if (dialog.open() == Window.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
示例9: createSearchScope
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
public static IJavaSearchScope createSearchScope(IJavaProject project) {
if (project == null) {
return SearchEngine.createWorkspaceScope();
}
return SearchEngine.createJavaSearchScope(new IJavaProject[] { project },
IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SYSTEM_LIBRARIES);
}
示例10: getSearchScope
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
protected IJavaSearchScope getSearchScope(ReferenceScope scope, ICompilationUnit compilationUnit) {
if (scope == ReferenceScope.Class) {
return SearchEngine.createJavaSearchScope(new IJavaElement[] { compilationUnit });
}
return SearchEngine.createWorkspaceScope();
}
示例11: classExists
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
@VisibleForTesting
static boolean classExists(IJavaProject project, String typeName) {
if (Strings.isNullOrEmpty(typeName)) {
return false;
}
SearchPattern pattern = SearchPattern.createPattern(typeName,
IJavaSearchConstants.CLASS,
IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_ERASURE_MATCH);
IJavaSearchScope scope = project == null ? SearchEngine.createWorkspaceScope()
: SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
return performSearch(pattern, scope, null);
}
示例12: findMainClasses
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
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;
}
示例13: handleTypeBrowsing
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
public void handleTypeBrowsing() {
Text textControl = javaStartCommandPart.getTypeText();
if (textControl == null) {
return;
}
String pattern = textControl.getText();
Shell shell = getShell();
int javaSearchType = IJavaSearchConstants.CLASS;
IJavaElement[] elements = new IJavaElement[] { javaProject };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(
shell, false, null, scope, javaSearchType);
dialog.setTitle(title);
dialog.setInitialPattern(pattern);
if (dialog.open() == Window.OK) {
IType type = (IType) dialog.getFirstResult();
if (type != null) {
String qualifiedName = type.getFullyQualifiedName();
if (qualifiedName != null) {
textControl.setText(qualifiedName);
}
}
}
javaStartCommandPart.updateStartCommand();
}
示例14: getPackageAndOccurrencesWithoutNamesakesScope
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
/**
* @return search scope with
* <p>- fPackage and
* <p>- all CUs from fOccurrences which are not in a namesake package
*/
private IJavaSearchScope getPackageAndOccurrencesWithoutNamesakesScope() {
List<IJavaElement> scopeList = new ArrayList<IJavaElement>();
scopeList.add(fPackage);
for (int i = 0; i < fOccurrences.length; i++) {
ICompilationUnit cu = fOccurrences[i].getCompilationUnit();
if (cu == null) continue;
IPackageFragment pack = (IPackageFragment) cu.getParent();
if (!pack.getElementName().equals(fPackage.getElementName())) scopeList.add(cu);
}
return SearchEngine.createJavaSearchScope(
scopeList.toArray(new IJavaElement[scopeList.size()]));
}
示例15: getReferencesToTypesInPackage
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
private List<SearchResultGroup> getReferencesToTypesInPackage(
IProgressMonitor pm, ReferencesInBinaryContext binaryRefs, RefactoringStatus status)
throws CoreException {
pm.beginTask("", 2); // $NON-NLS-1$
IJavaSearchScope referencedFromNamesakesScope =
RefactoringScopeFactory.create(fPackage, true, false);
IPackageFragment[] namesakePackages =
getNamesakePackages(referencedFromNamesakesScope, new SubProgressMonitor(pm, 1));
if (namesakePackages.length == 0) {
pm.done();
return new ArrayList<SearchResultGroup>(0);
}
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(namesakePackages);
IType[] typesToSearch = getTypesInPackage(fPackage);
if (typesToSearch.length == 0) {
pm.done();
return new ArrayList<SearchResultGroup>(0);
}
SearchPattern pattern =
RefactoringSearchEngine.createOrPattern(typesToSearch, IJavaSearchConstants.REFERENCES);
CollectingSearchRequestor requestor = new CuCollectingSearchRequestor(binaryRefs);
SearchResultGroup[] results =
RefactoringSearchEngine.search(
pattern, scope, requestor, new SubProgressMonitor(pm, 1), status);
pm.done();
return new ArrayList<SearchResultGroup>(Arrays.asList(results));
}