本文整理汇总了Java中org.eclipse.jdt.core.IClassFile.getSourceRange方法的典型用法代码示例。如果您正苦于以下问题:Java IClassFile.getSourceRange方法的具体用法?Java IClassFile.getSourceRange怎么用?Java IClassFile.getSourceRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IClassFile
的用法示例。
在下文中一共展示了IClassFile.getSourceRange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classFileNavigation
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
private OpenDeclarationDescriptor classFileNavigation(IClassFile classFile, IJavaElement element)
throws JavaModelException {
OpenDeclarationDescriptor dto =
DtoFactory.getInstance().createDto(OpenDeclarationDescriptor.class);
dto.setPath(classFile.getType().getFullyQualifiedName());
dto.setLibId(classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode());
dto.setBinary(true);
if (classFile.getSourceRange() != null) {
if (element instanceof ISourceReference) {
ISourceRange nameRange = ((ISourceReference) element).getNameRange();
dto.setOffset(nameRange.getOffset());
dto.setLength(nameRange.getLength());
}
}
return dto;
}
示例2: computeDefinitionNavigation
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
private Location computeDefinitionNavigation(ITypeRoot unit, int line, int column, IProgressMonitor monitor) {
try {
IJavaElement element = JDTUtils.findElementAtSelection(unit, line, column, this.preferenceManager, monitor);
if (element == null) {
return null;
}
ICompilationUnit compilationUnit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
IClassFile cf = (IClassFile) element.getAncestor(IJavaElement.CLASS_FILE);
if (compilationUnit != null || (cf != null && cf.getSourceRange() != null) ) {
return JDTUtils.toLocation(element);
}
if (element instanceof IMember && ((IMember) element).getClassFile() != null) {
return JDTUtils.toLocation(((IMember) element).getClassFile());
}
} catch (JavaModelException e) {
JavaLanguageServerPlugin.logException("Problem computing definition for" + unit.getElementName(), e);
}
return null;
}
示例3: getContent
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
public ClassContent getContent(IJavaProject project, String path) throws JavaModelException {
// java class or file
IType type = project.findType(path);
if (type != null) {
if (type.isBinary()) {
IClassFile classFile = type.getClassFile();
if (classFile.getSourceRange() != null) {
return createContent(classFile.getSource(), false);
} else {
return createContent(sourcesGenerator.generateSource(classFile.getType()), true);
}
} else {
return createContent(type.getCompilationUnit().getSource(), false);
}
}
throw new JavaModelException(new JavaModelStatus(0, "Can't find type: " + path));
}
示例4: getMember
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
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;
}
示例5: downloadSources
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
public boolean downloadSources(String projectPath, String fqn) {
IJavaProject javaProject =
JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(projectPath);
try {
IType type = javaProject.findType(fqn);
if (type != null && type.isBinary()) {
IClassFile classFile = type.getClassFile();
if (classFile.getSourceRange() == null) {
IJavaElement element = classFile;
while (element.getParent() != null) {
element = element.getParent();
if (element instanceof IPackageFragmentRoot) {
IPackageFragmentRoot root = (IPackageFragmentRoot) element;
if (root.getSourceAttachmentPath() == null) {
return downloadSources(root);
}
}
}
}
}
} catch (JavaModelException e) {
LOG.error(e.getMessage(), e);
}
return false;
}
示例6: probeInputForSource
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
private JavaModelException probeInputForSource(IEditorInput input) {
if (input == null)
return null;
IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) input;
IClassFile file= classFileEditorInput.getClassFile();
try {
file.getSourceRange();
} catch (JavaModelException e) {
return e;
}
return null;
}