Java Code Examples for com.sun.source.tree.CompilationUnitTree#getSourceFile()
The following examples show how to use
com.sun.source.tree.CompilationUnitTree#getSourceFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeConverter.java From j2objc with Apache License 2.0 | 5 votes |
public static CompilationUnit convertCompilationUnit( Options options, JavacEnvironment env, CompilationUnitTree javacUnit) { String sourceFilePath = getPath(javacUnit.getSourceFile()); try { TreeConverter converter = new TreeConverter(javacUnit, env); JavaFileObject sourceFile = javacUnit.getSourceFile(); String source = sourceFile.getCharContent(false).toString(); String mainTypeName = FileUtil.getMainTypeName(sourceFile); TranslationEnvironment translationEnv = new TranslationEnvironment(options, env); converter.newUnit = new CompilationUnit(translationEnv, sourceFilePath, mainTypeName, source); TreePath path = new TreePath(javacUnit); converter.newUnit.setPackage(converter.convertPackage(path)); for (Tree type : javacUnit.getTypeDecls()) { if (type.getKind() == Kind.IMPORT) { continue; } TreeNode newNode = converter.convert(type, path); if (newNode.getKind() != TreeNode.Kind.EMPTY_STATEMENT) { converter.newUnit.addType((AbstractTypeDeclaration) newNode); } } addOcniComments(converter.newUnit, options.jsniWarnings()); // Enable this to debug tree conversion issues, otherwise let // TranslationProcessor.applyMutations() handle verification. // converter.newUnit.validate(); return converter.newUnit; } catch (Throwable e) { ErrorUtil.fatalError(e, sourceFilePath); return null; } }
Example 2
Source File: JavacTrees.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Prints a message of the specified kind at the location of the * tree within the provided compilation unit * * @param kind the kind of message * @param msg the message, or an empty string if none * @param t the tree to use as a position hint * @param root the compilation unit that contains tree */ public void printMessage(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root) { JavaFileObject oldSource = null; JavaFileObject newSource = null; JCDiagnostic.DiagnosticPosition pos = null; newSource = root.getSourceFile(); if (newSource != null) { oldSource = log.useSource(newSource); pos = ((JCTree) t).pos(); } try { switch (kind) { case ERROR: boolean prev = log.multipleErrors; try { log.error(pos, "proc.messager", msg.toString()); } finally { log.multipleErrors = prev; } break; case WARNING: log.warning(pos, "proc.messager", msg.toString()); break; case MANDATORY_WARNING: log.mandatoryWarning(pos, "proc.messager", msg.toString()); break; default: log.note(pos, "proc.messager", msg.toString()); } } finally { if (oldSource != null) log.useSource(oldSource); } }
Example 3
Source File: TaskEvent.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 4
Source File: TaskEvent.java From javaide with GNU General Public License v3.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 5
Source File: TaskEvent.java From javaide with GNU General Public License v3.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 6
Source File: TaskEvent.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 7
Source File: TaskEvent.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 8
Source File: TaskEvent.java From hottub with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 9
Source File: TaskEvent.java From hottub with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 10
Source File: TaskEvent.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 11
Source File: TaskEvent.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 12
Source File: TaskEvent.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 13
Source File: TaskEvent.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 14
Source File: TaskEvent.java From JDKSourceCode1.8 with MIT License | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 15
Source File: TaskEvent.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 16
Source File: TaskEvent.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 17
Source File: TaskEvent.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 18
Source File: TaskEvent.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
Example 19
Source File: TaskEvent.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Creates a task event for a given kind and compilation unit. * The source file is set from the compilation unit, * and the type element is set to {@code null}. * @param kind the kind of the event * @param unit the compilation unit */ public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }
Example 20
Source File: TaskEvent.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Creates a task event for a given kind, compilation unit * and type element. * The source file is set from the compilation unit. * @param kind the kind of the event * @param unit the compilation unit * @param clazz the type element */ public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }