• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TypeLiteral类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getTypeLiteralSelection

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
/** 
 * @return selection (offset,length) of first simple type node within statement given by <code>statementIndex</code>
 */
private int[] getTypeLiteralSelection(int statementIndex, IMethod target) {
	MethodDeclaration targetNode = compileTargetMethod(target);
	Statement stmt = (Statement) targetNode.getBody().statements().get(statementIndex );
	final int[] selection = new int[2];
	stmt.accept( new ASTVisitor() {
		@Override
		public boolean visit(TypeLiteral node) {
			if (selection[1] == 0) {
				selection[0] = node.getStartPosition();
				selection[1] = node.getLength();
			}
			return false;
		}
	});
	return selection;
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:20,代码来源:ClassAccessTest.java


示例2: createGetClassMethodInvocation

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private MethodInvocation createGetClassMethodInvocation(MethodInvocation invNode, ITypeBinding[] paramTyps, AST ast) {
	MethodInvocation result = ast.newMethodInvocation();
	result.setName(ast.newSimpleName("getMethod")); //$NON-NLS-1$
	StringLiteral methName = ast.newStringLiteral();
	methName.setLiteralValue(invNode.getName().getFullyQualifiedName());
	result.arguments().add(methName);
	if (paramTyps != null && paramTyps.length > 0) {
		for (ITypeBinding paramTyp : paramTyps) {
			TypeLiteral curTyp = ast.newTypeLiteral();
			curTyp.setType(createType(paramTyp, ast));
			result.arguments().add(curTyp);
		}
	}
	return result;
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:17,代码来源:MethodInvocationProposalCreator.java


示例3: createProposal

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
public IJavaCompletionProposal createProposal(ASTNode node, IInvocationContext context) {
	if (node == null || node.getNodeType() != ASTNode.TYPE_LITERAL) {
		throw new IllegalArgumentException(ReflectifyMessages.NoOrIllegalNodeError);
	}
	
	TypeLiteral  litNode  = (TypeLiteral)node;
	ITypeBinding typeBind = litNode.getType().resolveBinding();
	if (typeBind == null) {
		throw new IllegalArgumentException(ReflectifyMessages.BindingResolutionError);
	}
	
	AST              ast     = litNode.getAST();
	ASTRewrite       rewrite = ASTRewrite.create(ast);
	MethodInvocation methInv = createClassForName(typeBind, ast);

	rewrite.replace(litNode, methInv, null); // no edit group
	return new ASTRewriteCorrectionProposal(
			ReflectifyMessages.ReflectifyAssistProcessor_class, 
			context.getCompilationUnit(),
			rewrite, 
			getRelevance(), 
			JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL));
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:24,代码来源:ClassAccessProposalCreator.java


示例4: parametrizedTypeOf

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private Type parametrizedTypeOf(MethodInvocation methodInvocation, Class<?> clazz) {
    if (methodInvocation.arguments().size() == 1 && methodInvocation.arguments().get(0) instanceof TypeLiteral) {
        return nodeFactory.parameterizedType(nodeFactory.simpleType(clazz.getSimpleName()),
                singletonList(nodeFactory.clone(((TypeLiteral) methodInvocation.arguments().get(0)).getType())));
    } else {
        return nodeFactory.simpleType(clazz.getSimpleName());
    }
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:9,代码来源:MatcherHandler.java


示例5: anyMapOf

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private Type anyMapOf(MethodInvocation methodInvocation, Class<?> clazz) {
    if (methodInvocation.arguments().size() == 2 &&
            methodInvocation.arguments().get(0) instanceof TypeLiteral &&
            methodInvocation.arguments().get(1) instanceof TypeLiteral) {
        return nodeFactory.parameterizedType(nodeFactory.simpleType(clazz.getSimpleName()),
                ImmutableList.of(nodeFactory.clone(((TypeLiteral) methodInvocation.arguments().get(0)).getType()),
                nodeFactory.clone(((TypeLiteral) methodInvocation.arguments().get(1)).getType())));
    } else {
        return nodeFactory.simpleType(clazz.getSimpleName());
    }
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:12,代码来源:MatcherHandler.java


示例6: anyMatcher

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private ASTNode anyMatcher(MethodInvocation methodInvocation) {
    if (methodInvocation.arguments().size() == 1 && methodInvocation.arguments().get(0) instanceof TypeLiteral) {
        return classMatcher(((TypeLiteral) methodInvocation.arguments().get(0)).getType());
    } else {
        return wildcard();
    }
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:8,代码来源:MatcherHandler.java


示例7: addThrownSupport

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private void addThrownSupport(MethodDeclaration methodDeclaration) {
    Optional<Annotation> testAnnotation = annotatedWith(methodDeclaration, "Test");
    Optional<Expression> expected = testAnnotation
            .filter(annotation -> annotation instanceof NormalAnnotation)
            .flatMap(this::expectedException);

    expected.ifPresent(expression -> body()
            .add(astNodeFactory().methodInvocation(THROWN,
                    singletonList(astNodeFactory().simpleName(((TypeLiteral) expression).getType().toString())))));
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:11,代码来源:TestMethodModel.java


示例8: endVisit

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@Override
public void endVisit(TypeLiteral node) {
	if (skipNode(node)) {
		return;
	}
	assignFlowInfo(node, node.getType());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:FlowAnalyzer.java


示例9: unboundedWildcardAllowed

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private static boolean unboundedWildcardAllowed(Type originalType) {
  ASTNode parent = originalType.getParent();
  while (parent instanceof Type) parent = parent.getParent();

  if (parent instanceof ClassInstanceCreation) {
    return false;
  } else if (parent instanceof AbstractTypeDeclaration) {
    return false;
  } else if (parent instanceof TypeLiteral) {
    return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:InferTypeArgumentsRefactoring.java


示例10: obtainTypeLiteralAnnotation

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
public static ITypeBinding obtainTypeLiteralAnnotation(BodyDeclaration declaration, Class<?> annotationClass) {
	Expression expr = obtainSingleMemberAnnotationValue(declaration, annotationClass);
	if (expr instanceof TypeLiteral) {
		return ((TypeLiteral) expr).getType().resolveBinding();
	}
	return null;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:8,代码来源:SharedUtils.java


示例11: visit

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@Override
public boolean visit(TypeLiteral node) {
	final String type = node.getType().toString();
	if (topMethod != null && methodsAsRoot) {
		types.put(topMethod, type);
	} else if (topClass != null) {
		types.put(topClass, type);
	}
	return super.visit(node);
}
 
开发者ID:mast-group,项目名称:tassal,代码行数:11,代码来源:TypenameScopeExtractor.java


示例12: unboundedWildcardAllowed

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private static boolean unboundedWildcardAllowed(Type originalType) {
	ASTNode parent= originalType.getParent();
	while (parent instanceof Type)
		parent= parent.getParent();

	if (parent instanceof ClassInstanceCreation) {
		return false;
	} else if (parent instanceof AbstractTypeDeclaration) {
		return false;
	} else if (parent instanceof TypeLiteral) {
		return false;
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:InferTypeArgumentsRefactoring.java


示例13: repairBug

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@Override
protected void repairBug(ASTRewrite rewrite, CompilationUnit workingUnit, BugInstance bug) throws BugResolutionException {
    ASTNode node = getASTNode(workingUnit, bug.getPrimarySourceLineAnnotation());
    LOVisitor visitor = new LOVisitor();
    node.accept(visitor);

    TypeLiteral fixedTypeLiteral = makeTypeLiteral(rewrite, node);
    rewrite.replace(visitor.badArgument, fixedTypeLiteral, null);
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:10,代码来源:LoggerOdditiesResolution.java


示例14: makeTypeLiteral

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private TypeLiteral makeTypeLiteral(ASTRewrite rewrite, ASTNode node) {
    TypeDeclaration tDeclaration = TraversalUtil.findClosestAncestor(node, TypeDeclaration.class);
    SimpleName name = tDeclaration.getName();
    AST ast = rewrite.getAST();
    SimpleType parentType = ast.newSimpleType(ast.newSimpleName(name.getIdentifier()));
    TypeLiteral fixedTypeLiteral = ast.newTypeLiteral();
    fixedTypeLiteral.setType(parentType);
    return fixedTypeLiteral;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:10,代码来源:LoggerOdditiesResolution.java


示例15: makeEnumConstructor

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private Expression makeEnumConstructor(EnumCollectionsVisitor visitor, ASTRewrite rewrite) {
    AST ast = rewrite.getAST();
    TypeLiteral enumDotClass = ast.newTypeLiteral(); // this is the EnumHere.class
    enumDotClass.setType(ast.newSimpleType(ast.newName(visitor.enumNameToUse)));

    if (visitor.isMap) {
        return makeEnumMap(enumDotClass, ast);
    }
    return makeEnumSet(enumDotClass, ast);
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:11,代码来源:UseEnumCollectionsResolution.java


示例16: makeEnumSet

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Expression makeEnumSet(TypeLiteral enumType, AST ast) {
    MethodInvocation newEnumSet = ast.newMethodInvocation();
    newEnumSet.setExpression(ast.newSimpleName("EnumSet"));
    newEnumSet.setName(ast.newSimpleName("noneOf"));
    newEnumSet.arguments().add(enumType);

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


示例17: makeEnumMap

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Expression makeEnumMap(TypeLiteral enumType, AST ast) {
    ClassInstanceCreation newEnumMap = ast.newClassInstanceCreation();
    Type enumMap = ast.newSimpleType(ast.newName("EnumMap"));
    // makes the <> braces by default
    newEnumMap.setType(ast.newParameterizedType(enumMap));
    newEnumMap.arguments().add(enumType);

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


示例18: typeLiteralToClassName

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
private String typeLiteralToClassName(Object node)
{
    if (node instanceof TypeLiteral)
    {
        return EclipseUtils.toClassName(tapestryModule.getEclipseProject(), (TypeLiteral) node);
    }
    return null;
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:9,代码来源:TapestryServiceCapturingVisitor.java


示例19: fillTypeLiteral

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
/**
 * Fills type literal skeleton pieces.
 * @param node The type literal part of the skeleton.
 * @return The synthesized expressions corresponding to this
 * skeleton piece and the type constraint representing their types.
 */
private ExpressionsAndTypeConstraints fillTypeLiteral(Expression node) {
	try {
		codehint.ast.Expression expr = ASTConverter.copy(node);
		IJavaType type = EclipseUtils.getType(((TypeLiteral)node).getType().toString(), stack, target, typeCache);
		IJavaClassObject classObj = ((IJavaReferenceType)type).getClassObject();
		IJavaType classObjType = classObj.getJavaType();
		expr.setStaticType(classObjType);
		Result result = new Result(classObj, valueCache, thread);
		expressionEvaluator.setResult(expr, result, Collections.<Effect>emptySet());
		return new ExpressionsAndTypeConstraints(expr, new SupertypeBound(classObjType));
	} catch (DebugException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:21,代码来源:ExpressionSkeleton.java


示例20: visit

import org.eclipse.jdt.core.dom.TypeLiteral; //导入依赖的package包/类
@Override
public boolean visit(TypeLiteral node) {
	//System.out.println("Found: " + node.getClass());
	// TODO I don't know if this is the right way to do this
	print("typeid(");
	node.getType().accept(this);
	print(")");
	return false;
}
 
开发者ID:mrmonday,项目名称:j2d,代码行数:10,代码来源:J2dVisitor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DeployableContainer类代码示例发布时间:2022-05-21
下一篇:
Java OverlayItem类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap