Java Code Examples for org.eclipse.jdt.core.search.IJavaSearchConstants#DECLARATIONS
The following examples show how to use
org.eclipse.jdt.core.search.IJavaSearchConstants#DECLARATIONS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RippleMethodFinder.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
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); }
Example 2
Source File: RippleMethodFinder2.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
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 (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); }
Example 3
Source File: RippleMethodFinder2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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); }
Example 4
Source File: JavaSearchQuery.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
ImageDescriptor getImageDescriptor() { int limitTo= getMaskedLimitTo(); if (limitTo == IJavaSearchConstants.IMPLEMENTORS || limitTo == IJavaSearchConstants.DECLARATIONS) return JavaPluginImages.DESC_OBJS_SEARCH_DECL; else return JavaPluginImages.DESC_OBJS_SEARCH_REF; }
Example 5
Source File: VariablePattern.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public VariablePattern(int patternKind, char[] name, int limitTo, int matchRule) { super(patternKind, matchRule); this.fineGrain = limitTo & FINE_GRAIN_MASK; if (this.fineGrain == 0) { switch (limitTo & 0xF) { case IJavaSearchConstants.DECLARATIONS : this.findDeclarations = true; break; case IJavaSearchConstants.REFERENCES : this.readAccess = true; this.writeAccess = true; break; case IJavaSearchConstants.READ_ACCESSES : this.readAccess = true; break; case IJavaSearchConstants.WRITE_ACCESSES : this.writeAccess = true; break; case IJavaSearchConstants.ALL_OCCURRENCES : this.findDeclarations = true; this.readAccess = true; this.writeAccess = true; break; } this.findReferences = this.readAccess || this.writeAccess; } this.name = (this.isCaseSensitive || this.isCamelCase) ? name : CharOperation.toLowerCase(name); }
Example 6
Source File: ImplementationCollector.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private List<T> findMethodImplementations(IProgressMonitor monitor) throws CoreException { IMethod method = (IMethod) javaElement; try { if (cannotBeOverriddenMethod(method)) { return null; } } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Find method implementations failure ", e); return null; } CompilationUnit ast = CoreASTProvider.getInstance().getAST(typeRoot, CoreASTProvider.WAIT_YES, monitor); if (ast == null) { return null; } ASTNode node = NodeFinder.perform(ast, region.getOffset(), region.getLength()); 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 return Collections.singletonList(mapper.convert(method, 0, 0)); } else if (parent instanceof MethodDeclaration) { parentTypeBinding = Bindings.getBindingOfParentType(node); } } final IType receiverType = getType(parentTypeBinding); if (receiverType == null) { return null; } final List<T> results = new ArrayList<>(); try { String methodLabel = JavaElementLabelsCore.getElementLabel(method, JavaElementLabelsCore.DEFAULT_QUALIFIED); monitor.beginTask(Messages.format(JavaElementImplementationHyperlink_search_method_implementors, methodLabel), 10); SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { if (match.getAccuracy() == SearchMatch.A_ACCURATE) { Object element = match.getElement(); if (element instanceof IMethod) { IMethod methodFound = (IMethod) element; if (!JdtFlags.isAbstract(methodFound)) { T result = mapper.convert(methodFound, match.getOffset(), match.getLength()); if (result != null) { results.add(result); } } } } } }; IJavaSearchScope hierarchyScope; if (receiverType.isInterface()) { hierarchyScope = SearchEngine.createHierarchyScope(method.getDeclaringType()); } else { if (isFullHierarchyNeeded(new SubProgressMonitor(monitor, 3), method, receiverType)) { hierarchyScope = SearchEngine.createHierarchyScope(receiverType); } else { boolean isMethodAbstract = JdtFlags.isAbstract(method); hierarchyScope = SearchEngine.createStrictHierarchyScope(null, receiverType, true, isMethodAbstract, null); } } int limitTo = IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE; SearchPattern pattern = SearchPattern.createPattern(method, limitTo); Assert.isNotNull(pattern); SearchParticipant[] participants = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }; SearchEngine engine = new SearchEngine(); engine.search(pattern, participants, hierarchyScope, requestor, new SubProgressMonitor(monitor, 7)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } } finally { monitor.done(); } return results; }
Example 7
Source File: FindDeclarationsAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override int getLimitTo() { return IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE; }
Example 8
Source File: MethodPattern.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public MethodPattern( char[] selector, char[] declaringQualification, char[] declaringSimpleName, char[] returnQualification, char[] returnSimpleName, char[][] parameterQualifications, char[][] parameterSimpleNames, IType declaringType, int limitTo, int matchRule) { this(matchRule); this.fineGrain = limitTo & FINE_GRAIN_MASK; if (this.fineGrain == 0) { switch (limitTo & 0xF) { case IJavaSearchConstants.DECLARATIONS : this.findReferences = false; break; case IJavaSearchConstants.REFERENCES : this.findDeclarations = false; break; case IJavaSearchConstants.ALL_OCCURRENCES : break; } } else { this.findDeclarations = false; } this.selector = (this.isCaseSensitive || this.isCamelCase) ? selector : CharOperation.toLowerCase(selector); this.declaringQualification = this.isCaseSensitive ? declaringQualification : CharOperation.toLowerCase(declaringQualification); this.declaringSimpleName = this.isCaseSensitive ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName); this.returnQualification = this.isCaseSensitive ? returnQualification : CharOperation.toLowerCase(returnQualification); this.returnSimpleName = this.isCaseSensitive ? returnSimpleName : CharOperation.toLowerCase(returnSimpleName); if (parameterSimpleNames != null) { this.parameterCount = parameterSimpleNames.length; this.parameterQualifications = new char[this.parameterCount][]; this.parameterSimpleNames = new char[this.parameterCount][]; for (int i = 0; i < this.parameterCount; i++) { this.parameterQualifications[i] = this.isCaseSensitive ? parameterQualifications[i] : CharOperation.toLowerCase(parameterQualifications[i]); this.parameterSimpleNames[i] = this.isCaseSensitive ? parameterSimpleNames[i] : CharOperation.toLowerCase(parameterSimpleNames[i]); } } else { this.parameterCount = -1; } this.declaringType = declaringType; if (this.declaringType != null) { this.declaringPackageName = this.declaringType.getPackageFragment().getElementName().toCharArray(); } this.mustResolve = mustResolve(); }
Example 9
Source File: ConstructorPattern.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public ConstructorPattern( char[] declaringSimpleName, char[] declaringQualification, char[][] parameterQualifications, char[][] parameterSimpleNames, int limitTo, int matchRule) { this(matchRule); this.fineGrain = limitTo & FINE_GRAIN_MASK; if (this.fineGrain == 0) { switch (limitTo) { case IJavaSearchConstants.DECLARATIONS : this.findReferences = false; break; case IJavaSearchConstants.REFERENCES : this.findDeclarations = false; break; case IJavaSearchConstants.ALL_OCCURRENCES : break; } } else { this.findDeclarations = false; } this.declaringQualification = this.isCaseSensitive ? declaringQualification : CharOperation.toLowerCase(declaringQualification); this.declaringSimpleName = (this.isCaseSensitive || this.isCamelCase) ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName); if (parameterSimpleNames != null) { this.parameterCount = parameterSimpleNames.length; boolean synthetic = this.parameterCount>0 && declaringQualification != null && CharOperation.equals(CharOperation.concat(parameterQualifications[0], parameterSimpleNames[0], '.'), declaringQualification); int offset = 0; if (synthetic) { // skip first synthetic parameter this.parameterCount--; offset++; } this.parameterQualifications = new char[this.parameterCount][]; this.parameterSimpleNames = new char[this.parameterCount][]; for (int i = 0; i < this.parameterCount; i++) { this.parameterQualifications[i] = this.isCaseSensitive ? parameterQualifications[i+offset] : CharOperation.toLowerCase(parameterQualifications[i+offset]); this.parameterSimpleNames[i] = this.isCaseSensitive ? parameterSimpleNames[i+offset] : CharOperation.toLowerCase(parameterSimpleNames[i+offset]); } } else { this.parameterCount = -1; } this.mustResolve = mustResolve(); }