com.github.javaparser.ast.CompilationUnit.addImport()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中com.github.javaparser.ast.CompilationUnit.addImport()方法的一些代码示例,展示了CompilationUnit.addImport()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CompilationUnit.addImport()方法的具体详情如下:
包路径:com.github.javaparser.ast.CompilationUnit
类名称:CompilationUnit
方法名:addImport

CompilationUnit.addImport介绍

暂无

代码示例

代码示例来源:origin: JCTools/JCTools

private static void organiseImports(CompilationUnit cu) {
  List<ImportDeclaration> importDecls = new ArrayList<>();
  for (ImportDeclaration importDeclaration : cu.getImports()) {
    if (importDeclaration.getNameAsString().startsWith("org.jctools.util.Unsafe")) {
      continue;
    }
    importDecls.add(importDeclaration);
  }
  cu.getImports().clear();
  for (ImportDeclaration importDecl : importDecls) {
    cu.addImport(importDecl);
  }
  cu.addImport(importDeclaration("java.util.concurrent.atomic.AtomicLongFieldUpdater"));
  cu.addImport(importDeclaration("java.util.concurrent.atomic.AtomicReferenceArray"));
  cu.addImport(importDeclaration("java.util.concurrent.atomic.AtomicLongArray"));
}

代码示例来源:origin: JCTools/JCTools

cu.addImport(importDecl);
cu.addImport(importDeclaration("java.util.concurrent.atomic.AtomicReferenceFieldUpdater"));
cu.addImport(importDeclaration("java.util.concurrent.atomic.AtomicLongFieldUpdater"));
cu.addImport(importDeclaration("org.jctools.queues.MessagePassingQueue"));
cu.addImport(importDeclaration("org.jctools.queues.MessagePassingQueue.Supplier"));
cu.addImport(importDeclaration("org.jctools.queues.MessagePassingQueueUtil"));
cu.addImport(importDeclaration("org.jctools.queues.QueueProgressIndicators"));
cu.addImport(importDeclaration("org.jctools.queues.IndexedQueueSizeUtil"));
cu.addImport(staticImportDeclaration("org.jctools.queues.atomic.LinkedAtomicArrayQueueUtil.*"));
cu.addImport(importDeclaration("java.util.concurrent.atomic.AtomicReferenceArray"));
cu.addImport(importDeclaration("org.jctools.queues.MpmcArrayQueue"));

代码示例来源:origin: com.reprezen.jsonoverlay/jsonoverlay

public String format() {
  CompilationUnit cu = new CompilationUnit();
  if (fileComment != null) {
    cu.addOrphanComment(new JavadocComment(fileComment));
  }
  cu.setPackageDeclaration(pkg);
  for (String imp : imports) {
    cu.addImport(imp);
  }
  cu.addType(type);
  for (Member member : gatherFinalMembers(members, cu)) {
    type.addMember(member.getDeclaration());
  }
  return cu.toString();
}

代码示例来源:origin: ftomassetti/analyze-java-code-examples

compilationUnit.addImport("java.util", false, true);

相关文章