当前位置: 首页>>代码示例>>Java>>正文


Java IClassFile.getSourceRange方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:JavaNavigation.java

示例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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:NavigateToDefinitionHandler.java

示例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));
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JavaNavigation.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:FindOccurrencesInFileAction.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:ClasspathManager.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ClassFileEditor.java


注:本文中的org.eclipse.jdt.core.IClassFile.getSourceRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。