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


Java SearchRequestor类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.search.SearchRequestor的典型用法代码示例。如果您正苦于以下问题:Java SearchRequestor类的具体用法?Java SearchRequestor怎么用?Java SearchRequestor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SearchRequestor类属于org.eclipse.jdt.core.search包,在下文中一共展示了SearchRequestor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getITypeMainByWorkspaceScope

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
/**
 * search the bundle that contains the Main class. The search is done in the
 * workspace scope (ie. if it is defined in the current workspace it will
 * find it
 * 
 * @return the name of the bundle containing the Main class or null if not
 *         found
 */
private IType getITypeMainByWorkspaceScope(String className) {
	SearchPattern pattern = SearchPattern.createPattern(className, IJavaSearchConstants.CLASS,
			IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

	final List<IType> binaryType = new ArrayList<IType>();

	SearchRequestor requestor = new SearchRequestor() {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			binaryType.add((IType) match.getElement());
		}
	};
	SearchEngine engine = new SearchEngine();

	try {
		engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope,
				requestor, null);
	} catch (CoreException e1) {
		throw new RuntimeException("Error while searching the bundle: " + e1.getMessage());
		// return new Status(IStatus.ERROR, Activator.PLUGIN_ID, );
	}

	return binaryType.isEmpty() ? null : binaryType.get(0);
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:34,代码来源:PlainK3ExecutionEngine.java

示例2: findAllDeclarations

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException {
	fDeclarations = new ArrayList<>();

	class MethodRequestor extends SearchRequestor {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			IMethod method = (IMethod) match.getElement();
			boolean isBinary = method.isBinary();
			if (!isBinary) {
				fDeclarations.add(method);
			}
		}
	}

	int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE;
	int matchRule = SearchPattern.R_ERASURE_MATCH | SearchPattern.R_CASE_SENSITIVE;
	SearchPattern pattern = SearchPattern.createPattern(fMethod, limitTo, matchRule);
	MethodRequestor requestor = new MethodRequestor();
	SearchEngine searchEngine = owner != null ? new SearchEngine(owner) : new SearchEngine();

	searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, createSearchScope(), requestor, monitor);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:RippleMethodFinder.java

示例3: searchType

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private List<IType> searchType(String classFQN, IProgressMonitor monitor) {
	classFQN = classFQN.replace('$', '.');
	final List<IType> types = new ArrayList<IType>();

	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
	SearchEngine engine = new SearchEngine();
	SearchPattern pattern = SearchPattern.createPattern(classFQN, IJavaSearchConstants.TYPE,
			IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);

	SearchRequestor requestor = new SearchRequestor() {
		public void acceptSearchMatch(final SearchMatch match) throws CoreException {
			TypeDeclarationMatch typeMatch = (TypeDeclarationMatch) match;
			IType type = (IType) typeMatch.getElement();
			types.add(type);
		}
	};
	try {
		engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope,
				requestor, monitor);
	} catch (final CoreException e) {
		return types;
	}

	return types;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:26,代码来源:JavaTypeMemberBookmarkLocationProvider.java

示例4: search

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的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;
}
 
开发者ID:abnervr,项目名称:VRaptorEclipsePlugin,代码行数:25,代码来源:SearchHelper.java

示例5: searchForOuterTypesOfReferences

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private IType[] searchForOuterTypesOfReferences(IMethod[] newNameMethods, IProgressMonitor pm)
    throws CoreException {
  final Set<IType> outerTypesOfReferences = new HashSet<IType>();
  SearchPattern pattern =
      RefactoringSearchEngine.createOrPattern(newNameMethods, IJavaSearchConstants.REFERENCES);
  IJavaSearchScope scope = createRefactoringScope(getMethod());
  SearchRequestor requestor =
      new SearchRequestor() {
        @Override
        public void acceptSearchMatch(SearchMatch match) throws CoreException {
          Object element = match.getElement();
          if (!(element instanceof IMember))
            return; // e.g. an IImportDeclaration for a static method import
          IMember member = (IMember) element;
          IType declaring = member.getDeclaringType();
          if (declaring == null) return;
          IType outer = declaring.getDeclaringType();
          if (outer != null) outerTypesOfReferences.add(declaring);
        }
      };
  new SearchEngine()
      .search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
  return outerTypesOfReferences.toArray(new IType[outerTypesOfReferences.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RenameMethodProcessor.java

示例6: searchForDeclarationsOfClashingMethods

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private IMethod[] searchForDeclarationsOfClashingMethods(IProgressMonitor pm)
    throws CoreException {
  final List<IMethod> results = new ArrayList<IMethod>();
  SearchPattern pattern = createNewMethodPattern();
  IJavaSearchScope scope = RefactoringScopeFactory.create(getMethod().getJavaProject());
  SearchRequestor requestor =
      new SearchRequestor() {
        @Override
        public void acceptSearchMatch(SearchMatch match) throws CoreException {
          Object method = match.getElement();
          if (method
              instanceof
              IMethod) // check for bug 90138: [refactoring] [rename] Renaming method throws
            // internal exception
            results.add((IMethod) method);
          else
            JavaPlugin.logErrorMessage(
                "Unexpected element in search match: " + match.toString()); // $NON-NLS-1$
        }
      };
  new SearchEngine()
      .search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
  return results.toArray(new IMethod[results.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RenameMethodProcessor.java

示例7: searchForOuterTypesOfReferences

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private IType[] searchForOuterTypesOfReferences(IMethod[] newNameMethods, IProgressMonitor pm) throws CoreException {
	final Set<IType> outerTypesOfReferences= new HashSet<IType>();
	SearchPattern pattern= RefactoringSearchEngine.createOrPattern(newNameMethods, IJavaSearchConstants.REFERENCES);
	IJavaSearchScope scope= createRefactoringScope(getMethod());
	SearchRequestor requestor= new SearchRequestor() {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			Object element= match.getElement();
			if (!(element instanceof IMember))
				return; // e.g. an IImportDeclaration for a static method import
			IMember member= (IMember) element;
			IType declaring= member.getDeclaringType();
			if (declaring == null)
				return;
			IType outer= declaring.getDeclaringType();
			if (outer != null)
				outerTypesOfReferences.add(declaring);
		}
	};
	new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(),
			scope, requestor, pm);
	return outerTypesOfReferences.toArray(new IType[outerTypesOfReferences.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:RenameMethodProcessor.java

示例8: searchForDeclarationsOfClashingMethods

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private IMethod[] searchForDeclarationsOfClashingMethods(IProgressMonitor pm) throws CoreException {
	final List<IMethod> results= new ArrayList<IMethod>();
	SearchPattern pattern= createNewMethodPattern();
	IJavaSearchScope scope= RefactoringScopeFactory.create(getMethod().getJavaProject());
	SearchRequestor requestor= new SearchRequestor() {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			Object method= match.getElement();
			if (method instanceof IMethod) // check for bug 90138: [refactoring] [rename] Renaming method throws internal exception
				results.add((IMethod) method);
			else
				JavaPlugin.logErrorMessage("Unexpected element in search match: " + match.toString()); //$NON-NLS-1$
		}
	};
	new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
	return results.toArray(new IMethod[results.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:RenameMethodProcessor.java

示例9: getNamesakePackages

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
/**
 * @param scope search scope
 * @param pm mrogress monitor
 * @return all package fragments in <code>scope</code> with same name as <code>fPackage</code>, excluding fPackage
 * @throws CoreException if search failed
 */
private IPackageFragment[] getNamesakePackages(IJavaSearchScope scope, IProgressMonitor pm) throws CoreException {
	SearchPattern pattern= SearchPattern.createPattern(fPackage.getElementName(), IJavaSearchConstants.PACKAGE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);

	final HashSet<IPackageFragment> packageFragments= new HashSet<IPackageFragment>();
	SearchRequestor requestor= new SearchRequestor() {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			IJavaElement enclosingElement= SearchUtils.getEnclosingJavaElement(match);
			if (enclosingElement instanceof IPackageFragment) {
				IPackageFragment pack= (IPackageFragment) enclosingElement;
				if (! fPackage.equals(pack))
					packageFragments.add(pack);
			}
		}
	};
	new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);

	return packageFragments.toArray(new IPackageFragment[packageFragments.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:RenamePackageProcessor.java

示例10: createSearchRequestor

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
public SearchRequestor createSearchRequestor() {
	SearchRequestor requestor = new SearchRequestor() {
		@Override
           public void acceptSearchMatch(SearchMatch match) throws CoreException {
           	IJavaElement type = null;
           	if(match.getElement() instanceof ResolvedSourceMethod) {
           		type = ((ResolvedSourceMethod )match.getElement()).getParent();
           	} else if(match.getElement() instanceof ResolvedSourceType) {
           		type = ((ResolvedSourceType )match.getElement()).getParent();
           	} else if(match.getElement() instanceof ResolvedSourceField) {
           		type = ((ResolvedSourceField)match.getElement()).getParent();
           	} 
           	if(null != type && inChangedFiles(type.getElementName())) {
           		addMatched(match);
           	} 
           }
       };
       return requestor;
}
 
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:20,代码来源:DependencySummary.java

示例11: search

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
/**
 * Find all java files that match the class name
 * 
 * @param cls
 *            The class name
 * @return List of java files
 */
public static List<IJavaElement> search(String cls) {

	final List<IJavaElement> javaElements = new ArrayList<IJavaElement>();

	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
	SearchEngine engine = new SearchEngine();
	SearchPattern pattern = SearchPattern.createPattern(cls.split("\\.")[0], IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);

	SearchRequestor requestor = new SearchRequestor() {
		public void acceptSearchMatch(final SearchMatch match) throws CoreException {
			TypeDeclarationMatch typeMatch = (TypeDeclarationMatch) match;
			IJavaElement type = (IJavaElement) typeMatch.getElement();
			javaElements.add(type);
		}
	};
	try {
		engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, requestor, new NullProgressMonitor());
	}
	catch (final CoreException e) {
		e.printStackTrace();
	}

	return javaElements;
}
 
开发者ID:sromku,项目名称:bugsnag-eclipse-plugin,代码行数:32,代码来源:WorkspaceUtils.java

示例12: search

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
protected void search(String patternString, int searchFor, int limitTo, int matchRule, IJavaSearchScope scope, SearchRequestor requestor) throws CoreException {
	if (patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1)
		matchRule |= SearchPattern.R_PATTERN_MATCH;
	SearchPattern pattern = SearchPattern.createPattern(
		patternString,
		searchFor,
		limitTo,
		matchRule);
	assertNotNull("Pattern should not be null", pattern);
	new SearchEngine().search(
		pattern,
		new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
		scope,
		requestor,
		null);
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:17,代码来源:AbstractJavaModelTests.java

示例13: getJavaProjectFromType

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
/**
 * Get java project from type.
 *
 * @param fullyQualifiedTypeName
 *            fully qualified name of type
 * @return java project
 * @throws CoreException
 *             CoreException
 */
private static List<IJavaProject> getJavaProjectFromType(String fullyQualifiedTypeName) throws CoreException {
    String[] splitItems = fullyQualifiedTypeName.split("/");
    // If the main class name contains the module name, should trim the module info.
    if (splitItems.length == 2) {
        fullyQualifiedTypeName = splitItems[1];
    }
    final String moduleName = splitItems.length == 2 ? splitItems[0] : null;

    SearchPattern pattern = SearchPattern.createPattern(
            fullyQualifiedTypeName,
            IJavaSearchConstants.TYPE,
            IJavaSearchConstants.DECLARATIONS,
            SearchPattern.R_EXACT_MATCH);
    IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
    ArrayList<IJavaProject> projects = new ArrayList<>();
    SearchRequestor requestor = new SearchRequestor() {
        @Override
        public void acceptSearchMatch(SearchMatch match) {
            Object element = match.getElement();
            if (element instanceof IJavaElement) {
                IJavaProject project = ((IJavaElement) element).getJavaProject();
                if (moduleName == null || moduleName.equals(JdtUtils.getModuleName(project))) {
                    projects.add(project);
                }
            }
        }
    };
    SearchEngine searchEngine = new SearchEngine();
    searchEngine.search(pattern, new SearchParticipant[] {
        SearchEngine.getDefaultSearchParticipant() }, scope,
        requestor, null /* progress monitor */);

    return projects.stream().distinct().collect(Collectors.toList());
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:44,代码来源:ResolveClasspathsHandler.java

示例14: renameOccurrences

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
public void renameOccurrences(WorkspaceEdit edit, String newName, IProgressMonitor monitor) throws CoreException {
	if (fElement == null || !canRename()) {
		return;
	}

	IJavaElement[] elementsToSearch = null;

	if (fElement instanceof IMethod) {
		elementsToSearch = RippleMethodFinder.getRelatedMethods((IMethod) fElement, monitor, null);
	} else {
		elementsToSearch = new IJavaElement[] { fElement };
	}

	SearchPattern pattern = createOccurrenceSearchPattern(elementsToSearch);
	if (pattern == null) {
		return;
	}
	SearchEngine engine = new SearchEngine();
	engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, createSearchScope(), new SearchRequestor() {

		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			Object o = match.getElement();
			if (o instanceof IJavaElement) {
				IJavaElement element = (IJavaElement) o;
				ICompilationUnit compilationUnit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
				if (compilationUnit == null) {
					return;
				}
				TextEdit replaceEdit = collectMatch(match, element, compilationUnit, newName);
				if (replaceEdit != null) {
					convert(edit, compilationUnit, replaceEdit);
				}
			}
		}
	}, monitor);

}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:39,代码来源:RenameProcessor.java

示例15: findReferences

import org.eclipse.jdt.core.search.SearchRequestor; //导入依赖的package包/类
private Set<SearchMatch> findReferences(Set<? extends IJavaElement> elements) throws CoreException {
	Set<SearchMatch> ret = new HashSet<>();
	for (IJavaElement elem : elements)
		new SearchEngine().search(
				SearchPattern.createPattern(elem, IJavaSearchConstants.REFERENCES, SearchPattern.R_EXACT_MATCH),
				new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
				SearchEngine.createWorkspaceScope(), new SearchRequestor() {

					@Override
					public void acceptSearchMatch(SearchMatch match) throws CoreException {
						ret.add(match);
					}
				}, new NullProgressMonitor());
	return ret;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:16,代码来源:EvaluateMigrateSkeletalImplementationToInterfaceRefactoringHandler.java


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