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


Java IBinding.TYPE属性代码示例

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


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

示例1: getImportName

public static String getImportName(IBinding binding) {
	ITypeBinding declaring= null;
	switch (binding.getKind()) {
	case IBinding.TYPE:
		return getRawQualifiedName((ITypeBinding) binding);
	case IBinding.PACKAGE:
		return binding.getName() + ".*"; //$NON-NLS-1$
	case IBinding.METHOD:
		declaring= ((IMethodBinding) binding).getDeclaringClass();
		break;
	case IBinding.VARIABLE:
		declaring= ((IVariableBinding) binding).getDeclaringClass();
		if (declaring == null) {
			return binding.getName(); // array.length
		}

		break;
	default:
		return binding.getName();
	}
	return JavaModelUtil.concatenateName(getRawQualifiedName(declaring), binding.getName());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:Bindings.java

示例2: rewriteAST

@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel) throws CoreException {
	ASTRewrite rewrite= cuRewrite.getASTRewrite();
	IBinding binding= fUnusedName.resolveBinding();
	CompilationUnit root= (CompilationUnit) fUnusedName.getRoot();
	String displayString= FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
	TextEditGroup group= createTextEditGroup(displayString, cuRewrite);

	if (binding.getKind() == IBinding.TYPE) {
		ITypeBinding decl= ((ITypeBinding) binding).getTypeDeclaration();
		ASTNode declaration= root.findDeclaringNode(decl);
		if (declaration.getParent() instanceof TypeDeclarationStatement) {
			declaration= declaration.getParent();
		}
		rewrite.remove(declaration, group);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:UnusedCodeFix.java

示例3: getDisplayString

private String getDisplayString(IBinding binding) {
	switch (binding.getKind()) {
	case IBinding.TYPE:
		return FixMessages.UnusedCodeFix_RemoveUnusedType_description;
	case IBinding.METHOD:
		if (((IMethodBinding) binding).isConstructor()) {
			return FixMessages.UnusedCodeFix_RemoveUnusedConstructor_description;
		} else {
			return FixMessages.UnusedCodeFix_RemoveUnusedPrivateMethod_description;
		}
	case IBinding.VARIABLE:
		if (((IVariableBinding) binding).isField()) {
			return FixMessages.UnusedCodeFix_RemoveUnusedField_description;
		} else {
			return FixMessages.UnusedCodeFix_RemoveUnusedVariabl_description;
		}
	default:
		return ""; //$NON-NLS-1$
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:UnusedCodeFix.java

示例4: getImportName

public static String getImportName(IBinding binding) {
  ITypeBinding declaring = null;
  switch (binding.getKind()) {
    case IBinding.TYPE:
      return getRawQualifiedName((ITypeBinding) binding);
    case IBinding.PACKAGE:
      return binding.getName() + ".*"; // $NON-NLS-1$
    case IBinding.METHOD:
      declaring = ((IMethodBinding) binding).getDeclaringClass();
      break;
    case IBinding.VARIABLE:
      declaring = ((IVariableBinding) binding).getDeclaringClass();
      if (declaring == null) {
        return binding.getName(); // array.length
      }

      break;
    default:
      return binding.getName();
  }
  return JavaModelUtil.concatenateName(getRawQualifiedName(declaring), binding.getName());
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:Bindings.java

示例5: getSignature

private static String getSignature(IBinding binding) {
  if (binding != null) {
    switch (binding.getKind()) {
      case IBinding.METHOD:
        StringBuffer buf = new StringBuffer();
        buf.append('M');
        buf.append(binding.getName()).append('(');
        ITypeBinding[] parameters = ((IMethodBinding) binding).getParameterTypes();
        for (int i = 0; i < parameters.length; i++) {
          if (i > 0) {
            buf.append(',');
          }
          ITypeBinding paramType = parameters[i].getErasure();
          buf.append(paramType.getQualifiedName());
        }
        buf.append(')');
        return buf.toString();
      case IBinding.VARIABLE:
        return 'V' + binding.getName();
      case IBinding.TYPE:
        return 'T' + binding.getName();
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ScopeAnalyzer.java

示例6: rewriteAST

@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel)
    throws CoreException {
  ASTRewrite rewrite = cuRewrite.getASTRewrite();
  IBinding binding = fUnusedName.resolveBinding();
  CompilationUnit root = (CompilationUnit) fUnusedName.getRoot();
  String displayString = FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
  TextEditGroup group = createTextEditGroup(displayString, cuRewrite);

  if (binding.getKind() == IBinding.TYPE) {
    ITypeBinding decl = ((ITypeBinding) binding).getTypeDeclaration();
    ASTNode declaration = root.findDeclaringNode(decl);
    if (declaration.getParent() instanceof TypeDeclarationStatement) {
      declaration = declaration.getParent();
    }
    rewrite.remove(declaration, group);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:UnusedCodeFix.java

示例7: getDisplayString

private String getDisplayString(IBinding binding) {
  switch (binding.getKind()) {
    case IBinding.TYPE:
      return FixMessages.UnusedCodeFix_RemoveUnusedType_description;
    case IBinding.METHOD:
      if (((IMethodBinding) binding).isConstructor()) {
        return FixMessages.UnusedCodeFix_RemoveUnusedConstructor_description;
      } else {
        return FixMessages.UnusedCodeFix_RemoveUnusedPrivateMethod_description;
      }
    case IBinding.VARIABLE:
      if (((IVariableBinding) binding).isField()) {
        return FixMessages.UnusedCodeFix_RemoveUnusedField_description;
      } else {
        return FixMessages.UnusedCodeFix_RemoveUnusedVariabl_description;
      }
    default:
      return ""; // $NON-NLS-1$
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:UnusedCodeFix.java

示例8: getCleanUpOptions

private static Map<String, String> getCleanUpOptions(IBinding binding, boolean removeAll) {
  Map<String, String> result = new Hashtable<String, String>();

  result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpOptions.TRUE);
  switch (binding.getKind()) {
    case IBinding.TYPE:
      result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpOptions.TRUE);
      break;
    case IBinding.METHOD:
      if (((IMethodBinding) binding).isConstructor()) {
        result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpOptions.TRUE);
      } else {
        result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpOptions.TRUE);
      }
      break;
    case IBinding.VARIABLE:
      if (removeAll) return null;

      result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpOptions.TRUE);
      result.put(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpOptions.TRUE);
      break;
  }

  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:UnusedCodeFix.java

示例9: getNeededVisibility

private static int getNeededVisibility(
    ASTNode currNode, ITypeBinding targetType, IBinding binding) {
  ITypeBinding currNodeBinding = Bindings.getBindingOfParentType(currNode);
  if (currNodeBinding == null) { // import
    return Modifier.PUBLIC;
  }

  if (Bindings.isSuperType(targetType, currNodeBinding)) {
    if (binding != null
        && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) {
      return Modifier.PUBLIC;
    }
    return Modifier.PROTECTED;
  }

  if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
    return 0;
  }
  return Modifier.PUBLIC;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ModifierCorrectionSubProcessor.java

示例10: isDeclarationBinding

/**
 * Tests if the given node is a declaration, not a instance of a generic type, method or field.
 * Declarations can be found in AST with CompilationUnit.findDeclaringNode
 * @param binding binding to test
 * @return returns <code>true</code> if the binding is a declaration binding
 */
public static boolean isDeclarationBinding(IBinding binding) {
	switch (binding.getKind()) {
	case IBinding.TYPE:
		return ((ITypeBinding) binding).getTypeDeclaration() == binding;
	case IBinding.VARIABLE:
		return ((IVariableBinding) binding).getVariableDeclaration() == binding;
	case IBinding.METHOD:
		return ((IMethodBinding) binding).getMethodDeclaration() == binding;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:Bindings.java

示例11: getDeclaration

public static IBinding getDeclaration(IBinding binding) {
	switch (binding.getKind()) {
	case IBinding.TYPE:
		return ((ITypeBinding) binding).getTypeDeclaration();
	case IBinding.VARIABLE:
		return ((IVariableBinding) binding).getVariableDeclaration();
	case IBinding.METHOD:
		return ((IMethodBinding) binding).getMethodDeclaration();
	}
	return binding;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:Bindings.java

示例12: findNullnessDefault

/**
 * Answer the annotation binding representing a nullness default
 * effective at the point denoted by 'contextBinding'.
 * @param contextBinding method binding or type binding denoting the location of interest
 * @param javaProject the containing java project, consulted for the actual name of
 *  the annotation used for nullness defaults (default: <code>@NonNullByDefault</code>).
 * @return binding for the effective nullness default annotation
 * 	or null if no nullness default is effective at the context location.
 */
public static IAnnotationBinding findNullnessDefault(IBinding contextBinding, IJavaProject javaProject) {
	if (JavaCore.ENABLED.equals(javaProject.getOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, true))) {
		String annotationName= javaProject.getOption(JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME, true);
		while (contextBinding != null) {
			for (IAnnotationBinding annotation : contextBinding.getAnnotations()) {
				ITypeBinding annotationType= annotation.getAnnotationType();
				if (annotationType != null && annotationType.getQualifiedName().equals(annotationName)) {
					return annotation;
				}
			}
			// travel out:
			switch (contextBinding.getKind()) {
			case IBinding.METHOD:
				IMethodBinding methodBinding= (IMethodBinding) contextBinding;
				contextBinding= methodBinding.getDeclaringMember();
				if (contextBinding == null) {
					contextBinding= methodBinding.getDeclaringClass();
				}
				break;
			case IBinding.VARIABLE:
				IVariableBinding variableBinding= (IVariableBinding) contextBinding;
				contextBinding= variableBinding.getDeclaringMethod();
				if (contextBinding == null) {
					contextBinding= variableBinding.getDeclaringClass();
				}
				break;
			case IBinding.TYPE:
				ITypeBinding currentClass= (ITypeBinding) contextBinding;
				contextBinding= currentClass.getDeclaringMember();
				if (contextBinding == null) {
					contextBinding= currentClass.getDeclaringMethod();
					if (contextBinding == null) {
						contextBinding= currentClass.getDeclaringClass();
						if (contextBinding == null) {
							contextBinding= currentClass.getPackage();
						}
					}
				}
				break;
			default:
				contextBinding= null;
				break;
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:56,代码来源:Bindings.java

示例13: add

/**
 * Tries to find the given type name and add it to the import structure.
 * @param ref the name node
 */
public void add(SimpleName ref) {
	String typeName= ref.getIdentifier();

	if (fImportsAdded.contains(typeName)) {
		return;
	}

	IBinding binding= ref.resolveBinding();
	if (binding != null) {
		if (binding.getKind() != IBinding.TYPE) {
			return;
		}
		ITypeBinding typeBinding= (ITypeBinding) binding;
		if (typeBinding.isArray()) {
			typeBinding= typeBinding.getElementType();
		}
		typeBinding= typeBinding.getTypeDeclaration();
		if (!typeBinding.isRecovered()) {
			if (needsImport(typeBinding, ref)) {
				fImpStructure.addImport(typeBinding);
				fImportsAdded.add(typeName);
			}
			return;
		}
	} else {
		if (fDoIgnoreLowerCaseNames && typeName.length() > 0) {
			char ch= typeName.charAt(0);
			if (Strings.isLowerCase(ch) && Character.isLetter(ch)) {
				return;
			}
		}
	}

	fImportsAdded.add(typeName);
	fUnresolvedTypes.put(typeName, new UnresolvedTypeData(ref));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:40,代码来源:OrganizeImportsOperation.java

示例14: possibleTypeRefFound

private void possibleTypeRefFound(Name node) {
	while (node.isQualifiedName()) {
		node= ((QualifiedName) node).getQualifier();
	}
	IBinding binding= node.resolveBinding();
	if (binding == null || binding.getKind() == IBinding.TYPE) {
		// if the binding is null, we cannot determine if
		// we have a type binding or not, so we will assume
		// we do.
		addReference((SimpleName) node);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:ImportReferencesCollector.java

示例15: getCleanUpOptions

private static Map<String, String> getCleanUpOptions(IBinding binding, boolean removeAll) {
	Map<String, String> result= new Hashtable<>();

	result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpOptions.TRUE);
	switch (binding.getKind()) {
	case IBinding.TYPE:
		result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpOptions.TRUE);
		break;
	case IBinding.METHOD:
		if (((IMethodBinding) binding).isConstructor()) {
			result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpOptions.TRUE);
		} else {
			result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpOptions.TRUE);
		}
		break;
	case IBinding.VARIABLE:
		if (removeAll) {
			return null;
		}

		result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpOptions.TRUE);
		result.put(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpOptions.TRUE);
		break;
	}

	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:UnusedCodeFix.java


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