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

Java JCImport类代码示例

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

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



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


示例16: ImportStatements

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
public ImportStatements(JCExpression packageTree, List<JCImport> importTrees,
    ErrorProneEndPosMap endPosMap) {
  
  // find start, end positions for current list of imports (for replacement)
  if (importTrees.isEmpty()) {
    // start/end positions are just after the package expression
    hasExistingImports = false;
    startPos = endPosMap.getEndPosition(packageTree) + 2;   // +2 for semicolon and newline
    endPos = startPos;
  } else {
    // process list of imports and find start/end positions
    hasExistingImports = true;
    for (JCImport importTree : importTrees) {
      int currStartPos = importTree.getStartPosition();
      int currEndPos = endPosMap.getEndPosition(importTree);
      
      startPos = Math.min(startPos, currStartPos);
      endPos = Math.max(endPos, currEndPos);
    }  
  }
  
  // sanity check for start/end positions
  Preconditions.checkState(startPos <= endPos);
  
  // convert list of JCImports to list of strings
  importStrings = new TreeSet<>(IMPORT_ORDERING);
  importStrings.addAll(Lists.transform(importTrees, new Function<JCImport, String>() {
    @Override
    public String apply(JCImport input) {
      String importExpr = input.toString();
      return importExpr.substring(0, importExpr.length() - 2); // snip trailing ";\n"
    }
  }));
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:35,代码来源:ImportStatements.java


示例17: emptyImportListShouldGivePositionOfPackageStmt

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
/**
 * Test empty initial import list. Positions should match package end
 * positions.
 */
@Test
public void emptyImportListShouldGivePositionOfPackageStmt() {
  ImportStatements imports = new ImportStatements(
      basePackage, new ArrayList<JCImport>(), FAKE_END_POS_MAP);
  assertEquals(81, imports.getStartPos());
  assertEquals(81, imports.getEndPos());
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:12,代码来源:ImportStatementsTest.java


示例18: addingToEmptyImportListOutputShouldStartAndEndWithNewlines

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
/**
 * Test empty initial import list. The output string should start and
 * end with newlines because it is intended to be inserted after the
 * package statement.
 */
@Test
public void addingToEmptyImportListOutputShouldStartAndEndWithNewlines() {
  ImportStatements imports = new ImportStatements(
      basePackage, new ArrayList<JCImport>(), FAKE_END_POS_MAP);
  imports.add("import org.joda.time.Interval");
  assertEquals("\n"
      + "import org.joda.time.Interval;\n",
      imports.toString());
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:15,代码来源:ImportStatementsTest.java


示例19: visitImport

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
@Override public void visitImport(JCImport node) {
	ImportDeclaration imp = new ImportDeclaration();
	fillWithIdentifiers(node.getQualifiedIdentifier(), imp.astParts());
	Identifier last = imp.astParts().last();
	if (last != null && "*".equals(last.astValue())) {
		imp.astParts().remove(last);
		imp.astStarImport(true);
		setConversionPositionInfo(imp, ".*", last.getPosition());
	}
	imp.astStaticImport(node.isStatic());
	set(node, imp);
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:13,代码来源:JcTreeConverter.java


示例20: emptyImportListShouldGivePositionOfPackageStmt

import com.sun.tools.javac.tree.JCTree.JCImport; //导入依赖的package包/类
/** Test empty initial import list. Positions should match package end positions. */
@Test
public void emptyImportListShouldGivePositionOfPackageStmt() {
  ImportStatements imports = createImportStatements(basePackage, new ArrayList<JCImport>());
  assertEquals(81, imports.getStartPos());
  assertEquals(81, imports.getEndPos());
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:ImportStatementsTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java PlayerList类代码示例发布时间:2022-05-21
下一篇:
Java VCFHeaderLineType类代码示例发布时间: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