本文整理汇总了Java中org.eclipse.jdt.core.search.SearchMatch类的典型用法代码示例。如果您正苦于以下问题:Java SearchMatch类的具体用法?Java SearchMatch怎么用?Java SearchMatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchMatch类属于org.eclipse.jdt.core.search包,在下文中一共展示了SearchMatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getITypeMainByWorkspaceScope
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的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.SearchMatch; //导入依赖的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.SearchMatch; //导入依赖的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: rewriteCompilationUnit
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
protected void rewriteCompilationUnit(ICompilationUnit unit,
Collection matches, CompilationUnit node, RefactoringStatus status,
IProgressMonitor monitor) throws CoreException {
final ASTRewrite astRewrite = ASTRewrite.create(node.getAST());
final ImportRewrite importRewrite = ImportRewrite.create(node, true);
for (final Iterator it = matches.iterator(); it.hasNext();) {
final SearchMatch match = (SearchMatch) it.next();
if (match.getAccuracy() == SearchMatch.A_ACCURATE
&& !match.isInsideDocComment())
if (this.matchToPurposeMap.get(match) == SearchMatchPurpose.ALTER_TYPE_DECLARATION
|| this.matchToPurposeMap.get(match) == SearchMatchPurpose.ALTER_NAMESPACE_PREFIX)
this.rewriteDeclarationsAndNamespaces(node, match, status,
astRewrite, importRewrite);
else if (this.matchToPurposeMap.get(match) == SearchMatchPurpose.ALTER_INFIX_EXPRESSION)
this.rewriteExpressions(node, match, status, astRewrite,
importRewrite);
}
this.rewriteAST(unit, astRewrite, importRewrite);
}
开发者ID:ponder-lab,项目名称:Constants-to-Enum-Eclipse-Plugin,代码行数:22,代码来源:ConvertConstantsToEnumRefactoring.java
示例5: search
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的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
示例6: getCompilationUnit
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
/**
* @param match the search match
* @return the enclosing {@link ICompilationUnit} of the given match, or null iff none
*/
public static ICompilationUnit getCompilationUnit(SearchMatch match) {
IJavaElement enclosingElement = getEnclosingJavaElement(match);
if (enclosingElement != null) {
if (enclosingElement instanceof ICompilationUnit) return (ICompilationUnit) enclosingElement;
ICompilationUnit cu =
(ICompilationUnit) enclosingElement.getAncestor(IJavaElement.COMPILATION_UNIT);
if (cu != null) return cu;
}
IJavaElement jElement = JavaCore.create(match.getResource());
if (jElement != null
&& jElement.exists()
&& jElement.getElementType() == IJavaElement.COMPILATION_UNIT)
return (ICompilationUnit) jElement;
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:SearchUtils.java
示例7: addReferenceUpdates
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
private void addReferenceUpdates(TextChangeManager manager, IProgressMonitor pm) {
SearchResultGroup[] grouped = getOccurrences();
for (int i = 0; i < grouped.length; i++) {
SearchResultGroup group = grouped[i];
SearchMatch[] results = group.getSearchResults();
ICompilationUnit cu = group.getCompilationUnit();
TextChange change = manager.get(cu);
for (int j = 0; j < results.length; j++) {
SearchMatch match = results[j];
if (!(match instanceof MethodDeclarationMatch)) {
ReplaceEdit replaceEdit = createReplaceEdit(match, cu);
String editName = RefactoringCoreMessages.RenamePrivateMethodRefactoring_update;
addTextEdit(change, editName, replaceEdit);
}
}
}
pm.done();
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:RenameNonVirtualMethodProcessor.java
示例8: searchForOuterTypesOfReferences
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的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
示例9: searchForDeclarationsOfClashingMethods
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的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
示例10: createReplaceEdit
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
protected final ReplaceEdit createReplaceEdit(SearchMatch searchResult, ICompilationUnit cu) {
if (searchResult.isImplicit()) { // handle Annotation Element references, see bug 94062
StringBuffer sb = new StringBuffer(getNewElementName());
if (JavaCore.INSERT.equals(
cu.getJavaProject()
.getOption(
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR,
true))) sb.append(' ');
sb.append('=');
if (JavaCore.INSERT.equals(
cu.getJavaProject()
.getOption(
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR,
true))) sb.append(' ');
return new ReplaceEdit(searchResult.getOffset(), 0, sb.toString());
} else {
return new ReplaceEdit(
searchResult.getOffset(), searchResult.getLength(), getNewElementName());
}
}
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RenameMethodProcessor.java
示例11: addReferenceUpdates
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
private void addReferenceUpdates(TextChangeManager manager, IProgressMonitor pm) {
pm.beginTask("", fReferences.length); // $NON-NLS-1$
for (int i = 0; i < fReferences.length; i++) {
ICompilationUnit cu = fReferences[i].getCompilationUnit();
if (cu == null) continue;
String name = RefactoringCoreMessages.RenameTypeRefactoring_update_reference;
SearchMatch[] results = fReferences[i].getSearchResults();
for (int j = 0; j < results.length; j++) {
SearchMatch match = results[j];
ReplaceEdit replaceEdit =
new ReplaceEdit(match.getOffset(), match.getLength(), getNewElementName());
TextChangeCompatibility.addTextEdit(
manager.get(cu), name, replaceEdit, CATEGORY_TYPE_RENAME);
}
pm.worked(1);
}
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenameTypeProcessor.java
示例12: analyzeRenameChanges
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
static RefactoringStatus analyzeRenameChanges(
TextChangeManager manager,
SearchResultGroup[] oldOccurrences,
SearchResultGroup[] newOccurrences) {
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < oldOccurrences.length; i++) {
SearchResultGroup oldGroup = oldOccurrences[i];
SearchMatch[] oldSearchResults = oldGroup.getSearchResults();
ICompilationUnit cunit = oldGroup.getCompilationUnit();
if (cunit == null) continue;
for (int j = 0; j < oldSearchResults.length; j++) {
SearchMatch oldSearchResult = oldSearchResults[j];
if (!RenameAnalyzeUtil.existsInNewOccurrences(oldSearchResult, newOccurrences, manager)) {
addShadowsError(cunit, oldSearchResult, result);
}
}
}
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenameAnalyzeUtil.java
示例13: addReferenceShadowedError
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
private static void addReferenceShadowedError(
ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
// Found a new match with no corresponding old match.
// -> The new match is a reference which was pointing to another element,
// but that other element has been shadowed
// TODO: should not have to filter declarations:
if (newMatch instanceof MethodDeclarationMatch || newMatch instanceof FieldDeclarationMatch)
return;
ISourceRange range = getOldSourceRange(newMatch);
RefactoringStatusContext context = JavaStatusContext.create(cu, range);
String message =
Messages.format(
RefactoringCoreMessages.RenameAnalyzeUtil_reference_shadowed,
new String[] {
BasicElementLabels.getFileName(cu),
BasicElementLabels.getJavaElementName(newElementName)
});
result.addError(message, context);
}
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RenameAnalyzeUtil.java
示例14: getResults
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
public List<V> getResults() {
while (!isDone) {
synchronized (this) {
try {
wait(50);
} catch (InterruptedException e) {
DataHierarchyPlugin.logError("getResults() interrupted...", e);
}
}
}
List<V> results = new ArrayList<V>();
for (SearchMatch match : searchResults) {
results.add((V) match.getElement());
}
return results;
}
开发者ID:iloveeclipse,项目名称:datahierarchy,代码行数:17,代码来源:AbstractReferencesRequestor.java
示例15: getAllRippleMethods
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
private IMethod[] getAllRippleMethods(IProgressMonitor pm, WorkingCopyOwner owner)
throws CoreException {
IMethod[] rippleMethods = findAllRippleMethods(pm, owner);
if (fDeclarationToMatch == null) return rippleMethods;
List<IMethod> rippleMethodsList = new ArrayList<IMethod>(Arrays.asList(rippleMethods));
for (Iterator<IMethod> iter = rippleMethodsList.iterator(); iter.hasNext(); ) {
Object match = fDeclarationToMatch.get(iter.next());
if (match != null) {
iter.remove();
fBinaryRefs.add((SearchMatch) match);
}
}
fDeclarationToMatch = null;
return rippleMethodsList.toArray(new IMethod[rippleMethodsList.size()]);
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:RippleMethodFinder2.java
示例16: addTypeImports
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
/**
* Add new imports to types in <code>typeReferences</code> with package <code>fPackage</code>.
*
* @param typeReferences type references
* @throws CoreException should not happen
*/
private void addTypeImports(SearchResultGroup typeReferences) throws CoreException {
SearchMatch[] searchResults = typeReferences.getSearchResults();
for (int i = 0; i < searchResults.length; i++) {
SearchMatch result = searchResults[i];
IJavaElement enclosingElement = SearchUtils.getEnclosingJavaElement(result);
if (!(enclosingElement instanceof IImportDeclaration)) {
String reference = getNormalizedTypeReference(result);
if (!reference.startsWith(fPackage.getElementName())) {
// is unqualified
reference = cutOffInnerTypes(reference);
ImportChange importChange =
fImportsManager.getImportChange(typeReferences.getCompilationUnit());
importChange.addImport(fPackage.getElementName() + '.' + reference);
}
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:RenamePackageProcessor.java
示例17: updateTypeImports
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
/**
* Add new imports to types in <code>typeReferences</code> with package <code>fNewElementName
* </code> and remove old import with <code>fPackage</code>.
*
* @param typeReferences type references
* @throws CoreException should not happen
*/
private void updateTypeImports(SearchResultGroup typeReferences) throws CoreException {
SearchMatch[] searchResults = typeReferences.getSearchResults();
for (int i = 0; i < searchResults.length; i++) {
SearchMatch result = searchResults[i];
IJavaElement enclosingElement = SearchUtils.getEnclosingJavaElement(result);
if (enclosingElement instanceof IImportDeclaration) {
IImportDeclaration importDeclaration = (IImportDeclaration) enclosingElement;
updateImport(
typeReferences.getCompilationUnit(),
importDeclaration,
getUpdatedImport(importDeclaration));
} else {
String reference = getNormalizedTypeReference(result);
if (!reference.startsWith(fPackage.getElementName())) {
reference = cutOffInnerTypes(reference);
ImportChange importChange =
fImportsManager.getImportChange(typeReferences.getCompilationUnit());
importChange.removeImport(fPackage.getElementName() + '.' + reference);
importChange.addImport(getNewPackageName() + '.' + reference);
} // else: already found & updated with package reference search
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:RenamePackageProcessor.java
示例18: acceptSearchMatch
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
@Override
public final void acceptSearchMatch(final SearchMatch match) throws CoreException {
final SearchMatch accepted = fRequestor.acceptSearchMatch(match);
if (accepted != null) {
final IResource resource = accepted.getResource();
if (!resource.equals(fLastResource)) {
final IJavaElement element = JavaCore.create(resource);
if (element instanceof ICompilationUnit) fCollectedUnits.add((ICompilationUnit) element);
}
if (fInaccurate
&& accepted.getAccuracy() == SearchMatch.A_INACCURATE
&& !fInaccurateMatches.contains(accepted)) {
fStatus.addEntry(
fSeverity,
Messages.format(
RefactoringCoreMessages.RefactoringSearchEngine_inaccurate_match,
BasicElementLabels.getResourceName(accepted.getResource())),
null,
null,
RefactoringStatusEntry.NO_CODE);
fInaccurateMatches.add(accepted);
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RefactoringSearchEngine2.java
示例19: findReferences
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
private SearchResultGroup[] findReferences(IProgressMonitor pm, RefactoringStatus status)
throws JavaModelException {
final RefactoringSearchEngine2 engine =
new RefactoringSearchEngine2(
SearchPattern.createPattern(fField, IJavaSearchConstants.REFERENCES));
engine.setFiltering(true, true);
engine.setScope(RefactoringScopeFactory.create(fField));
engine.setStatus(status);
engine.setRequestor(
new IRefactoringSearchRequestor() {
public SearchMatch acceptSearchMatch(SearchMatch match) {
return match.isInsideDocComment() ? null : match;
}
});
engine.searchPattern(new SubProgressMonitor(pm, 1));
return (SearchResultGroup[]) engine.getResults();
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:InlineConstantRefactoring.java
示例20: toString
import org.eclipse.jdt.core.search.SearchMatch; //导入依赖的package包/类
@Override
public String toString() {
StringBuffer buf = new StringBuffer(fResouce.getFullPath().toString());
buf.append('\n');
for (int i = 0; i < fSearchMatches.size(); i++) {
SearchMatch match = fSearchMatches.get(i);
buf.append(" ")
.append(match.getOffset())
.append(", ")
.append(match.getLength()); // $NON-NLS-1$//$NON-NLS-2$
buf.append(
match.getAccuracy() == SearchMatch.A_ACCURATE
? "; acc"
: "; inacc"); // $NON-NLS-1$//$NON-NLS-2$
if (match.isInsideDocComment()) buf.append("; inDoc"); // $NON-NLS-1$
if (match.getElement() instanceof IJavaElement)
buf.append("; in: ")
.append(((IJavaElement) match.getElement()).getElementName()); // $NON-NLS-1$
buf.append('\n');
}
return buf.toString();
}
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:SearchResultGroup.java
注:本文中的org.eclipse.jdt.core.search.SearchMatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论