List of usage examples for org.eclipse.jdt.core.search IJavaSearchConstants IGNORE_RETURN_TYPE
int IGNORE_RETURN_TYPE
To view the source code for org.eclipse.jdt.core.search IJavaSearchConstants IGNORE_RETURN_TYPE.
Click Source Link
From source file:org.codehaus.groovy.eclipse.core.search.SyntheticAccessorSearchRequestor.java
License:Apache License
private SearchPattern createPattern(IJavaElement element) throws JavaModelException { List<IJavaElement> toSearch = new ArrayList<IJavaElement>(4); toSearch.add(findSyntheticMember(element, "is")); toSearch.add(findSyntheticMember(element, "get")); toSearch.add(findSyntheticMember(element, "set")); toSearch.add(findSyntheticProperty(element)); SearchPattern pattern = null;/*from w w w . j a v a2s . c o m*/ for (IJavaElement searchElt : toSearch) { if (searchElt != null) { SearchPattern newPattern = SearchPattern.createPattern(searchElt, IJavaSearchConstants.ALL_OCCURRENCES | IJavaSearchConstants.IGNORE_RETURN_TYPE); if (pattern == null) { pattern = newPattern; } else { pattern = SearchPattern.createOrPattern(pattern, newPattern); } } } return pattern; }
From source file:org.eclipse.ajdt.internal.ui.refactoring.RippleMethodFinder2.java
License:Open Source License
private void findAllDeclarations(IProgressMonitor monitor, WorkingCopyOwner owner) throws CoreException { fDeclarations = new ArrayList(); class MethodRequestor extends SearchRequestor { public void acceptSearchMatch(SearchMatch match) throws CoreException { IMethod method = (IMethod) match.getElement(); boolean isBinary = method.isBinary(); if (fBinaryRefs != null || !(fExcludeBinaries && isBinary)) { fDeclarations.add(method); }//from w w w .j a v a 2s .com 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); }
From source file:org.eclipse.xtext.xbase.ui.navigation.JvmImplementationOpener.java
License:Open Source License
/** * Main parts of the logic is taken from {@link org.eclipse.jdt.internal.ui.javaeditor.JavaElementImplementationHyperlink} * * @param element - Element to show implementations for * @param textviewer - Viewer to show hierarchy view on * @param region - Region where to show hierarchy view *//*from www . j a va2 s . co m*/ public void openImplementations(final IJavaElement element, ITextViewer textviewer, IRegion region) { if (element instanceof IMethod) { ITypeRoot typeRoot = ((IMethod) element).getTypeRoot(); CompilationUnit ast = SharedASTProvider.getAST(typeRoot, SharedASTProvider.WAIT_YES, null); if (ast == null) { openQuickHierarchy(textviewer, element, region); return; } try { ISourceRange nameRange = ((IMethod) element).getNameRange(); ASTNode node = NodeFinder.perform(ast, nameRange); ITypeBinding parentTypeBinding = null; if (node instanceof SimpleName) { ASTNode parent = node.getParent(); if (parent instanceof MethodInvocation) { Expression expression = ((MethodInvocation) parent).getExpression(); if (expression == null) { parentTypeBinding = Bindings.getBindingOfParentType(node); } else { parentTypeBinding = expression.resolveTypeBinding(); } } else if (parent instanceof SuperMethodInvocation) { // Directly go to the super method definition openEditor(element); return; } else if (parent instanceof MethodDeclaration) { parentTypeBinding = Bindings.getBindingOfParentType(node); } } final IType type = parentTypeBinding != null ? (IType) parentTypeBinding.getJavaElement() : null; if (type == null) { openQuickHierarchy(textviewer, element, region); return; } final String earlyExitIndicator = "EarlyExitIndicator"; final ArrayList<IJavaElement> links = Lists.newArrayList(); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor == null) { monitor = new NullProgressMonitor(); } try { String methodLabel = JavaElementLabels.getElementLabel(element, JavaElementLabels.DEFAULT_QUALIFIED); monitor.beginTask( Messages.format("Searching for implementors of ''{0}''", methodLabel), 100); SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { if (match.getAccuracy() == SearchMatch.A_ACCURATE) { IJavaElement element = (IJavaElement) match.getElement(); if (element instanceof IMethod && !JdtFlags.isAbstract((IMethod) element)) { links.add(element); if (links.size() > 1) { throw new OperationCanceledException(earlyExitIndicator); } } } } }; int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE; SearchPattern pattern = SearchPattern.createPattern(element, limitTo); Assert.isNotNull(pattern); SearchParticipant[] participants = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }; SearchEngine engine = new SearchEngine(); engine.search(pattern, participants, SearchEngine.createHierarchyScope(type), requestor, new SubProgressMonitor(monitor, 100)); if (monitor.isCanceled()) { throw new InterruptedException(); } } catch (OperationCanceledException e) { throw new InterruptedException(e.getMessage()); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }; try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format( "An error occurred while searching for implementations of method ''{0}''. See error log for details.", element.getElementName()), e.getCause()); JavaPlugin.log(status); ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Open Implementation", "Problems finding implementations.", status); } catch (InterruptedException e) { if (e.getMessage() != earlyExitIndicator) { return; } } if (links.size() == 1) { openEditor(links.get(0)); } else { openQuickHierarchy(textviewer, element, region); } } catch (JavaModelException e) { log.error("An error occurred while searching for implementations", e.getCause()); } catch (PartInitException e) { log.error("An error occurred while searching for implementations", e.getCause()); } } }
From source file:org.jboss.tools.batch.ui.participants.BatchArtifactSearchParticipant.java
License:Open Source License
public boolean isSearchForReferences(int limitTo) { int maskedLimitTo = limitTo & ~(IJavaSearchConstants.IGNORE_DECLARING_TYPE + IJavaSearchConstants.IGNORE_RETURN_TYPE); if (maskedLimitTo == IJavaSearchConstants.REFERENCES || maskedLimitTo == IJavaSearchConstants.ALL_OCCURRENCES) { return true; }/*from ww w . ja va2 s.c o m*/ return false; }
From source file:org.jboss.tools.jst.web.kb.refactoring.ELReferencesQueryParticipant.java
License:Open Source License
public boolean isSearchForReferences(int limitTo) { int maskedLimitTo = limitTo & ~(IJavaSearchConstants.IGNORE_DECLARING_TYPE + IJavaSearchConstants.IGNORE_RETURN_TYPE); return maskedLimitTo == IJavaSearchConstants.REFERENCES || maskedLimitTo == IJavaSearchConstants.ALL_OCCURRENCES; }
From source file:org.jboss.tools.seam.ui.search.SeamSearchEngine.java
License:Open Source License
/** * Checks if the given limitTo flag is limited to declarations * //from w ww . j a v a2 s . c om * @param limitTo * @return */ public static boolean isSearchForDeclarations(int limitTo) { int maskedLimitTo = limitTo & ~(IJavaSearchConstants.IGNORE_DECLARING_TYPE + IJavaSearchConstants.IGNORE_RETURN_TYPE); if (maskedLimitTo == IJavaSearchConstants.DECLARATIONS || maskedLimitTo == IJavaSearchConstants.ALL_OCCURRENCES) { return true; } return false; }
From source file:org.jboss.tools.seam.ui.search.SeamSearchEngine.java
License:Open Source License
/** * Checks if the given limitTo flag is limited to references * // ww w . j a v a2 s . co m * @param limitTo * @return */ public static boolean isSearchForReferences(int limitTo) { int maskedLimitTo = limitTo & ~(IJavaSearchConstants.IGNORE_DECLARING_TYPE + IJavaSearchConstants.IGNORE_RETURN_TYPE); if (maskedLimitTo == IJavaSearchConstants.REFERENCES || maskedLimitTo == IJavaSearchConstants.ALL_OCCURRENCES) { return true; } return false; }