本文整理匯總了Java中org.eclipse.jdt.core.search.SearchEngine.getDefaultSearchParticipant方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchEngine.getDefaultSearchParticipant方法的具體用法?Java SearchEngine.getDefaultSearchParticipant怎麽用?Java SearchEngine.getDefaultSearchParticipant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.search.SearchEngine
的用法示例。
在下文中一共展示了SearchEngine.getDefaultSearchParticipant方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TypeReference
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private TypeReference(
IJavaElement enclosingElement,
int accuracy,
int start,
int length,
boolean insideDocComment,
IResource resource,
int simpleNameStart,
String simpleName) {
super(
enclosingElement,
accuracy,
start,
length,
insideDocComment,
SearchEngine.getDefaultSearchParticipant(),
resource);
fSimpleNameStart = simpleNameStart;
fSimpleTypeName = simpleName;
}
示例2: cleanUpIndexes
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public void cleanUpIndexes() {
SimpleSet knownPaths = new SimpleSet();
IJavaSearchScope scope = BasicSearchEngine.createWorkspaceScope();
PatternSearchJob job =
new PatternSearchJob(null, SearchEngine.getDefaultSearchParticipant(), scope, null);
Index[] selectedIndexes = job.getIndexes(null);
for (int i = 0, l = selectedIndexes.length; i < l; i++) {
IndexLocation IndexLocation = selectedIndexes[i].getIndexLocation();
knownPaths.add(IndexLocation);
}
if (this.indexStates != null) {
Object[] keys = this.indexStates.keyTable;
IndexLocation[] locations = new IndexLocation[this.indexStates.elementSize];
int count = 0;
for (int i = 0, l = keys.length; i < l; i++) {
IndexLocation key = (IndexLocation) keys[i];
if (key != null && !knownPaths.includes(key)) locations[count++] = key;
}
if (count > 0) removeIndexesState(locations);
}
deleteIndexFiles(knownPaths);
}
示例3: 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();
}
}
示例4: searchMainMethods
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public void searchMainMethods(IProgressMonitor pm, IJavaSearchScope scope, Collection<IType> dst) throws CoreException
{
pm.beginTask("Searching for main methods...", 100);
try
{
SearchPattern pattern = SearchPattern.createPattern("main(String[]) void",
IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); //$NON-NLS-1$
SearchParticipant[] participants = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
IProgressMonitor searchMonitor = new SubProgressMonitor(pm, 100);
ResultAggregator collector = new ResultAggregator(dst);
new SearchEngine().search(pattern, participants, scope, collector, searchMonitor);
}
finally
{
pm.done();
}
}
示例5: PatternSearchJob
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public static List<ResourceItem> collectAllWorkspaceTypes() {
IJavaSearchScope scope = BasicSearchEngine.createWorkspaceScope();
PatternSearchJob job = new PatternSearchJob(null, SearchEngine.getDefaultSearchParticipant(), scope, null);
List<Index> selectedIndexes = new ArrayList<>(Arrays.asList(job.getIndexes(null)));
List<ResourceItem> files = selectedIndexes.stream().parallel()
.flatMap(index -> {
return addResourceForIndexEntry(getIndexEntries(index), index).stream();
}).collect(Collectors.toList());
return files;
}
示例6: addBinary
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
/**
* Trigger addition of a resource to an index Note: the actual operation is performed in
* background
*/
public void addBinary(IFile resource, IPath containerPath) {
// if (JavaCore.getPlugin() == null) return;
SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
SearchDocument document = participant.getDocument(resource.getFullPath().toString());
IndexLocation indexLocation = computeIndexLocation(containerPath);
scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
}
示例7: addSource
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
/**
* Trigger addition of a resource to an index Note: the actual operation is performed in
* background
*/
public void addSource(IFile resource, IPath containerPath, SourceElementParser parser) {
// if (JavaCore.getPlugin() == null) return;
SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
SearchDocument document = participant.getDocument(resource.getFullPath().toString());
document.setParser(parser);
IndexLocation indexLocation = computeIndexLocation(containerPath);
scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
}
示例8: getExistingCategories
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private List<String> getExistingCategories() {
if(existingCategories==null) {
final Set<String> categories = new TreeSet<String>();
if(selectedJavaProject!=null) {
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if(match.getElement() instanceof IType) {
String fqn = ((IType) match.getElement()).getFullyQualifiedName();
if(!fqn.startsWith("net.sf.jasperreports.functions.standard")) {
// avoid to propose standard functions categories
categories.add(fqn);
}
}
}
};
IJavaElement[] elements= new IJavaElement[] { selectedJavaProject };
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
int matchRule= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
SearchPattern fullAnnotationPattern= SearchPattern.createPattern(
"net.sf.jasperreports.functions.annotations.FunctionCategory", IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE, matchRule);
SearchPattern simpleNamePattern= SearchPattern.createPattern(
"FunctionCategory", IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE, matchRule);
SearchPattern annotationsPattern= SearchPattern.createOrPattern(fullAnnotationPattern, simpleNamePattern);
SearchParticipant[] searchParticipants= new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
try {
new SearchEngine().search(annotationsPattern, searchParticipants, scope, requestor,new NullProgressMonitor());
} catch (CoreException e) {
}
}
existingCategories = new ArrayList<String>(categories);
((NewFunctionsLibraryWizard)getWizard()).setAvailableCategories(existingCategories);
}
return existingCategories;
}
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:36,代碼來源:FunctionsLibraryInformationPage.java
示例9: createSearchResult
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private static SearchMatch createSearchResult(ASTNode superCall, IMethod constructor) {
int start= superCall.getStartPosition();
int end= ASTNodes.getInclusiveEnd(superCall); //TODO: why inclusive?
IResource resource= constructor.getResource();
return new SearchMatch(constructor, SearchMatch.A_ACCURATE, start, end - start,
SearchEngine.getDefaultSearchParticipant(), resource);
}
示例10: TypeReference
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private TypeReference(IJavaElement enclosingElement, int accuracy, int start, int length,
boolean insideDocComment, IResource resource, int simpleNameStart, String simpleName) {
super(enclosingElement, accuracy, start, length,
insideDocComment, SearchEngine.getDefaultSearchParticipant(), resource);
fSimpleNameStart= simpleNameStart;
fSimpleTypeName= simpleName;
}
示例11: generateIndexForJar
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public void generateIndexForJar(String pathToJar, String pathToIndexFile) throws IOException {
File f = new File(pathToJar);
if (!f.exists()) {
throw new FileNotFoundException(pathToJar + " not found"); //$NON-NLS-1$
}
IndexLocation indexLocation = new FileIndexLocation(new File(pathToIndexFile));
Index index = new Index(indexLocation, pathToJar, false /*reuse index file*/);
SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
index.separator = JAR_SEPARATOR;
ZipFile zip = new ZipFile(pathToJar);
try {
for (Enumeration e = zip.entries(); e.hasMoreElements();) {
// iterate each entry to index it
ZipEntry ze = (ZipEntry) e.nextElement();
String zipEntryName = ze.getName();
if (Util.isClassFileName(zipEntryName)) {
final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
JavaSearchDocument entryDocument = new JavaSearchDocument(ze, new Path(pathToJar), classFileBytes, participant);
entryDocument.setIndex(index);
new BinaryIndexer(entryDocument).indexDocument();
}
}
index.save();
} finally {
zip.close();
}
return;
}
示例12: 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();
}
int constructor = IJavaSearchConstants.METHOD;
if(isConstructor()) {
constructor = IJavaSearchConstants.CONSTRUCTOR;
}
if(null != getName() && !getName().isEmpty()) {
SearchPattern pattern = SearchPattern.createPattern(
getName(),
constructor,
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();
}
}
}
示例13: findElementReferences
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private List<IMember> findElementReferences(IMember iMember, IProgressMonitor pm) {
final List<IMember> references = new ArrayList<IMember>();
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (match.getAccuracy() == SearchMatch.A_ACCURATE)
references.add((IMember) match.getElement());
}
};
SearchEngine engine = new SearchEngine();
IJavaSearchScope workspaceScope = SearchEngine.createWorkspaceScope();
SearchPattern pattern = SearchPattern.createPattern(iMember, IJavaSearchConstants.ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
SearchParticipant[] participant = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
try {
engine.search(pattern, participant, workspaceScope, requestor, pm);
} catch (CoreException e) {
e.printStackTrace();
}
return references;
}
示例14: getDefaultSearchParticipants
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public static SearchParticipant[] getDefaultSearchParticipants() {
return new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
}
示例15: findClassesInContainer
import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private List<String> findClassesInContainer(
IJavaElement container, String testMethodAnnotation, String testClassAnnotation) {
List<String> result = new LinkedList<>();
IRegion region = getRegion(container);
try {
ITypeHierarchy hierarchy = JavaCore.newTypeHierarchy(region, null, null);
IType[] allClasses = hierarchy.getAllClasses();
// search for all types with references to RunWith and Test and all subclasses
HashSet<IType> candidates = new HashSet<>(allClasses.length);
SearchRequestor requestor = new AnnotationSearchRequestor(hierarchy, candidates);
IJavaSearchScope scope =
SearchEngine.createJavaSearchScope(allClasses, IJavaSearchScope.SOURCES);
int matchRule = SearchPattern.R_CASE_SENSITIVE;
SearchPattern testPattern =
SearchPattern.createPattern(
testMethodAnnotation,
IJavaSearchConstants.ANNOTATION_TYPE,
IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE,
matchRule);
SearchPattern runWithPattern =
isNullOrEmpty(testClassAnnotation)
? testPattern
: SearchPattern.createPattern(
testClassAnnotation,
IJavaSearchConstants.ANNOTATION_TYPE,
IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE,
matchRule);
SearchPattern annotationsPattern = SearchPattern.createOrPattern(runWithPattern, testPattern);
SearchParticipant[] searchParticipants =
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
new SearchEngine().search(annotationsPattern, searchParticipants, scope, requestor, null);
// find all classes in the region
for (IType candidate : candidates) {
if (isAccessibleClass(candidate)
&& !Flags.isAbstract(candidate.getFlags())
&& region.contains(candidate)) {
result.add(candidate.getFullyQualifiedName());
}
}
} catch (CoreException e) {
LOG.info("Can't build project hierarchy.", e);
}
return result;
}