當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchEngine.search方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.search.SearchEngine.search方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchEngine.search方法的具體用法?Java SearchEngine.search怎麽用?Java SearchEngine.search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.search.SearchEngine的用法示例。


在下文中一共展示了SearchEngine.search方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getITypeMainByWorkspaceScope

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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: performSearch

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
/**
 * Searches for a class that matches a pattern.
 */
@VisibleForTesting
static boolean performSearch(SearchPattern pattern, IJavaSearchScope scope,
    IProgressMonitor monitor) {
  try {
    SearchEngine searchEngine = new SearchEngine();
    TypeSearchRequestor requestor = new TypeSearchRequestor();
    searchEngine.search(pattern,
        new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
        scope, requestor, monitor);
    return requestor.foundMatch();
  } catch (CoreException ex) {
    logger.log(Level.SEVERE, ex.getMessage());
    return false;
  }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:19,代碼來源:WebXmlValidator.java

示例3: findAllDeclarations

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例4: searchType

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例5: 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;
}
 
開發者ID:abnervr,項目名稱:VRaptorEclipsePlugin,代碼行數:25,代碼來源:SearchHelper.java

示例6: internalSearch

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private static SearchResultGroup[] internalSearch(
    SearchEngine searchEngine,
    SearchPattern pattern,
    IJavaSearchScope scope,
    CollectingSearchRequestor requestor,
    IProgressMonitor monitor,
    RefactoringStatus status)
    throws JavaModelException {
  try {
    searchEngine.search(
        pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, monitor);
  } catch (CoreException e) {
    throw new JavaModelException(e);
  }
  return groupByCu(requestor.getResults(), status);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:17,代碼來源:RefactoringSearchEngine.java

示例7: 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();
	}
}
 
開發者ID:SEMERU-WM,項目名稱:ChangeScribe,代碼行數:26,代碼來源:TypeDependencySummary.java

示例8: search

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例9: getJavaProjectFromType

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例10: renameOccurrences

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例11: commenceSearch

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
void commenceSearch(SearchEngine engine, SearchPattern pattern,
		IJavaSearchScope scope, final SearchMatchPurpose purpose,
		IProgressMonitor monitor) throws CoreException {
	engine.search(pattern, new SearchParticipant[] { SearchEngine
			.getDefaultSearchParticipant() }, scope, new SearchRequestor() {

		public void acceptSearchMatch(SearchMatch match)
				throws CoreException {
			if (match.getAccuracy() == SearchMatch.A_ACCURATE
					&& !match.isInsideDocComment())
				matchToPurposeMap.put(match, purpose);
		}
	}, new SubProgressMonitor(monitor, 1,
			SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
}
 
開發者ID:ponder-lab,項目名稱:Constants-to-Enum-Eclipse-Plugin,代碼行數:16,代碼來源:ConvertConstantsToEnumRefactoring.java

示例12: findParameters

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private void findParameters(final int paramNumber, SearchPattern pattern)
		throws CoreException {

	final SearchRequestor requestor = new SearchRequestor() {

		public void acceptSearchMatch(SearchMatch match)
				throws CoreException {
			if (match.getAccuracy() == SearchMatch.A_ACCURATE
					&& !match.isInsideDocComment()) {
				IJavaElement elem = (IJavaElement) match.getElement();
				ASTNode node = Util.getASTNode(elem,
						ASTNodeProcessor.this.monitor);
				ParameterProcessingVisitor visitor = new ParameterProcessingVisitor(
						paramNumber, match.getOffset());
				node.accept(visitor);
				ASTNodeProcessor.this.found.addAll(visitor.getElements());

				for (Iterator it = visitor.getExpressions().iterator(); it
						.hasNext();) {
					Expression exp = (Expression) it.next();
					ASTNodeProcessor.this.processExpression(exp);
				}
			}
		}
	};

	final SearchEngine searchEngine = new SearchEngine();
	searchEngine.search(pattern, new SearchParticipant[] { SearchEngine
			.getDefaultSearchParticipant() }, this.scope, requestor, null);
}
 
開發者ID:ponder-lab,項目名稱:Constants-to-Enum-Eclipse-Plugin,代碼行數:31,代碼來源:ASTNodeProcessor.java

示例13: findAllDeclarations

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner)
    throws CoreException {
  fDeclarations = new ArrayList<IMethod>();

  class MethodRequestor extends SearchRequestor {
    @Override
    public void acceptSearchMatch(SearchMatch match) throws CoreException {
      IMethod method = (IMethod) match.getElement();
      boolean isBinary = method.isBinary();
      if (fBinaryRefs != null || !(fExcludeBinaries && isBinary)) {
        fDeclarations.add(method);
      }
      if (isBinary && fBinaryRefs != null) {
        fDeclarationToMatch.put(method, match);
      }
    }
  }

  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);
  SearchParticipant[] participants = SearchUtils.getDefaultSearchParticipants();
  IJavaSearchScope scope =
      RefactoringScopeFactory.createRelatedProjectsScope(
          fMethod.getJavaProject(),
          IJavaSearchScope.SOURCES
              | IJavaSearchScope.APPLICATION_LIBRARIES
              | IJavaSearchScope.SYSTEM_LIBRARIES);
  MethodRequestor requestor = new MethodRequestor();
  SearchEngine searchEngine = owner != null ? new SearchEngine(owner) : new SearchEngine();

  searchEngine.search(pattern, participants, scope, requestor, monitor);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:37,代碼來源:RippleMethodFinder2.java

示例14: search

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private <V extends IJavaElement> List<V> search(AbstractReferencesRequestor<V> requestor,
        IProgressMonitor monitor) throws CoreException {
    SearchEngine searchEngine = new SearchEngine();
    try {
        searchEngine.search(pattern, new SearchParticipant[] { SearchEngine
                .getDefaultSearchParticipant() }, scope, requestor, monitor);
    } catch (OperationCanceledException e) {
        requestor.endReporting();
    }
    return requestor.getResults();
}
 
開發者ID:iloveeclipse,項目名稱:datahierarchy,代碼行數:12,代碼來源:SearchHelper.java

示例15: findAllDeclarations

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException {
	fDeclarations= new ArrayList<IMethod>();

	class MethodRequestor extends SearchRequestor {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			IMethod method= (IMethod) match.getElement();
			boolean isBinary= method.isBinary();
			if (fBinaryRefs != null || ! (fExcludeBinaries && isBinary)) {
				fDeclarations.add(method);
			}
			if (isBinary && fBinaryRefs != null) {
				fDeclarationToMatch.put(method, match);
			}
		}
	}

	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);
	SearchParticipant[] participants= SearchUtils.getDefaultSearchParticipants();
	IJavaSearchScope scope= RefactoringScopeFactory.createRelatedProjectsScope(fMethod.getJavaProject(), IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SYSTEM_LIBRARIES);
	MethodRequestor requestor= new MethodRequestor();
	SearchEngine searchEngine= owner != null ? new SearchEngine(owner) : new SearchEngine();

	searchEngine.search(pattern, participants, scope, requestor, monitor);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:28,代碼來源:RippleMethodFinder2.java


注:本文中的org.eclipse.jdt.core.search.SearchEngine.search方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。