com.sun.tools.javac.api.JavacTrees Java Examples
The following examples show how to use
com.sun.tools.javac.api.JavacTrees.
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: ManTypes.java From manifold with Apache License 2.0 | 6 votes |
private void reassignEarlyHolders8( Context context ) { ReflectUtil.field( Annotate.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Attr.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Check.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( DeferredAttr.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Flow.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Gen.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Infer.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavaCompiler.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacTrees.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacTypes.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacElements.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( LambdaToMethod.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Lower.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ManResolve.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( MemberEnter.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( RichDiagnosticFormatter.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( TransTypes.instance( context ), TYPES_FIELD ).set( this ); }
Example #2
Source File: ModuleInfoTreeAccess.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testTreePathForModuleDeclWithImport(Path base) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) { Path src = base.resolve("src"); tb.writeJavaFiles(src, "import java.lang.Deprecated; /** Test module */ @Deprecated module m1x {}"); Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src)); JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files); task.analyze(); JavacTrees trees = JavacTrees.instance(task); ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1x"); TreePath path = trees.getPath(mdle); assertNotNull("path", path); ModuleElement mdle1 = (ModuleElement) trees.getElement(path); assertNotNull("mdle1", mdle1); DocCommentTree docCommentTree = trees.getDocCommentTree(mdle); assertNotNull("docCommentTree", docCommentTree); } }
Example #3
Source File: ModuleInfoTreeAccess.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testTreePathForModuleDecl(Path base) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) { Path src = base.resolve("src"); tb.writeJavaFiles(src, "/** Test module */ module m1x {}"); Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src)); JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files); task.analyze(); JavacTrees trees = JavacTrees.instance(task); ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1x"); TreePath path = trees.getPath(mdle); assertNotNull("path", path); ModuleElement mdle1 = (ModuleElement) trees.getElement(path); assertNotNull("mdle1", mdle1); DocCommentTree docCommentTree = trees.getDocCommentTree(mdle); assertNotNull("docCommentTree", docCommentTree); } }
Example #4
Source File: TestContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #5
Source File: InferenceRegressionTest02.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context context = new Context(); JavacFileManager.preRegister(context); Trees trees = JavacTrees.instance(context); StringWriter strOut = new StringWriter(); PrintWriter pw = new PrintWriter(strOut); DPrinter dprinter = new DPrinter(pw, trees); final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, Arrays.asList(new JavaSource())); Iterable<? extends CompilationUnitTree> elements = ct.parse(); ct.analyze(); Assert.check(elements.iterator().hasNext()); dprinter.treeTypes(true).printTree("", (JCTree)elements.iterator().next()); String output = strOut.toString(); Assert.check(!output.contains("java.lang.Object"), "there shouldn't be any type instantiated to Object"); }
Example #6
Source File: ToolEnvironment.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Constructor * * @param context Context for this javadoc instance. */ protected ToolEnvironment(Context context) { context.put(ToolEnvKey, this); this.context = context; messager = Messager.instance0(context); syms = Symtab.instance(context); finder = JavadocClassFinder.instance(context); enter = JavadocEnter.instance(context); names = Names.instance(context); externalizableSym = syms.enterClass(syms.java_base, names.fromString("java.io.Externalizable")); chk = Check.instance(context); types = com.sun.tools.javac.code.Types.instance(context); fileManager = context.get(JavaFileManager.class); if (fileManager instanceof JavacFileManager) { ((JavacFileManager)fileManager).setSymbolFileEnabled(false); } docTrees = JavacTrees.instance(context); source = Source.instance(context); elements = JavacElements.instance(context); typeutils = JavacTypes.instance(context); elementToTreePath = new HashMap<>(); }
Example #7
Source File: ManResolve.java From manifold with Apache License 2.0 | 6 votes |
private void reassignEarlyHolders( Context context ) { ReflectUtil.field( _attr, RESOLVE_FIELD ).set( this ); ReflectUtil.field( DeferredAttr.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Check.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Infer.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Flow.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( LambdaToMethod.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Lower.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Gen.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.jvm.StringConcat" ), "instance", Context.class ) .invokeStatic( context ), RESOLVE_FIELD ) .set( this ); ReflectUtil.field( JavacTrees.instance( context ), "resolve" ).set( this ); ReflectUtil.field( Annotate.instance( context ), "resolve" ).set( this ); ReflectUtil.field( TransTypes.instance( context ), "resolve" ).set( this ); ReflectUtil.field( JavacElements.instance( context ), "resolve" ).set( this ); }
Example #8
Source File: TestContext.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #9
Source File: CompilationInfo.java From netbeans with Apache License 2.0 | 6 votes |
/** * Return the {@link Trees} service of the javac represented by this {@link CompilationInfo}. * @return javac Trees service */ public synchronized @NonNull Trees getTrees() { checkConfinement(); if (trees == null) { //use a working init order: com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext()); trees = JavacTrees.instance(impl.getJavacTask().getContext()); Snapshot snapshot = impl.getSnapshot(); Document doc = snapshot != null ? snapshot.getSource().getDocument(false) : null; WrapperFactory factory = doc != null ? (WrapperFactory)doc.getProperty(WrapperFactory.class) : null; if (factory != null) { trees = factory.wrapTrees(trees); } } return trees; }
Example #10
Source File: VeryPretty.java From netbeans with Apache License 2.0 | 6 votes |
private void adjustSpans(Iterable<? extends Tree> original, String code) { if (tree2Tag == null) { return; //nothing to copy } java.util.List<Tree> linearized = new LinkedList<Tree>(); if (!new Linearize().scan(original, linearized) != Boolean.TRUE) { return; //nothing to copy } ClassPath empty = ClassPathSupport.createClassPath(new URL[0]); ClasspathInfo cpInfo = ClasspathInfo.create(JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(), empty, empty); JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, Arrays.asList(FileObjects.memoryFileObject("", "Scratch.java", code))); com.sun.tools.javac.util.Context ctx = javacTask.getContext(); JavaCompiler.instance(ctx).genEndPos = true; CompilationUnitTree tree = javacTask.parse().iterator().next(); //NOI18N SourcePositions sp = JavacTrees.instance(ctx).getSourcePositions(); ClassTree clazz = (ClassTree) tree.getTypeDecls().get(0); new CopyTags(tree, sp).scan(clazz.getModifiers().getAnnotations(), linearized); }
Example #11
Source File: TestContext.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #12
Source File: TestContext.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #13
Source File: TestContext.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #14
Source File: TestContext.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #15
Source File: TestContext.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #16
Source File: TestContext.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { round++; JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv; Context c = jpe.getContext(); check(c.get(JavacElements.class), eltUtils); check(c.get(JavacTypes.class), typeUtils); check(c.get(JavacTrees.class), treeUtils); final int MAXROUNDS = 3; if (round < MAXROUNDS) generateSource("Gen" + round); return true; }
Example #17
Source File: ManTypes.java From manifold with Apache License 2.0 | 5 votes |
private void reassignEarlyHolders( Context context ) { ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.Analyzer" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Annotate.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Attr.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Check.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( DeferredAttr.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Flow.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Gen.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Infer.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavaCompiler.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacElements.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacProcessingEnvironment.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacTrees.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacTypes.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( LambdaToMethod.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Lower.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ManResolve.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( MemberEnter.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.Modules" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.Operators" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); //noinspection ConstantConditions ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.jvm.StringConcat" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( RichDiagnosticFormatter.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( TransTypes.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.TypeEnter" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( TreeMaker.instance( context ), TYPES_FIELD ).set( this ); }
Example #18
Source File: RemoveUnusedImports.java From google-java-format with Apache License 2.0 | 5 votes |
public static String removeUnusedImports(final String contents) throws FormatterException { Context context = new Context(); JCCompilationUnit unit = parse(context, contents); if (unit == null) { // error handling is done during formatting return contents; } UnusedImportScanner scanner = new UnusedImportScanner(JavacTrees.instance(context)); scanner.scan(unit, null); return applyReplacements( contents, buildReplacements(contents, unit, scanner.usedNames, scanner.usedInJavadoc)); }
Example #19
Source File: ClassSymbols.java From manifold with Apache License 2.0 | 5 votes |
private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbolForProducedClass( String fqn, BasicJavacTask[] task ) { StringWriter errors = new StringWriter(); // need javac with ManifoldJavaFileManager because the produced class must come from manifold task[0] = getJavacTask_ManFileMgr(); Symbol.ClassSymbol e = IDynamicJdk.instance().getTypeElement( task[0].getContext(), null, fqn ); if( e != null && e.getSimpleName().contentEquals( ManClassUtil.getShortClassName( fqn ) ) ) { JavacTrees trees = JavacTrees.instance( task[0].getContext() ); TreePath path = trees.getPath( e ); if( path != null ) { return new Pair<>( e, (JCTree.JCCompilationUnit)path.getCompilationUnit() ); } else { // TreePath is only applicable to a source file; // if fqn is not a source file, there is no compilation unit available return new Pair<>( e, null ); } } StringBuffer errorText = errors.getBuffer(); if( errorText.length() > 0 ) { throw new RuntimeException( "Compile errors:\n" + errorText ); } return null; }
Example #20
Source File: ClassSymbols.java From manifold with Apache License 2.0 | 5 votes |
private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbol( Context ctx, Object moduleCtx, String fqn ) { Symbol.ClassSymbol typeElement = IDynamicJdk.instance().getTypeElement( ctx, moduleCtx, fqn ); if( typeElement == null ) { // For the case where the class is generated from a type manifold esp. from a IExtensionClassProducer return getClassSymbolForProducedClass( fqn, new BasicJavacTask[1] ); //## want this instead, but the typeElement is not complete in this case, investigate this // if( JavacPlugin.instance() != null ) // { // typeElement = IDynamicJdk.instance().getTypeElement( JavacPlugin.instance().getContext(), moduleCtx, fqn ); // typeElement.complete(); // } } JavacTrees trees = JavacTrees.instance( ctx ); TreePath path = trees.getPath( typeElement ); if( path != null ) { return new Pair<>( typeElement, (JCTree.JCCompilationUnit)path.getCompilationUnit() ); } else { // TreePath is only applicable to a source file; // if fqn is not a source file, there is no compilation unit available return new Pair<>( typeElement, null ); } }
Example #21
Source File: ManResolve.java From manifold with Apache License 2.0 | 5 votes |
private void reassignEarlyHolders8( Context context ) { ReflectUtil.field( Attr.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( DeferredAttr.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Check.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Infer.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Flow.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Lower.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Gen.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( Annotate.instance( context ), RESOLVE_FIELD ).set( this ); ReflectUtil.field( JavacTrees.instance( context ), "resolve" ).set( this ); ReflectUtil.field( TransTypes.instance( context ), "resolve" ).set( this ); }
Example #22
Source File: DependenciesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void runTest(Stream<Path> inputs) { JavacTool tool = JavacTool.create(); try (JavacFileManager fm = tool.getStandardFileManager(null, null, null)) { Path classes = Paths.get(System.getProperty("test.classes")); Iterable<? extends JavaFileObject> reconFiles = fm.getJavaFileObjectsFromFiles(inputs.sorted().map(p -> p.toFile()) :: iterator); List<String> options = Arrays.asList("-classpath", classes.toAbsolutePath().toString()); JavacTask reconTask = tool.getTask(null, fm, null, options, null, reconFiles); Iterable<? extends CompilationUnitTree> reconUnits = reconTask.parse(); JavacTrees reconTrees = JavacTrees.instance(reconTask); SearchAnnotations scanner = new SearchAnnotations(reconTrees, reconTask.getElements()); List<JavaFileObject> validateFiles = new ArrayList<>(); reconTask.analyze(); scanner.scan(reconUnits, null); for (CompilationUnitTree cut : reconUnits) { validateFiles.add(ClearAnnotations.clearAnnotations(reconTrees, cut)); } Context validateContext = new Context(); TestDependencies.preRegister(validateContext); JavacTask validateTask = tool.getTask(null, fm, null, options, null, validateFiles, validateContext); validateTask.analyze(); TestDependencies deps = (TestDependencies) Dependencies.instance(validateContext); if (!scanner.topLevel2Expected.equals(deps.topLevel2Completing)) { throw new IllegalStateException( "expected=" + scanner.topLevel2Expected + "; actual=" + deps.topLevel2Completing); } } catch (IOException ex) { throw new IllegalStateException(ex); } finally { inputs.close(); } }
Example #23
Source File: GenerateGetMethodProcessor.java From java-master with Apache License 2.0 | 5 votes |
@Override public synchronized void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); this.processingEnv = processingEnv; this.elementUtils = processingEnv.getElementUtils(); this.typeUtils = processingEnv.getTypeUtils(); this.filer = processingEnv.getFiler(); this.trees = JavacTrees.instance(processingEnv); Context context = ((JavacProcessingEnvironment) processingEnv).getContext(); this.treeMaker = TreeMaker.instance(context); this.names = Names.instance(context); }
Example #24
Source File: Messager.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private String getDiagSource(DocTreePath path) { if (path == null || path.getTreePath() == null) { return programName; } JavacTrees trees = JavacTrees.instance(context); DocSourcePositions sourcePositions = trees.getSourcePositions(); CompilationUnitTree cu = path.getTreePath().getCompilationUnit(); long spos = sourcePositions.getStartPosition(cu, path.getDocComment(), path.getLeaf()); long lineNumber = cu.getLineMap().getLineNumber(spos); String fname = cu.getSourceFile().getName(); String posString = fname + ":" + lineNumber; return posString; }
Example #25
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Create a tree maker with NOPOS as initial position. */ protected DocTreeMaker(Context context) { context.put(treeMakerKey, this); diags = JCDiagnostic.Factory.instance(context); this.pos = Position.NOPOS; trees = JavacTrees.instance(context); referenceParser = new ReferenceParser(ParserFactory.instance(context)); sentenceBreakTags = EnumSet.of(H1, H2, H3, H4, H5, H6, PRE, P); }
Example #26
Source File: JavaParsingContext.java From netbeans with Apache License 2.0 | 5 votes |
@NonNull private Lookup getPluginServices(final JavacTaskImpl jt) { return Lookups.fixed( jt.getElements(), jt.getTypes(), JavacTrees.instance(jt.getContext()), JavaSourceAccessor.getINSTANCE().createElementUtilities(jt)); }
Example #27
Source File: NBJavacTrees.java From netbeans with Apache License 2.0 | 5 votes |
public static void preRegister(Context context) { context.put(JavacTrees.class, new Context.Factory<JavacTrees>() { public JavacTrees make(Context c) { return new NBJavacTrees(c); } }); }
Example #28
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** Create a tree maker with NOPOS as initial position. */ protected DocTreeMaker(Context context) { context.put(treeMakerKey, this); diags = JCDiagnostic.Factory.instance(context); this.pos = Position.NOPOS; trees = JavacTrees.instance(context); referenceParser = new ReferenceParser(ParserFactory.instance(context)); sentenceBreakTags = EnumSet.of(H1, H2, H3, H4, H5, H6, PRE, P); }
Example #29
Source File: Messager.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private String getDiagSource(Element e) { if (e == null) { return programName; } JavacTrees trees = JavacTrees.instance(context); TreePath path = trees.getPath(e); DocSourcePositions sourcePositions = trees.getSourcePositions(); JCTree tree = trees.getTree(e); CompilationUnitTree cu = path.getCompilationUnit(); long spos = sourcePositions.getStartPosition(cu, tree); long lineNumber = cu.getLineMap().getLineNumber(spos); String fname = cu.getSourceFile().getName(); String posString = fname + ":" + lineNumber; return posString; }
Example #30
Source File: JavadocClassFinder.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public JavadocClassFinder(Context context) { super(context); toolEnv = ToolEnvironment.instance(context); preferSource = true; trees = JavacTrees.instance(context); }