Example usage for org.eclipse.jdt.core JavaCore COMPILER_DOC_COMMENT_SUPPORT

List of usage examples for org.eclipse.jdt.core JavaCore COMPILER_DOC_COMMENT_SUPPORT

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore COMPILER_DOC_COMMENT_SUPPORT.

Prototype

String COMPILER_DOC_COMMENT_SUPPORT

To view the source code for org.eclipse.jdt.core JavaCore COMPILER_DOC_COMMENT_SUPPORT.

Click Source Link

Document

Compiler option ID: Javadoc Comment Support.

Usage

From source file:at.bestsolution.fxide.jdt.editor.JDTJavaDocSupport.java

License:Open Source License

private static CompilationUnit createAST(IJavaElement element, String cuSource) {
    ASTParser parser = ASTParser.newParser(AST.JLS8);

    IJavaProject javaProject = element.getJavaProject();
    parser.setProject(javaProject);/*  w  w w .j av a2s.c  o m*/
    Map<String, String> options = javaProject.getOptions(true);
    options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); // workaround
    // for
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207
    parser.setCompilerOptions(options);

    parser.setSource(cuSource.toCharArray());
    return (CompilationUnit) parser.createAST(null);
}

From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java

License:Open Source License

private static CompilationUnit createAST(IJavaElement element, String cuSource) {
    Assert.isNotNull(element);/* w w  w  .ja  va 2s .  c o  m*/
    ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);

    IJavaProject javaProject = element.getJavaProject();
    parser.setProject(javaProject);
    Map<String, String> options = javaProject.getOptions(true);
    options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207
    parser.setCompilerOptions(options);

    parser.setSource(cuSource.toCharArray());
    return (CompilationUnit) parser.createAST(null);
}

From source file:chibi.gumtreediff.gen.jdt.AbstractJdtTreeGenerator.java

License:Open Source License

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public TreeContext generate(Reader r) throws IOException {
    ASTParser parser = ASTParser.newParser(AST.JLS8);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    Map pOptions = JavaCore.getOptions();
    pOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
    pOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
    pOptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
    pOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
    parser.setCompilerOptions(pOptions);
    parser.setSource(readerToCharArray(r));
    AbstractJdtVisitor v = createVisitor();
    CompilationUnit c = (CompilationUnit) parser.createAST(null);
    v.setTreeRoot(c);/* w  ww. j  av  a  2s  . c  om*/
    c.accept(v);
    return v.getTreeContext();
}

From source file:com.codenvy.ide.ext.java.BaseTest.java

License:Open Source License

public BaseTest() {
    options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
    options.put(JavaCore.CORE_ENCODING, "UTF-8");
    options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);
    options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_7);
    options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED);
    options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
    options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING);
    options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
    options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED);
    options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX");
    options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED);
    options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
    options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.DISABLED);
}

From source file:com.codenvy.ide.ext.java.server.javadoc.JavadocContentAccess2.java

License:Open Source License

private static CompilationUnit createAST(IJavaElement element, String cuSource) {
    Assert.isNotNull(element);/*w w w.j  a  v a  2 s  . c  o m*/
    ASTParser parser = ASTParser.newParser(AST.JLS8);

    IJavaProject javaProject = element.getJavaProject();
    parser.setProject(javaProject);
    Map<String, String> options = javaProject.getOptions(true);
    options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207
    parser.setCompilerOptions(options);

    parser.setSource(cuSource.toCharArray());
    return (CompilationUnit) parser.createAST(null);
}

From source file:com.google.dart.java2dart.Context.java

License:Open Source License

/**
 * @return the Java AST of the given Java {@link File} in context of {@link #sourceFolders}.
 *///from   ww  w  . j  a v  a2s . co  m
private Map<File, CompilationUnit> parseJavaFiles(final List<File> javaFiles) throws Exception {
    String paths[] = new String[javaFiles.size()];
    final Map<String, File> pathToFile = Maps.newHashMap();
    for (int i = 0; i < javaFiles.size(); i++) {
        File javaFile = javaFiles.get(i);
        String javaPath = javaFile.getAbsolutePath();
        paths[i] = javaPath;
        pathToFile.put(javaPath, javaFile);
    }
    // prepare Java parser
    ASTParser parser = ASTParser.newParser(AST.JLS4);
    {
        String[] classpathEntries = new String[classpathFiles.size()];
        for (int i = 0; i < classpathFiles.size(); i++) {
            classpathEntries[i] = classpathFiles.get(i).getAbsolutePath();
        }
        String[] sourceEntries = new String[sourceFolders.size()];
        for (int i = 0; i < sourceFolders.size(); i++) {
            sourceEntries[i] = sourceFolders.get(i).getAbsolutePath();
        }
        parser.setEnvironment(classpathEntries, sourceEntries, null, true);
    }
    parser.setResolveBindings(true);
    parser.setCompilerOptions(ImmutableMap.of(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5,
            JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED));
    // do parse
    final Map<File, CompilationUnit> units = Maps.newLinkedHashMap();
    parser.createASTs(paths, null, ArrayUtils.EMPTY_STRING_ARRAY, new FileASTRequestor() {
        @Override
        public void acceptAST(String sourceFilePath, org.eclipse.jdt.core.dom.CompilationUnit javaUnit) {
            File astFile = pathToFile.get(sourceFilePath);
            CompilationUnit dartUnit = SyntaxTranslator.translate(Context.this, javaUnit);
            units.put(astFile, dartUnit);
        }
    }, null);
    return units;
}

From source file:com.google.dart.java2dart.SyntaxTranslatorTest.java

License:Open Source License

/**
 * Parse Java source lines into {@link #javaUnit}.
 *///from   ww w.  j ava 2 s. c  o  m
private void parseJava(String... lines) {
    String source = Joiner.on("\n").join(lines);
    ASTParser parser = ASTParser.newParser(AST.JLS4);
    parser.setCompilerOptions(ImmutableMap.of(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5,
            JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED));
    parser.setSource(source.toCharArray());
    javaUnit = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
    assertThat(javaUnit.getProblems()).isEmpty();
}

From source file:com.kodebeagle.javaparser.JavaASTParser.java

License:Apache License

/**
 * Return an ASTNode given the content//from   w w  w.j  a va  2 s  .co  m
 *
 * @param content
 * @return
 */
public final ASTNode getASTNode(final char[] content, final ParseType parseType) {
    final ASTParser parser = ASTParser.newParser(AST.JLS8);
    final int astKind;
    switch (parseType) {
    case CLASS_BODY:
    case METHOD:
        astKind = ASTParser.K_CLASS_BODY_DECLARATIONS;
        break;
    case COMPILATION_UNIT:
        astKind = ASTParser.K_COMPILATION_UNIT;
        break;
    case EXPRESSION:
        astKind = ASTParser.K_EXPRESSION;
        break;
    case STATEMENTS:
        astKind = ASTParser.K_STATEMENTS;
        break;
    default:
        astKind = ASTParser.K_COMPILATION_UNIT;
    }
    parser.setKind(astKind);

    final Map<String, String> options = new Hashtable<String, String>();
    options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
    options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
    if (useJavadocs) {
        options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
    }
    parser.setCompilerOptions(options);
    parser.setSource(content);
    parser.setResolveBindings(useBindings);
    parser.setBindingsRecovery(useBindings);
    parser.setStatementsRecovery(true);

    if (parseType != ParseType.METHOD) {
        return parser.createAST(null);
    } else {
        final ASTNode cu = parser.createAST(null);
        return getFirstMethodDeclaration(cu);
    }
}

From source file:net.sf.j2s.core.builder.AbstractImageBuilder.java

License:Open Source License

protected Compiler newCompiler() {
    // disable entire javadoc support if not interested in diagnostics
    Map projectOptions = this.javaBuilder.javaProject.getOptions(true);
    String option = (String) projectOptions.get(JavaCore.COMPILER_PB_INVALID_JAVADOC);
    if (option == null || option.equals(JavaCore.IGNORE)) { // TODO (frederic) see why option is null sometimes while running model tests!?
        option = (String) projectOptions.get(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS);
        if (option == null || option.equals(JavaCore.IGNORE)) {
            option = (String) projectOptions.get(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS);
            if (option == null || option.equals(JavaCore.IGNORE)) {
                option = (String) projectOptions.get(JavaCore.COMPILER_PB_UNUSED_IMPORT);
                if (option == null || option.equals(JavaCore.IGNORE)) { // Unused import need also to look inside javadoc comment
                    projectOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED);
                }/*www  .  ja v  a  2s. co  m*/
            }
        }
    }

    // called once when the builder is initialized... can override if needed
    CompilerOptions compilerOptions = new CompilerOptions(projectOptions);
    compilerOptions.performMethodsFullRecovery = true;
    compilerOptions.performStatementsRecovery = true;
    Compiler newCompiler = new Compiler(this.nameEnvironment,
            DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, this,
            ProblemFactory.getProblemFactory(Locale.getDefault()));
    CompilerOptions options = newCompiler.options;
    // temporary code to allow the compiler to revert to a single thread
    String setting = System.getProperty("jdt.compiler.useSingleThread"); //$NON-NLS-1$
    newCompiler.useSingleThread = setting != null && setting.equals("true"); //$NON-NLS-1$

    // enable the compiler reference info support
    options.produceReferenceInfo = true;

    if (options.complianceLevel >= ClassFileConstants.JDK1_6 && options.processAnnotations) {
        // support for Java 6 annotation processors
        initializeAnnotationProcessorManager(newCompiler);
    }

    return newCompiler;
}

From source file:net.sf.j2s.core.builder.Java2ScriptBatchImageBuilder.java

License:Open Source License

protected Compiler newCompiler() {
    // disable entire javadoc support if not interested in diagnostics
    Map projectOptions = javaBuilder.javaProject.getOptions(true);
    String option = (String) projectOptions.get(JavaCore.COMPILER_PB_INVALID_JAVADOC);
    if (option == null || option.equals(JavaCore.IGNORE)) { // TODO (frederic) see why option is null sometimes while running model tests!?
        option = (String) projectOptions.get(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS);
        if (option == null || option.equals(JavaCore.IGNORE)) {
            option = (String) projectOptions.get(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS);
            if (option == null || option.equals(JavaCore.IGNORE)) {
                option = (String) projectOptions.get(JavaCore.COMPILER_PB_UNUSED_IMPORT);
                if (option == null || option.equals(JavaCore.IGNORE)) { // Unused import need also to look inside javadoc comment
                    projectOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED);
                }/*from  w w w.j a v  a 2 s  .c om*/
            }
        }
    }

    // called once when the builder is initialized... can override if needed
    CompilerOptions compilerOptions = new CompilerOptions(projectOptions);
    compilerOptions.performMethodsFullRecovery = true;
    compilerOptions.performStatementsRecovery = true;
    Compiler newCompiler = new Java2ScriptImageCompiler(nameEnvironment,
            DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, this,
            ProblemFactory.getProblemFactory(Locale.getDefault()));
    CompilerOptions options = newCompiler.options;
    // temporary code to allow the compiler to revert to a single thread
    String setting = System.getProperty("jdt.compiler.useSingleThread"); //$NON-NLS-1$
    newCompiler.useSingleThread = setting != null && setting.equals("true"); //$NON-NLS-1$

    // enable the compiler reference info support
    options.produceReferenceInfo = true;

    if (options.complianceLevel >= ClassFileConstants.JDK1_6 && options.processAnnotations) {
        // support for Java 6 annotation processors
        initializeAnnotationProcessorManager(newCompiler);
    }

    return newCompiler;
}