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


Java IField.getCompilationUnit方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IField.getCompilationUnit方法的典型用法代码示例。如果您正苦于以下问题:Java IField.getCompilationUnit方法的具体用法?Java IField.getCompilationUnit怎么用?Java IField.getCompilationUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IField的用法示例。


在下文中一共展示了IField.getCompilationUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GetterSetterCompletionProposal

import org.eclipse.jdt.core.IField; //导入方法依赖的package包/类
public GetterSetterCompletionProposal(
    IField field, int start, int length, boolean isGetter, int relevance)
    throws JavaModelException {
  super(
      "",
      field.getCompilationUnit(),
      start,
      length,
      JavaPluginImages.get(JavaPluginImages.DESC_MISC_PUBLIC),
      getDisplayName(field, isGetter),
      relevance); // $NON-NLS-1$
  Assert.isNotNull(field);

  fField = field;
  fIsGetter = isGetter;
  setProposalInfo(new ProposalInfo(field));
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:GetterSetterCompletionProposal.java

示例2: getProposal

import org.eclipse.jdt.core.IField; //导入方法依赖的package包/类
private static CUCorrectionProposal getProposal(ProposalParameter context) {
	IJavaElement element = context.variableBinding.getJavaElement();
	if (element instanceof IField) {
		IField field = (IField) element;
		CompilationUnit cu = SharedASTProvider.getInstance().getAST(field.getTypeRoot(), null);
		try {
			if (isSelfEncapsulateAvailable(field)) {
				return new SelfEncapsulateFieldProposal(getDescription(field), field.getCompilationUnit(), cu.getRoot(), context.variableBinding, field, IProposalRelevance.GETTER_SETTER_UNUSED_PRIVATE_FIELD);
			}
		} catch (JavaModelException e) {
			JavaLanguageServerPlugin.logException("Add getter proposal failure ", e);
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:GetterSetterCorrectionSubProcessor.java

示例3: thresholdTypeToField

import org.eclipse.jdt.core.IField; //导入方法依赖的package包/类
/**
 * Returns the visibility threshold from a type to a field.
 *
 * @param referencing the referencing type
 * @param referenced the referenced field
 * @param monitor the progress monitor to use
 * @return the visibility keyword corresponding to the threshold, or <code>null</code> for default
 *     visibility
 * @throws JavaModelException if the java elements could not be accessed
 */
private ModifierKeyword thresholdTypeToField(
    final IType referencing, final IField referenced, final IProgressMonitor monitor)
    throws JavaModelException {
  ModifierKeyword keyword = ModifierKeyword.PUBLIC_KEYWORD;
  final ICompilationUnit referencedUnit = referenced.getCompilationUnit();
  if (referenced.getDeclaringType().equals(referencing))
    keyword = ModifierKeyword.PRIVATE_KEYWORD;
  else {
    final ITypeHierarchy hierarchy =
        getTypeHierarchy(referencing, new SubProgressMonitor(monitor, 1));
    final IType[] types = hierarchy.getSupertypes(referencing);
    IType superType = null;
    for (int index = 0; index < types.length; index++) {
      superType = types[index];
      if (superType.equals(referenced.getDeclaringType())) {
        keyword = ModifierKeyword.PROTECTED_KEYWORD;
        return keyword;
      }
    }
  }
  final ICompilationUnit typeUnit = referencing.getCompilationUnit();
  if (referencedUnit != null && referencedUnit.equals(typeUnit))
    keyword = ModifierKeyword.PRIVATE_KEYWORD;
  else if (referencedUnit != null
      && typeUnit != null
      && referencedUnit.getParent().equals(typeUnit.getParent())) keyword = null;
  return keyword;
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:MemberVisibilityAdjustor.java


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