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


Java JCExpression类代码示例

本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCExpression的典型用法代码示例。如果您正苦于以下问题:Java JCExpression类的具体用法?Java JCExpression怎么用?Java JCExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createField

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, String loggerTopic) {
	JavacTreeMaker maker = typeNode.getTreeMaker();
	
	// private static final <loggerType> log = <factoryMethod>(<parameter>);
	JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName());
	JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName());

	JCExpression loggerName;
	if (loggerTopic == null || loggerTopic.trim().length() == 0) {
		loggerName = framework.createFactoryParameter(typeNode, loggingType);
	} else {
		loggerName = maker.Literal(loggerTopic);
	}

	JCMethodInvocation factoryMethodCall = maker.Apply(List.<JCExpression>nil(), factoryMethod, List.<JCExpression>of(loggerName));

	JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
			maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (useStatic ? Flags.STATIC : 0)),
			typeNode.toName(logFieldName), loggerType, factoryMethodCall), source, typeNode.getContext());
	
	injectFieldAndMarkGenerated(typeNode, fieldDecl);
	return true;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:24,代码来源:HandleLog.java

示例2: resolveIdent

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
/**
 * Resolve an identifier.
 *
 * @param name The identifier to resolve
 */
public Symbol resolveIdent(String name) {
    if (name.equals(""))
        return syms.errSymbol;
    JavaFileObject prev = log.useSource(null);
    try {
        JCExpression tree = null;
        for (String s : name.split("\\.", -1)) {
            if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
                return syms.errSymbol;
            tree = (tree == null) ? make.Ident(names.fromString(s))
                    : make.Select(tree, names.fromString(s));
        }
        JCCompilationUnit toplevel =
                make.TopLevel(List.<JCAnnotation>nil(), null, List.<JCTree>nil());
        toplevel.packge = syms.unnamedPackage;
        return attr.attribIdent(tree, toplevel);
    } finally {
        log.useSource(prev);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:26,代码来源:JavaCompiler.java

示例3: resolveIdent

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
/** Resolve an identifier.
 * @param msym      The module in which the search should be performed
 * @param name      The identifier to resolve
 */
public Symbol resolveIdent(ModuleSymbol msym, String name) {
    if (name.equals(""))
        return syms.errSymbol;
    JavaFileObject prev = log.useSource(null);
    try {
        JCExpression tree = null;
        for (String s : name.split("\\.", -1)) {
            if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
                return syms.errSymbol;
            tree = (tree == null) ? make.Ident(names.fromString(s))
                                  : make.Select(tree, names.fromString(s));
        }
        JCCompilationUnit toplevel =
            make.TopLevel(List.nil());
        toplevel.modle = msym;
        toplevel.packge = msym.unnamedPackage;
        return attr.attribIdent(tree, toplevel);
    } finally {
        log.useSource(prev);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:JavaCompiler.java

示例4: resolutionExceptionBlock

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private JCBlock resolutionExceptionBlock() {
    if (resolutionExceptionBlock == null) {
        JCExpression expClass = null;
        // Split the exception class name at dots
        for (String id : SPIResolutionException.class.getName().split("\\.")) {
            Name nm = names.fromString(id);
            if (expClass == null) {
                expClass = make.Ident(nm);
            } else {
                expClass = make.Select(expClass, nm);
            }
        }
        JCNewClass exp = make.NewClass(null,
                null, expClass, List.of(make.Literal(keyIndex)), null);
        resolutionExceptionBlock = make.Block(0L, List.of(make.Throw(exp)));
    }
    return resolutionExceptionBlock;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Corraller.java

示例5: replaceExtCall

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private void replaceExtCall( JCTree.JCMethodInvocation tree, Symbol.MethodSymbol method )
{
  JCExpression methodSelect = tree.getMethodSelect();
  if( methodSelect instanceof JCTree.JCFieldAccess )
  {
    JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
    boolean isStatic = m.sym.getModifiers().contains( javax.lang.model.element.Modifier.STATIC );
    TreeMaker make = _tp.getTreeMaker();
    JavacElements javacElems = _tp.getElementUtil();
    JCExpression thisArg = m.selected;
    String extensionFqn = method.getEnclosingElement().asType().tsym.toString();
    m.selected = memberAccess( make, javacElems, extensionFqn );
    BasicJavacTask javacTask = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getJavacTask();
    Symbol.ClassSymbol extensionClassSym = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getClassSymbol( javacTask, extensionFqn ).getFirst();
    assignTypes( m.selected, extensionClassSym );
    m.sym = method;
    m.type = method.type;

    if( !isStatic )
    {
      ArrayList<JCExpression> newArgs = new ArrayList<>( tree.args );
      newArgs.add( 0, thisArg );
      tree.args = List.from( newArgs );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:27,代码来源:ExtensionTransformer.java

示例6: isStructuralMethod

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private boolean isStructuralMethod( JCTree.JCMethodInvocation tree )
{
  JCExpression methodSelect = tree.getMethodSelect();
  if( methodSelect instanceof JCTree.JCFieldAccess )
  {
    JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
    if( m.sym != null && !m.sym.getModifiers().contains( javax.lang.model.element.Modifier.STATIC ) )
    {
      JCExpression thisArg = m.selected;
      if( TypeUtil.isStructuralInterface( _tp, thisArg.type.tsym ) )
      {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:18,代码来源:ExtensionTransformer.java

示例7: cloneParamType

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JCTree source) {
	if (typeArgs == null || typeArgs.size() <= index) {
		return genJavaLangTypeRef(builderType, "Object");
	} else {
		JCExpression originalType = typeArgs.get(index);
		if (originalType.getKind() == Kind.UNBOUNDED_WILDCARD || originalType.getKind() == Kind.SUPER_WILDCARD) {
			return genJavaLangTypeRef(builderType, "Object");
		} else if (originalType.getKind() == Kind.EXTENDS_WILDCARD) {
			try {
				return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source, builderType.getContext());
			} catch (Exception e) {
				return genJavaLangTypeRef(builderType, "Object");
			}
		} else {
			return cloneType(maker, originalType, source, builderType.getContext());
		}
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:JavacSingularsRecipes.java

示例8: resolveIdent

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
/** Resolve an identifier.
 * @param msym      The module in which the search should be performed
 * @param name      The identifier to resolve
 */
public Symbol resolveIdent(ModuleSymbol msym, String name) {
    if (name.equals(""))
        return syms.errSymbol;
    JavaFileObject prev = log.useSource(null);
    try {
        JCExpression tree = null;
        for (String s : name.split("\\.", -1)) {
            if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
                return syms.errSymbol;
            tree = (tree == null) ? make.Ident(names.fromString(s))
                                  : make.Select(tree, names.fromString(s));
        }
        JCCompilationUnit toplevel =
            make.TopLevel(List.<JCTree>nil());
        toplevel.modle = msym;
        toplevel.packge = msym.unnamedPackage;
        return attr.attribIdent(tree, toplevel);
    } finally {
        log.useSource(prev);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:26,代码来源:JavaCompiler.java

示例9: createTypeReference

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
public JCExpression createTypeReference(JavacNode type) {
	java.util.List<String> list = new ArrayList<String>();
	list.add(type.getName());
	JavacNode tNode = type.up();
	while (tNode != null && tNode.getKind() == Kind.TYPE) {
		list.add(tNode.getName());
		tNode = tNode.up();
	}
	Collections.reverse(list);
	
	JavacTreeMaker maker = type.getTreeMaker();
	JCExpression chain = maker.Ident(type.toName(list.get(0)));
	
	for (int i = 1; i < list.size(); i++) {
		chain = maker.Select(chain, type.toName(list.get(i)));
	}
	
	return chain;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:HandleEqualsAndHashCode.java

示例10: resolutionExceptionBlock

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private JCBlock resolutionExceptionBlock() {
    if (resolutionExceptionBlock == null) {
        JCExpression expClass = null;
        // Split the exception class name at dots
        for (String id : SPIResolutionException.class.getName().split("\\.")) {
            Name nm = names.fromString(id);
            if (expClass == null) {
                expClass = make.Ident(nm);
            } else {
                expClass = make.Select(expClass, nm);
            }
        }
        JCNewClass exp = make.NewClass(null,
                null, expClass, List.of(make.Literal(keyIndex)), null);
        resolutionExceptionBlock = make.Block(0L, List.<JCStatement>of(
                make.Throw(exp)));
    }
    return resolutionExceptionBlock;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:20,代码来源:Corraller.java

示例11: generateMethods

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
@Override public void generateMethods(SingularData data, JavacNode builderType, JCTree source, boolean fluent, boolean chain) {
	if (useGuavaInstead(builderType)) {
		guavaListSetSingularizer.generateMethods(data, builderType, source, fluent, chain);
		return;
	}
	
	JavacTreeMaker maker = builderType.getTreeMaker();
	Name thisName = builderType.toName("this");
	
	JCExpression returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
	JCStatement returnStatement = chain ? maker.Return(maker.Ident(thisName)) : null;
	generateSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
	
	returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
	returnStatement = chain ? maker.Return(maker.Ident(thisName)) : null;
	generatePluralMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
	
	returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
	returnStatement = chain ? maker.Return(maker.Ident(thisName)) : null;
	generateClearMethod(maker, returnType, returnStatement, data, builderType, source);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:JavacJavaUtilListSetSingularizer.java

示例12: generateCleanMethod

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
	JavacTreeMaker maker = type.getTreeMaker();
	ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
	
	for (BuilderFieldData bfd : builderFields) {
		if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
			bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, type, source, statements);
		}
	}
	
	statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")), maker.Literal(CTC_BOOLEAN, false))));
	JCBlock body = maker.Block(0, statements.toList());
	return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName("$lombokClean"), maker.Type(Javac.createVoidType(maker, CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
	/*
	 * 		if (shouldReturnThis) {
		methodType = cloneSelfType(field);
	}
	
	if (methodType == null) {
		//WARNING: Do not use field.getSymbolTable().voidType - that field has gone through non-backwards compatible API changes within javac1.6.
		methodType = treeMaker.Type(Javac.createVoidType(treeMaker, CTC_VOID));
		shouldReturnThis = false;
	}

	 */
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:27,代码来源:HandleBuilder.java

示例13: generateMethods

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
@Override public void generateMethods(SingularData data, JavacNode builderType, JCTree source, boolean fluent, boolean chain) {
	if (useGuavaInstead(builderType)) {
		guavaMapSingularizer.generateMethods(data, builderType, source, fluent, chain);
		return;
	}
	
	JavacTreeMaker maker = builderType.getTreeMaker();
	
	JCExpression returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
	JCStatement returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
	generateSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
	
	returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
	returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
	generatePluralMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
	
	returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
	returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
	generateClearMethod(maker, returnType, returnStatement, data, builderType, source);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:21,代码来源:JavacJavaUtilMapSingularizer.java

示例14: suppress

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
private boolean suppress(JCTree tree) {
	if (tree instanceof JCBlock) {
		JCBlock block = (JCBlock) tree;
		return (Position.NOPOS == block.pos) && block.stats.isEmpty();
	}
	
	if (tree instanceof JCExpressionStatement) {
		JCExpression expr = ((JCExpressionStatement)tree).expr;
		if (expr instanceof JCMethodInvocation) {
			JCMethodInvocation inv = (JCMethodInvocation) expr;
			if (!inv.typeargs.isEmpty() || !inv.args.isEmpty()) return false;
			if (!(inv.meth instanceof JCIdent)) return false;
			return ((JCIdent) inv.meth).name.toString().equals("super");
		}
	}
	
	return false;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:PrettyPrinter.java

示例15: visitTree

import com.sun.tools.javac.tree.JCTree.JCExpression; //导入依赖的package包/类
@Override public void visitTree(JCTree tree) {
	String simpleName = tree.getClass().getSimpleName();
	if ("JCTypeUnion".equals(simpleName)) {
		List<JCExpression> types = readObject(tree, "alternatives", List.<JCExpression>nil());
		print(types, " | ");
		return;
	} else if ("JCTypeIntersection".equals(simpleName)) {
		print(readObject(tree, "bounds", List.<JCExpression>nil()), " & ");
		return;
	} else if ("JCMemberReference".equals(simpleName)) {
		printMemberReference0(tree);
		return;
	} else if ("JCLambda".equals(simpleName)) {
		printLambda0(tree);
		return;
	} else if ("JCAnnotatedType".equals(simpleName)) {
		printAnnotatedType0(tree);
		return;
	}
	
	throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:23,代码来源:PrettyPrinter.java


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