Tabnine Logo
JCTree$JCCompilationUnit
Code IndexAdd Tabnine to your IDE (free)

How to use
JCTree$JCCompilationUnit
in
com.sun.tools.javac.tree

Best Java code snippets using com.sun.tools.javac.tree.JCTree$JCCompilationUnit (Showing top 20 results out of 315)

origin: cincheo/jsweet

private void generateModuleDefs(JCCompilationUnit moduleDefs) throws IOException {
  StringBuilder out = new StringBuilder();
  for (String line : FileUtils.readLines(new File(moduleDefs.getSourceFile().getName()))) {
    if (line.startsWith("///")) {
      out.append(line.substring(3));
    }
  }
  FileUtils.write(new File(tsOutputDir, "module_defs.d.ts"), out, false);
}
origin: google/error-prone

private List<String> getAllImports(Inliner inliner) {
 List<String> allImports = new ArrayList<>(inliner.getImportsToAdd());
 if (inliner.getContext() != null
   && inliner.getContext().get(JCCompilationUnit.class) != null) {
  for (JCImport jcImport : inliner.getContext().get(JCCompilationUnit.class).getImports()) {
   JCFieldAccess qualified = (JCFieldAccess) jcImport.getQualifiedIdentifier();
   allImports.add(qualified.toString());
  }
 }
 return allImports;
}
origin: google/error-prone

private static String getFullyQualifiedName(JCCompilationUnit tree) {
 Iterator<JCClassDecl> types =
   Iterables.filter(tree.getTypeDecls(), JCClassDecl.class).iterator();
 if (types.hasNext()) {
  return Iterators.getOnlyElement(types).sym.getQualifiedName().toString();
 }
 // Fallback: if no class is declared, then assume we're looking at a `package-info.java`.
 return tree.getPackage().packge.package_info.toString();
}
origin: org.netbeans.api/org-netbeans-modules-java-source-base

additionalDiffs.addAll(CasualDiff.diff(getContext(), diffContext, getTreeUtilities(), diffContext.origUnit.getImports(), ncut.getImports(), userInfo, tree2Tag, tree2Doc, tag2Span, oldTrees));
origin: com.google.errorprone/error_prone_core

protected static Pretty pretty(Context context, final Writer writer) {
 final JCCompilationUnit unit = context.get(JCCompilationUnit.class);
 try {
  final String unitContents = unit.getSourceFile().getCharContent(false).toString();
  return new Pretty(writer, true) {
origin: com.google.errorprone/error_prone_check_api

JavaFileObject originalSource = log.useSource(compilation.getSourceFile());
try {
 if (shouldExcludeSourceFile(compilation.getSourceFile())) {
  return;
origin: io.teecube.t3/t3-common

JCClassDecl classDecl = (JCClassDecl) compilationUnit.getTypeDecls().get(0);
JavacTreeMaker treeMaker = annotationNode.getTreeMaker();
origin: com.google.errorprone/error_prone_check_api

JavaFileObject modifiedFile = compilationUnit.getSourceFile();
BasicJavacTask javacTask = (BasicJavacTask) state.context.get(JavacTask.class);
if (javacTask == null) {
origin: org.netbeans.api/org-netbeans-modules-java-source-base

TokenHierarchy<?> tokens =   unit.getSourceFile() instanceof AbstractSourceFileObject
              ? ((AbstractSourceFileObject) unit.getSourceFile()).getTokenHierarchy()
              : TokenHierarchy.create(unit.getSourceFile().getCharContent(true), JavaTokenId.language());
TokenSequence<JavaTokenId> seq = tokens.tokenSequence(JavaTokenId.language());
TreePath tp = TreePath.getPath(cut, original);
origin: com.google.errorprone/error_prone_core

String path = ASTHelpers.getFileNameFromUri(compilationUnit.getSourceFile().toUri());
if (Pattern.matches(restriction.allowedOnPath(), path)) {
 return Description.NO_MATCH;
origin: manifold-systems/manifold

JavaFileObject sourceFile = env.toplevel.getSourceFile();
if( sourceFile instanceof GeneratedJavaStubFileObject )
origin: com.cognifide.qa.bb/bb-annotations

compilationUnit.accept(new TreeTranslator() {
origin: konsoletyper/teavm-javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}
origin: org.netbeans.api/org-netbeans-modules-java-source-base

public void printImportsBlock(java.util.List<? extends JCTree> imports, boolean maybeAppendNewLine) {
  boolean hasImports = !imports.isEmpty();
  CodeStyle.ImportGroups importGroups = null;
  if (hasImports) {
    blankLines(Math.max(cs.getBlankLinesBeforeImports(), diffContext.origUnit.getPackageName() != null ? cs.getBlankLinesAfterPackage() : 0));
    if (cs.separateImportGroups())
      importGroups = cs.getImportGroups();
  }
  int lastGroup = -1;
  for (JCTree importStat : imports) {
    if (importGroups != null) {
      Name name = fullName(((JCImport)importStat).qualid);
      int group = name != null ? importGroups.getGroupId(name.toString(), ((JCImport)importStat).staticImport) : -1;
      if (lastGroup >= 0 && lastGroup != group)
        blankline();
      lastGroup = group;
    }
    printStat(importStat);
    newline();
  }
  if (hasImports && maybeAppendNewLine) {
    blankLines(cs.getBlankLinesAfterImports());
  }
}
origin: sc.fiji/javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}
origin: org.jvnet.sorcerer/sorcerer-javac

/**
 * Create given tree node at current position.
 * @param defs a list of ClassDef, Import, and Skip
 */
public JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations,
         JCExpression pid,
         List<JCTree> defs) {
  assert packageAnnotations != null;
  for (JCTree node : defs)
    assert node instanceof JCClassDecl
  || node instanceof JCImport
  || node instanceof JCSkip
      || node instanceof JCErroneous
  || (node instanceof JCExpressionStatement
    && ((JCExpressionStatement)node).expr instanceof JCErroneous)
       : node.getClass().getSimpleName();
  JCCompilationUnit tree = new JCCompilationUnit(packageAnnotations, pid, defs,
                 null, null, null, null);
  tree.pos = pos;
  return tree;
}
origin: org.kohsuke.sorcerer/sorcerer-javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}
origin: org.jvnet.sorcerer/sorcerer-javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}
origin: konsoletyper/teavm-javac

/**
 * Create given tree node at current position.
 * @param defs a list of ClassDef, Import, and Skip
 */
public JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations,
                 JCExpression pid,
                 List<JCTree> defs) {
  Assert.checkNonNull(packageAnnotations);
  for (JCTree node : defs)
    Assert.check(node instanceof JCClassDecl
      || node instanceof JCImport
      || node instanceof JCSkip
      || node instanceof JCErroneous
      || (node instanceof JCExpressionStatement
        && ((JCExpressionStatement)node).expr instanceof JCErroneous),
      node.getClass().getSimpleName());
  JCCompilationUnit tree = new JCCompilationUnit(packageAnnotations, pid, defs,
                 null, null, null, null);
  tree.pos = pos;
  return tree;
}
origin: sc.fiji/javac

/**
 * Create given tree node at current position.
 * @param defs a list of ClassDef, Import, and Skip
 */
public JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations,
                 JCExpression pid,
                 List<JCTree> defs) {
  assert packageAnnotations != null;
  for (JCTree node : defs)
    assert node instanceof JCClassDecl
      || node instanceof JCImport
      || node instanceof JCSkip
      || node instanceof JCErroneous
      || (node instanceof JCExpressionStatement
        && ((JCExpressionStatement)node).expr instanceof JCErroneous)
       : node.getClass().getSimpleName();
  JCCompilationUnit tree = new JCCompilationUnit(packageAnnotations, pid, defs,
                 null, null, null, null);
  tree.pos = pos;
  return tree;
}
com.sun.tools.javac.treeJCTree$JCCompilationUnit

Javadoc

Everything in one source file is kept in a JCCompilationUnit structure.

Most used methods

  • getSourceFile
  • <init>
  • getImports
  • getPackageName
  • getTypeDecls
  • accept
  • getPackage
  • pos

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • onRequestPermissionsResult (Fragment)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now