Java Code Examples for org.eclipse.jdt.core.IMember#getClassFile()
The following examples show how to use
org.eclipse.jdt.core.IMember#getClassFile() .
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: FindOccurrencesInFileAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IMember getMember(IStructuredSelection selection) { if (selection.size() != 1) return null; Object o= selection.getFirstElement(); if (o instanceof IMember) { IMember member= (IMember)o; try { if (member.getNameRange() == null) return null; } catch (JavaModelException ex) { return null; } IClassFile file= member.getClassFile(); if (file != null) { try { if (file.getSourceRange() != null) return member; } catch (JavaModelException e) { return null; } } return member; } return null; }
Example 2
Source File: MatchLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void reportBinaryMemberDeclaration(IResource resource, IMember binaryMember, Binding binaryMemberBinding, IBinaryType info, int accuracy) throws CoreException { ClassFile classFile = (ClassFile) binaryMember.getClassFile(); ISourceRange range = classFile.isOpen() ? binaryMember.getNameRange() : SourceMapper.UNKNOWN_RANGE; if (range.getOffset() == -1) { BinaryType type = (BinaryType) classFile.getType(); String sourceFileName = type.sourceFileName(info); if (sourceFileName != null) { SourceMapper mapper = classFile.getSourceMapper(); if (mapper != null) { char[] contents = mapper.findSource(type, sourceFileName); if (contents != null) range = mapper.mapSource(type, contents, info, binaryMember); } } } if (resource == null) resource = this.currentPossibleMatch.resource; SearchMatch match = newDeclarationMatch(binaryMember, binaryMemberBinding, accuracy, range.getOffset(), range.getLength(), getParticipant(), resource); report(match); }
Example 3
Source File: CallerMethodWrapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IJavaSearchScope getAccurateSearchScope(IJavaSearchScope defaultSearchScope, IMember member) throws JavaModelException { if (! JdtFlags.isPrivate(member)) return defaultSearchScope; if (member.getCompilationUnit() != null) { return SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getCompilationUnit() }); } else if (member.getClassFile() != null) { // member could be called from an inner class-> search // package fragment (see also bug 109053): return SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getAncestor(IJavaElement.PACKAGE_FRAGMENT) }); } else { return defaultSearchScope; } }