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


Java ClassInstanceCreation.getType方法代码示例

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


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

示例1: endVisit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public void endVisit(ClassInstanceCreation node) {
  Expression receiver = node.getExpression();
  Type createdType = node.getType();

  ConstraintVariable2 typeCv;
  if (node.getAnonymousClassDeclaration() == null) {
    typeCv = getConstraintVariable(createdType);
  } else {
    typeCv = fTCModel.makeImmutableTypeVariable(createdType.resolveBinding(), null);
    setConstraintVariable(createdType, typeCv);
  }
  setConstraintVariable(node, typeCv);

  IMethodBinding methodBinding = node.resolveConstructorBinding();
  Map<String, IndependentTypeVariable2> methodTypeVariables =
      createMethodTypeArguments(methodBinding);
  List<Expression> arguments = node.arguments();
  doVisitMethodInvocationArguments(
      methodBinding, arguments, receiver, methodTypeVariables, createdType);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:InferTypeArgumentsConstraintCreator.java

示例2: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(final ClassInstanceCreation node) {
	Assert.isNotNull(node);
	if (fCreateInstanceField) {
		final AST ast= node.getAST();
		final Type type= node.getType();
		final ITypeBinding binding= type.resolveBinding();
		if (binding != null && binding.getDeclaringClass() != null && !Bindings.equals(binding, fTypeBinding) && fSourceRewrite.getRoot().findDeclaringNode(binding) != null) {
			if (!Modifier.isStatic(binding.getModifiers())) {
				Expression expression= null;
				if (fCodeGenerationSettings.useKeywordThis || fEnclosingInstanceFieldName.equals(fNameForEnclosingInstanceConstructorParameter)) {
					final FieldAccess access= ast.newFieldAccess();
					access.setExpression(ast.newThisExpression());
					access.setName(ast.newSimpleName(fEnclosingInstanceFieldName));
					expression= access;
				} else
					expression= ast.newSimpleName(fEnclosingInstanceFieldName);
				if (node.getExpression() != null)
					fSourceRewrite.getImportRemover().registerRemovedNode(node.getExpression());
				fSourceRewrite.getASTRewrite().set(node, ClassInstanceCreation.EXPRESSION_PROPERTY, expression, fGroup);
			} else
				addTypeQualification(type, fSourceRewrite, fGroup);
		}
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:MoveInnerToTopRefactoring.java

示例3: endVisit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public void endVisit(ClassInstanceCreation node) {
	Expression receiver= node.getExpression();
	Type createdType= node.getType();

	ConstraintVariable2 typeCv;
	if (node.getAnonymousClassDeclaration() == null) {
		typeCv= getConstraintVariable(createdType);
	} else {
		typeCv= fTCModel.makeImmutableTypeVariable(createdType.resolveBinding(), null);
		setConstraintVariable(createdType, typeCv);
	}
	setConstraintVariable(node, typeCv);

	IMethodBinding methodBinding= node.resolveConstructorBinding();
	Map<String, IndependentTypeVariable2> methodTypeVariables= createMethodTypeArguments(methodBinding);
	List<Expression> arguments= node.arguments();
	doVisitMethodInvocationArguments(methodBinding, arguments, receiver, methodTypeVariables, createdType);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:InferTypeArgumentsConstraintCreator.java

示例4: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(ClassInstanceCreation node) {
	// match with the constructor and the type.

	Type type= node.getType();
	if (type instanceof ParameterizedType) {
		type= ((ParameterizedType) type).getType();
	}
	if (type instanceof SimpleType) {
		Name name= ((SimpleType) type).getName();
		if (name instanceof QualifiedName)
			name= ((QualifiedName)name).getName();
		addUsage(name, node.resolveConstructorBinding());
	}
	return super.visit(node);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:OccurrencesFinder.java

示例5: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(ClassInstanceCreation node) {
    if (badBigDecimalConstructor != null) {
        return false;
    }
    Type type = node.getType();
    if (type instanceof SimpleType
            && "BigDecimal".equals(((SimpleType) type).getName().getFullyQualifiedName())) {

        @SuppressWarnings("unchecked")
        List<Expression> args = node.arguments();
        if (args.size() == 1 && args.get(0) instanceof NumberLiteral) {
            badBigDecimalConstructor = node;
            this.decimalVar = (NumberLiteral) node.arguments().get(0);
        }
    }

    return true;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:20,代码来源:BigDecimalConstructorResolution.java

示例6: addParameterInfo

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException {
	ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST());
	String name= fParameterName != null ? fParameterName : guessedParameterName();
	Expression expression= fSelectedExpression instanceof ParenthesizedExpression ? ((ParenthesizedExpression)fSelectedExpression).getExpression() : fSelectedExpression;
	
	ImportRewrite importRewrite= cuRewrite.getImportRewrite();			
	ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(fSelectedExpression, importRewrite);
	String typeName= importRewrite.addImport(typeBinding, importRewriteContext);
	
	String defaultValue= null;
	if (expression instanceof ClassInstanceCreation && typeBinding.isParameterizedType()) {
		ClassInstanceCreation classInstanceCreation= (ClassInstanceCreation) expression;
		Type cicType= classInstanceCreation.getType();
		if (cicType instanceof ParameterizedType && ((ParameterizedType) cicType).typeArguments().size() == 0) {
			// expand the diamond:
			AST ast= cuRewrite.getAST();				
			Type type= importRewrite.addImport(typeBinding, ast, importRewriteContext);				
			classInstanceCreation.setType(type);    // Should not touch the original AST ...
			defaultValue= ASTNodes.asFormattedString(classInstanceCreation,  0, StubUtility.getLineDelimiterUsed(cuRewrite.getCu()), cuRewrite.getCu().getJavaProject().getOptions(true));
			classInstanceCreation.setType(cicType); // ... so let's restore it right away.
		}
	}
	
	if (defaultValue == null) {
		defaultValue= fSourceCU.getBuffer().getText(expression.getStartPosition(), expression.getLength());
	}
	fParameter= ParameterInfo.createInfoForAddedParameter(typeBinding, typeName, name, defaultValue);
	if (fArguments == null) {
		List<ParameterInfo> parameterInfos= fChangeSignatureProcessor.getParameterInfos();
		int parametersCount= parameterInfos.size();
		if (parametersCount > 0 && parameterInfos.get(parametersCount - 1).isOldVarargs())
			parameterInfos.add(parametersCount - 1, fParameter);
		else
			parameterInfos.add(fParameter);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:IntroduceParameterRefactoring.java

示例7: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(ClassInstanceCreation node) {
	if (matches(node.resolveConstructorBinding())) {
		Type type= node.getType();
		fResult.add(new OccurrenceLocation(type.getStartPosition(), type.getLength(), 0, fDescription));
	}
	return super.visit(node);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ExceptionOccurrencesFinder.java

示例8: visit

import org.eclipse.jdt.core.dom.ClassInstanceCreation; //导入方法依赖的package包/类
@Override
public boolean visit(ClassInstanceCreation node) {
	if (isExitPoint(node.resolveConstructorBinding())) {
		Type name= node.getType();
		fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fExitDescription));
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:MethodExitsFinder.java


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