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


Java JCImport类代码示例

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


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

示例1: diffImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
protected int diffImport(JCImport oldT, JCImport newT, int[] bounds) {
    int localPointer = bounds[0];

    int[] qualBounds = getBounds(oldT.getQualifiedIdentifier());
    if (oldT.staticImport == newT.staticImport) {
        copyTo(localPointer, qualBounds[0]);
    } else {
        if (oldT.staticImport) {
            //removing "static":
            moveFwdToToken(tokenSequence, localPointer, JavaTokenId.STATIC);
            copyTo(localPointer, tokenSequence.offset());
        } else {
            copyTo(localPointer, qualBounds[0]);
            printer.print("static ");
        }
    }
    localPointer = diffTree(oldT.getQualifiedIdentifier(), newT.getQualifiedIdentifier(), qualBounds);
    copyTo(localPointer, bounds[1]);

    return bounds[1];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CasualDiff.java

示例2: deleteImportFromCompilationUnit

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public static void deleteImportFromCompilationUnit(JavacNode node, String name) {
	if (inNetbeansEditor(node)) return;
	if (!node.shouldDeleteLombokAnnotations()) return;
	ListBuffer<JCTree> newDefs = new ListBuffer<JCTree>();
	
	JCCompilationUnit unit = (JCCompilationUnit) node.top().get();
	
	for (JCTree def : unit.defs) {
		boolean delete = false;
		if (def instanceof JCImport) {
			JCImport imp0rt = (JCImport)def;
			delete = (!imp0rt.staticImport && imp0rt.qualid.toString().equals(name));
		}
		if (!delete) newDefs.append(def);
	}
	unit.defs = newDefs.toList();
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:18,代码来源:JavacHandlerUtil.java

示例3: stubImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
/**
 * A helper method to create a JCImport stub.
 *
 * @param typeName the fully-qualified name of the type being imported
 * @param isStatic whether the import is static
 * @param startPos the start position of the import statement
 * @param endPos the end position of the import statement
 * @return a new JCImport stub
 */
private static JCImport stubImport(String typeName, boolean isStatic, int startPos, int endPos) {
  JCImport result = mock(JCImport.class);
  when(result.isStatic()).thenReturn(isStatic);
  when(result.getStartPosition()).thenReturn(startPos);
  when(result.getEndPosition(anyMapOf(JCTree.class, Integer.class))).thenReturn(endPos);

  // craft import string
  StringBuilder returnSB = new StringBuilder("import ");
  if (isStatic) {
    returnSB.append("static ");
  }
  returnSB.append(typeName);
  returnSB.append(";\n");
  when(result.toString()).thenReturn(returnSB.toString());
  return result;
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:26,代码来源:ImportStatementsTest.java

示例4: visitTopLevel

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
@Override public void visitTopLevel(JCCompilationUnit node) {
	CompilationUnit unit = new CompilationUnit();
	if (node.pid != null) {
		PackageDeclaration pkg = new PackageDeclaration();
		fillWithIdentifiers(node.pid, pkg.astParts());
		unit.astPackageDeclaration(setPos(node.pid, pkg));
		fillList(node.packageAnnotations, pkg.rawAnnotations());
	}
	
	for (JCTree def : node.defs) {
		if (def instanceof JCImport) {
			unit.rawImportDeclarations().addToEnd(toTree(def));
		} else {
			unit.rawTypeDeclarations().addToEnd(toTree(def, FlagKey.SKIP_IS_DECL));
		}
	}
	
	setConversionStructureInfo(unit, "converted");
	set(node, unit);
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:21,代码来源:JcTreeConverter.java

示例5: deleteImportFromCompilationUnit

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public static void deleteImportFromCompilationUnit(JavacNode node, String name) {
	if (inNetbeansEditor(node)) return;
	if (!node.shouldDeleteLombokAnnotations()) return;
	ListBuffer<JCTree> newDefs = ListBuffer.lb();
	
	JCCompilationUnit unit = (JCCompilationUnit) node.top().get();
	
	for (JCTree def : unit.defs) {
		boolean delete = false;
		if (def instanceof JCImport) {
			JCImport imp0rt = (JCImport)def;
			delete = (!imp0rt.staticImport && imp0rt.qualid.toString().equals(name));
		}
		if (!delete) newDefs.append(def);
	}
	unit.defs = newDefs.toList();
}
 
开发者ID:redundent,项目名称:lombok,代码行数:18,代码来源:JavacHandlerUtil.java

示例6: hasStarImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
@Override public boolean hasStarImport(String packageName) {
	if (pkg != null && pkg.toString().equals(packageName)) return true;
	if ("java.lang".equals(packageName)) return true;
	
	for (JCTree def : defs) {
		if (!(def instanceof JCImport)) continue;
		if (((JCImport) def).staticImport) continue;
		JCTree qual = ((JCImport) def).qualid;
		if (!(qual instanceof JCFieldAccess)) continue;
		String simpleName = ((JCFieldAccess) qual).name.toString();
		if (!"*".equals(simpleName)) continue;
		if (packageName.equals(((JCFieldAccess) qual).selected.toString())) return true;
	}
	
	return false;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:17,代码来源:JavacImportList.java

示例7: importAll

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public void importAll(Types types, Scope origin,
                      ImportFilter filter,
                      JCImport imp,
                      BiConsumer<JCImport, CompletionFailure> cfHandler) {
    for (Scope existing : subScopes) {
        Assert.check(existing instanceof FilterImportScope);
        FilterImportScope fis = (FilterImportScope) existing;
        if (fis.origin == origin && fis.filter == filter &&
            fis.imp.staticImport == imp.staticImport)
            return ; //avoid entering the same scope twice
    }
    prependSubScope(new FilterImportScope(types, origin, null, filter, imp, cfHandler));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Scope.java

示例8: FilterImportScope

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public FilterImportScope(Types types,
                         Scope origin,
                         Name  filterName,
                         ImportFilter filter,
                         JCImport imp,
                         BiConsumer<JCImport, CompletionFailure> cfHandler) {
    super(origin.owner);
    this.types = types;
    this.origin = origin;
    this.filterName = filterName;
    this.filter = filter;
    this.imp = imp;
    this.cfHandler = cfHandler;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Scope.java

示例9: getFullyQualifiedNameForSimpleName

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
@Override public String getFullyQualifiedNameForSimpleName(String unqualified) {
	for (JCTree def : defs) {
		if (!(def instanceof JCImport)) continue;
		JCTree qual = ((JCImport) def).qualid;
		if (!(qual instanceof JCFieldAccess)) continue;
		String simpleName = ((JCFieldAccess) qual).name.toString();
		if (simpleName.equals(unqualified)) {
			return LombokInternalAliasing.processAliases(qual.toString());
		}
	}
	
	return null;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:JavacImportList.java

示例10: visitImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public void visitImport(JCImport that) {
    try {
        print("JCImport:");
    } catch (Exception e) {
    }
    super.visitImport(that);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:8,代码来源:PrintAstVisitor.java

示例11: printUnit

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
/** Print unit consisting of package clause and import statements in toplevel,
 *  followed by class definition. if class definition == null,
 *  print all definitions in toplevel.
 *  @param tree	 The toplevel tree
 *  @param cdef	 The class definition, which is assumed to be part of the
 *				  toplevel tree.
 */
public void printUnit(JCCompilationUnit tree, JCClassDecl cdef) throws IOException {
	Object dc = getDocComments(tree);
	loadDocCommentsTable(dc);
	printDocComment(tree);
	if (tree.pid != null) {
		consumeComments(tree.pos, tree);
		print("package ");
		printExpr(tree.pid);
		print(";");
		println();
	}
	boolean firstImport = true;
	for (List<JCTree> l = tree.defs;
	l.nonEmpty() && (cdef == null || IMPORT.equals(treeTag(l.head)));
	l = l.tail) {
		if (IMPORT.equals(treeTag(l.head))) {
			JCImport imp = (JCImport)l.head;
			Name name = TreeInfo.name(imp.qualid);
			if (name == name.table.fromChars(new char[] {'*'}, 0, 1) ||
					cdef == null ||
					isUsed(TreeInfo.symbol(imp.qualid), cdef)) {
				if (firstImport) {
					firstImport = false;
					println();
				}
				printStat(imp);
			}
		} else {
			printStat(l.head);
		}
	}
	if (cdef != null) {
		printStat(cdef);
		println();
	}
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:44,代码来源:PrettyCommentsPrinter.java

示例12: visitImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public void visitImport(JCImport tree) {
	try {
		print("import ");
		if (tree.staticImport) print("static ");
		printExpr(tree.qualid);
		print(";");
		println();
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:12,代码来源:PrettyCommentsPrinter.java

示例13: mergeImports

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
@SafeVarargs
private static List<JCImport> mergeImports(List<JCImport> mergedImports, List<JCImport>... importLists) {
    for (List<JCImport> imports : importLists) {
        for (JCImport imp : imports) {
            mergedImports = appendImport(mergedImports, imp);
        }
    }
    return mergedImports;
}
 
开发者ID:ixkor,项目名称:genaroid,代码行数:10,代码来源:GUnit.java

示例14: appendImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
private static List<JCImport> appendImport(List<JCImport> imports, JCImport addImport) {
    for (JCImport imp : imports) {
        if (imp.toString().equals(addImport.toString())) {
            return imports;
        }
    }
    return imports.append(addImport);
}
 
开发者ID:ixkor,项目名称:genaroid,代码行数:9,代码来源:GUnit.java

示例15: addNewImports

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public void addNewImports(String... imports) {
    TreeMaker maker = environment.getMaker();
    List<JCImport> newImports = List.nil();
    for (String newImport : imports) {
        newImports = newImports.append(maker.Import(environment.createParser(newImport).parseType(), false));
    }

    addNewImports(newImports);
}
 
开发者ID:ixkor,项目名称:genaroid,代码行数:10,代码来源:GUnit.java


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