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


Java BindingKey类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.BindingKey的典型用法代码示例。如果您正苦于以下问题:Java BindingKey类的具体用法?Java BindingKey怎么用?Java BindingKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createArrayType

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
public ArrayType createArrayType(TType elementType, int dimensions) {
  Assert.isTrue(!elementType.isArrayType());
  Assert.isTrue(!elementType.isAnonymous());
  Assert.isTrue(dimensions > 0);

  int index = dimensions - 1;
  Map<TType, ArrayType> arrayTypes = getArrayTypesMap(index);
  ArrayType result = arrayTypes.get(elementType);
  if (result != null) return result;
  result =
      new ArrayType(
          this, BindingKey.createArrayTypeBindingKey(elementType.getBindingKey(), dimensions));
  arrayTypes.put(elementType, result);
  result.initialize(elementType, dimensions);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:TypeEnvironment.java

示例2: getFullyQualifiedParameterizedName

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
protected String getFullyQualifiedParameterizedName(String fullyQualifiedName, String uniqueKey) throws JavaModelException {
	String[] typeArguments = new BindingKey(uniqueKey).getTypeArguments();
	int length = typeArguments.length;
	if (length == 0) return fullyQualifiedName;
	StringBuffer buffer = new StringBuffer();
	buffer.append(fullyQualifiedName);
	buffer.append('<');
	for (int i = 0; i < length; i++) {
		String typeArgument = typeArguments[i];
		buffer.append(Signature.toString(typeArgument));
		if (i < length-1)
			buffer.append(',');
	}
	buffer.append('>');
	return buffer.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:NamedMember.java

示例3: appendFieldLabel

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
/**
 * Appends the style label for a field. Considers the F_* flags.
 *
 * @param field the element to render
 * @param flags the rendering flags. Flags with names starting with 'F_' are considered.
 */
public void appendFieldLabel(IField field, long flags) {
	try {

		if (getFlag(flags, JavaElementLabels.F_PRE_TYPE_SIGNATURE) && field.exists() && !Flags.isEnum(field.getFlags())) {
			if (getFlag(flags, JavaElementLabels.USE_RESOLVED) && field.isResolved()) {
				appendTypeSignatureLabel(field, new BindingKey(field.getKey()).toSignature(), flags);
			} else {
				appendTypeSignatureLabel(field, field.getTypeSignature(), flags);
			}
			fBuilder.append(' ');
		}

		// qualification
		if (getFlag(flags, JavaElementLabels.F_FULLY_QUALIFIED)) {
			appendTypeLabel(field.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
			fBuilder.append('.');
		}
		fBuilder.append(getElementName(field));

		if (getFlag(flags, JavaElementLabels.F_APP_TYPE_SIGNATURE) && field.exists() && !Flags.isEnum(field.getFlags())) {
			fBuilder.append(JavaElementLabels.DECL_STRING);
			if (getFlag(flags, JavaElementLabels.USE_RESOLVED) && field.isResolved()) {
				appendTypeSignatureLabel(field, new BindingKey(field.getKey()).toSignature(), flags);
			} else {
				appendTypeSignatureLabel(field, field.getTypeSignature(), flags);
			}
		}

		// post qualification
		if (getFlag(flags, JavaElementLabels.F_POST_QUALIFIED)) {
			fBuilder.append(JavaElementLabels.CONCAT_STRING);
			appendTypeLabel(field.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
		}

	} catch (JavaModelException e) {
		JavaLanguageServerPlugin.logException("", e); // NotExistsException will not reach this point
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:45,代码来源:JavaElementLabelComposer.java

示例4: createArrayType

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
public ArrayType createArrayType(TType elementType, int dimensions) {
	Assert.isTrue(! elementType.isArrayType());
	Assert.isTrue(! elementType.isAnonymous());
	Assert.isTrue(dimensions > 0);

	int index= dimensions - 1;
	Map<TType, ArrayType> arrayTypes= getArrayTypesMap(index);
	ArrayType result= arrayTypes.get(elementType);
	if (result != null)
		return result;
	result= new ArrayType(this, BindingKey.createArrayTypeBindingKey(elementType.getBindingKey(), dimensions));
	arrayTypes.put(elementType, result);
	result.initialize(elementType, dimensions);
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:TypeEnvironment.java

示例5: translateFtoA

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
/**
 * Translate a typeBinding with a formal type parameter into one with fully substituted type
 * based on the enclosing type
 * @param typeBinding: e.g., virtual field of type <E extends java.lang.Object>
 * @param actualBinding: the enclosing type, e.g., class ArrayList<courses.Course> 
 * 						where the generic type declaration is class ArrayList<E> {...}
 * @return typeBinding with the type substitution performed, e.g., courses.Course
 */
public static ITypeBinding translateFtoA(ITypeBinding typeBinding, ITypeBinding actualBinding) {
	ITypeBinding toTypeBindingActual = typeBinding;

	// HACK: Introduced bugs!		
	// Check that it is a generic type, to avoid generating a type that does not exist!
	// if(!typeBinding.isGenericType()) {
	// 	return typeBinding;
	// }
	
	// HACK: Introduced bugs!
	 if (typeBinding.isEqualTo(actualBinding)) {
		return typeBinding;
	 }
	
	// Instantiate generic types...
	if (actualBinding.isParameterizedType()) {
		ITypeBinding[] typeParameters = actualBinding.getErasure().getTypeParameters();
		int pIndex = -1;
		int index = 0;
		for(ITypeBinding typeParameter : typeParameters ) {
			if ( typeParameter.isEqualTo(typeBinding) ) {
				pIndex = index;
				break;
			}
			index++;
		}
		ITypeBinding[] typeArguments = actualBinding.getTypeArguments();
		if ( typeBinding.isTypeVariable() && typeArguments != null && pIndex != -1  && pIndex < typeArguments.length) {
			toTypeBindingActual = typeArguments[pIndex];
		}
		else {
			String[] typeArgumentString = getParameters(typeArguments);
			String bindingKey = BindingKey.createParameterizedTypeBindingKey(typeBinding.getKey(), typeArgumentString);
			toTypeBindingActual = GenHelper.mapBindingKeyToTypeBinding(bindingKey);
		}
	}
	


	return toTypeBindingActual;
}
 
开发者ID:aroog,项目名称:code,代码行数:50,代码来源:GenHelper.java

示例6: getCorrespondingArrayType

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
private static ITypeBinding getCorrespondingArrayType(ITypeBinding elementType) {
	String bindingKey = BindingKey.createArrayTypeBindingKey(elementType.getKey(), 1);
	ITypeBinding typeBinding = GenHelper.mapBindingKeyToTypeBinding(bindingKey);

	return typeBinding;
}
 
开发者ID:aroog,项目名称:code,代码行数:7,代码来源:GenHelper.java

示例7: createVariable

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
public Variable createVariable(
    IJavaElement element, IType enclosingType, String expectedType, int positionScore)
    throws JavaModelException {
  int variableType;
  int elementType = element.getElementType();
  String elementName = element.getElementName();

  String typeSignature;
  switch (elementType) {
    case IJavaElement.FIELD:
      {
        IField field = (IField) element;
        if (field.getDeclaringType().equals(enclosingType)) {
          variableType = Variable.FIELD;
        } else {
          variableType = Variable.INHERITED_FIELD;
        }
        if (field.isResolved()) {
          typeSignature = new BindingKey(field.getKey()).toSignature();
        } else {
          typeSignature = field.getTypeSignature();
        }
        break;
      }
    case IJavaElement.LOCAL_VARIABLE:
      {
        ILocalVariable locVar = (ILocalVariable) element;
        variableType = Variable.LOCAL;
        typeSignature = locVar.getTypeSignature();
        break;
      }
    case IJavaElement.METHOD:
      {
        IMethod method = (IMethod) element;
        if (isMethodToSuggest(method)) {
          if (method.getDeclaringType().equals(enclosingType)) {
            variableType = Variable.METHOD;
          } else {
            variableType = Variable.INHERITED_METHOD;
          }
          if (method.isResolved()) {
            typeSignature =
                Signature.getReturnType(new BindingKey(method.getKey()).toSignature());
          } else {
            typeSignature = method.getReturnType();
          }
          elementName = elementName + "()"; // $NON-NLS-1$
        } else {
          return null;
        }
        break;
      }
    default:
      return null;
  }
  String type = Signature.toString(typeSignature);

  boolean isAutoboxMatch = isPrimitiveType(expectedType) != isPrimitiveType(type);
  return new Variable(
      type,
      elementName,
      variableType,
      isAutoboxMatch,
      positionScore,
      NO_TRIGGERS,
      getImageDescriptor(element));
}
 
开发者ID:eclipse,项目名称:che,代码行数:68,代码来源:ParameterGuesser.java

示例8: getTypeArguments

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
/**
	 * @param baseType the base type
	 * @param typeArgumentCvs type argument constraint variables
	 * @param rewrite the cu rewrite
	 * @param tCModel the type constraints model
	 * @param leaveUnconstraindRaw <code>true</code> to keep unconstrained type references raw,
	 *            <code>false</code> to infer <code>&lt;?&gt;</code> if possible
	 * @return the new type arguments, or <code>null</code> iff an argument could not be inferred
	 */
	private static Type[] getTypeArguments(Type baseType, ArrayList<CollectionElementVariable2> typeArgumentCvs, CompilationUnitRewrite rewrite, InferTypeArgumentsTCModel tCModel, boolean leaveUnconstraindRaw) {
		if (typeArgumentCvs.size() == 0)
			return null;

		Type[] typeArguments= new Type[typeArgumentCvs.size()];
		for (int i= 0; i < typeArgumentCvs.size(); i++) {
			CollectionElementVariable2 elementCv= typeArgumentCvs.get(i);
			Type typeArgument;
			TType chosenType= InferTypeArgumentsConstraintsSolver.getChosenType(elementCv);
			if (chosenType != null) {
				if (chosenType.isWildcardType() && ! unboundedWildcardAllowed(baseType))
					return null; // can't e.g. write "new ArrayList<?>()".
				if (chosenType.isParameterizedType()) // workaround for bug 99124
					chosenType= chosenType.getTypeDeclaration();
				BindingKey bindingKey= new BindingKey(chosenType.getBindingKey());
				typeArgument= rewrite.getImportRewrite().addImportFromSignature(bindingKey.toSignature(), rewrite.getAST());
				ArrayList<CollectionElementVariable2> nestedTypeArgumentCvs= getTypeArgumentCvs(elementCv, tCModel);
				Type[] nestedTypeArguments= getTypeArguments(typeArgument, nestedTypeArgumentCvs, rewrite, tCModel, leaveUnconstraindRaw); //recursion
				if (nestedTypeArguments != null) {
					ParameterizedType parameterizedType= rewrite.getAST().newParameterizedType(typeArgument);
					for (int j= 0; j < nestedTypeArguments.length; j++)
						parameterizedType.typeArguments().add(nestedTypeArguments[j]);
					typeArgument= parameterizedType;
				}

			} else { // couldn't infer an element type (no constraints)
				if (leaveUnconstraindRaw) {
					// every guess could be wrong => leave the whole thing raw
					return null;
				} else {
					if (unboundedWildcardAllowed(baseType)) {
						typeArgument= rewrite.getAST().newWildcardType();
					} else {
						String object= rewrite.getImportRewrite().addImport("java.lang.Object"); //$NON-NLS-1$
						typeArgument= (Type) rewrite.getASTRewrite().createStringPlaceholder(object, ASTNode.SIMPLE_TYPE);
					}
				}
//				ASTNode baseTypeParent= baseType.getParent();
//				if (baseTypeParent instanceof ClassInstanceCreation) {
//					//No ? allowed. Take java.lang.Object.
//					typeArgument= rewrite.getAST().newSimpleType(rewrite.getAST().newName(rewrite.getImportRewrite().addImport("java.lang.Object"))); //$NON-NLS-1$
//				} else if (baseTypeParent instanceof ArrayCreation || baseTypeParent instanceof InstanceofExpression) {
//					//Only ? allowed.
//					typeArgument= rewrite.getAST().newWildcardType();
//				} else {
//					//E.g. field type: can put anything. Choosing ? in order to be most constraining.
//					typeArgument= rewrite.getAST().newWildcardType();
//				}
			}
			typeArguments[i]= typeArgument;
		}
		return typeArguments;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:63,代码来源:InferTypeArgumentsRefactoring.java

示例9: createVariable

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
public Variable createVariable(IJavaElement element, IType enclosingType, String expectedType, int positionScore) throws JavaModelException {
	int variableType;
	int elementType= element.getElementType();
	String elementName= element.getElementName();

	String typeSignature;
	switch (elementType) {
		case IJavaElement.FIELD: {
			IField field= (IField) element;
			if (field.getDeclaringType().equals(enclosingType)) {
				variableType= Variable.FIELD;
			} else {
				variableType= Variable.INHERITED_FIELD;
			}
			if (field.isResolved()) {
				typeSignature= new BindingKey(field.getKey()).toSignature();
			} else {
				typeSignature= field.getTypeSignature();
			}
			break;
		}
		case IJavaElement.LOCAL_VARIABLE: {
			ILocalVariable locVar= (ILocalVariable) element;
			variableType= Variable.LOCAL;
			typeSignature= locVar.getTypeSignature();
			break;
		}
		case IJavaElement.METHOD: {
			IMethod method= (IMethod) element;
			if (isMethodToSuggest(method)) {
				if (method.getDeclaringType().equals(enclosingType)) {
					variableType= Variable.METHOD;
				} else {
					variableType= Variable.INHERITED_METHOD;
				}
				if (method.isResolved()) {
					typeSignature= Signature.getReturnType(new BindingKey(method.getKey()).toSignature());
				} else {
					typeSignature= method.getReturnType();
				}
				elementName= elementName + "()";  //$NON-NLS-1$
			} else {
				return null;
			}
			break;
		}
		default:
			return null;
	}
	String type= Signature.toString(typeSignature);

	boolean isAutoboxMatch= isPrimitiveType(expectedType) != isPrimitiveType(type);
	return new Variable(type, elementName, variableType, isAutoboxMatch, positionScore, NO_TRIGGERS, getImageDescriptor(element));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:55,代码来源:ParameterGuesser.java

示例10: ConstructorPattern

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
public ConstructorPattern(
	char[] declaringSimpleName,
	char[] declaringQualification,
	char[][] parameterQualifications,
	char[][] parameterSimpleNames,
	String[] parameterSignatures,
	IMethod method,
	int limitTo,
	int matchRule) {

	this(declaringSimpleName,
		declaringQualification,
		parameterQualifications,
		parameterSimpleNames,
		limitTo,
		matchRule);

	// Set flags
	try {
		this.varargs = (method.getFlags() & Flags.AccVarargs) != 0;
	} catch (JavaModelException e) {
		// do nothing
	}

	// Get unique key for parameterized constructors
	String genericDeclaringTypeSignature = null;
	if (method.isResolved()) {
		String key = method.getKey();
		BindingKey bindingKey = new BindingKey(key);
		if (bindingKey.isParameterizedType()) {
			genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key);
			// Store type signature and arguments for declaring type
			if (genericDeclaringTypeSignature != null) {
					this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature);
					setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
			}
		}
	} else {
		this.constructorParameters = true;
		storeTypeSignaturesAndArguments(method.getDeclaringType());
	}

	// store type signatures and arguments for method parameters type
	if (parameterSignatures != null) {
		int length = parameterSignatures.length;
		if (length > 0) {
			this.parametersTypeSignatures = new char[length][][];
			this.parametersTypeArguments = new char[length][][][];
			for (int i=0; i<length; i++) {
				this.parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
				this.parametersTypeArguments[i] = Util.getAllTypeArguments(this.parametersTypeSignatures[i]);
			}
		}
	}

	// Store type signatures and arguments for method
	this.constructorArguments = extractMethodArguments(method);
	if (hasConstructorArguments())  this.mustResolve = true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:60,代码来源:ConstructorPattern.java

示例11: createCorrespondingNode

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
/**
 * Returns a new ast node corresponding to the given type.
 * 
 * @param rewrite the compilation unit rewrite to use
 * @param type the new type
 * @param node the old node
 * @return A corresponding ast node
 */
protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type, ASTNode node) {
	ImportRewrite importRewrite= rewrite.getImportRewrite();
	ImportRewriteContext context = new ContextSensitiveImportRewriteContext(node, importRewrite);
	return importRewrite.addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST(), context);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:SuperTypeRefactoringProcessor.java

示例12: createCorrespondingNode

import org.eclipse.jdt.core.BindingKey; //导入依赖的package包/类
/**
 * Returns a new ast node corresponding to the given type.
 *
 * @param rewrite
 *            the compilation unit rewrite to use
 * @param type
 *            the specified type
 * @return A corresponding ast node
 */
protected static ASTNode createCorrespondingNode(final CompilationUnitRewrite rewrite, final TType type) {
	return rewrite.getImportRewrite().addImportFromSignature(new BindingKey(type.getBindingKey()).toSignature(), rewrite.getAST());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:13,代码来源:SuperTypeRefactoringProcessor.java


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