Exemplo n.º 1
0
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=157170
 public void test0017() {
   CompilerOptions options = new CompilerOptions();
   options.complianceLevel = ClassFileConstants.JDK1_5;
   options.sourceLevel = ClassFileConstants.JDK1_5;
   options.targetJDK = ClassFileConstants.JDK1_5;
   this.runConformTest(
       "X.java",
       "@interface Annot {\n"
           + "	int value() default 0;\n"
           + "}\n"
           + "@Annot\n"
           + "@Annot(3)\n"
           + "@Annot(value=4)\n"
           + "public class X {\n"
           + "}\n",
       new Parser(
           new ProblemReporter(
               DefaultErrorHandlingPolicies.proceedWithAllProblems(),
               options,
               new DefaultProblemFactory()),
           false),
       new AnnotationCollector(),
       "marker annotation start visit\n"
           + "marker annotation end visit\n"
           + "single member annotation start visit\n"
           + "3\n"
           + "single member annotation end visit\n"
           + "normal annotation start visit\n"
           + "member value pair start visit\n"
           + "value, 4\n"
           + "member value pair end visit\n"
           + "normal annotation end visit\n");
 }
Exemplo n.º 2
0
 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=157170
 public void test0019() {
   CompilerOptions options = new CompilerOptions();
   options.complianceLevel = ClassFileConstants.JDK1_5;
   options.sourceLevel = ClassFileConstants.JDK1_5;
   options.targetJDK = ClassFileConstants.JDK1_5;
   options.docCommentSupport = true;
   this.runConformTest(
       "X.java",
       "@interface Annot {\n"
           + "	int value() default 0;\n"
           + "}\n"
           + "/**\n"
           + " * @see Annot\n"
           + " */\n"
           + "@Annot\n"
           + "@Annot(3)\n"
           + "@Annot(value=4)\n"
           + "public class X {\n"
           + "	/**\n"
           + "	 * @see Annot\n"
           + "	 */\n"
           + "	public void foo(@Annot int i) {\n"
           + "		@Annot int j = 0;"
           + "	}\n"
           + "}\n",
       new Parser(
           new ProblemReporter(
               DefaultErrorHandlingPolicies.proceedWithAllProblems(),
               options,
               new DefaultProblemFactory()),
           false),
       new AnnotationCollector(),
       "java doc single type reference start visit\n"
           + "java doc single type reference end visit\n"
           + "marker annotation start visit\n"
           + "marker annotation end visit\n"
           + "single member annotation start visit\n"
           + "3\n"
           + "single member annotation end visit\n"
           + "normal annotation start visit\n"
           + "member value pair start visit\n"
           + "value, 4\n"
           + "member value pair end visit\n"
           + "normal annotation end visit\n"
           + "java doc single type reference start visit\n"
           + "java doc single type reference end visit\n"
           + "start argument\n"
           + "marker annotation start visit\n"
           + "marker annotation end visit\n"
           + "exit argument\n"
           + "start local declaration\n"
           + "marker annotation start visit\n"
           + "marker annotation end visit\n"
           + "exit local declaration\n");
 }
Exemplo n.º 3
0
 /**
  * Parse Java source.
  *
  * @param javaSource String containing Java source to parse
  * @return a CompilationUnitDeclaration or null if parsing failed
  */
 private static CompilationUnitDeclaration parseJava(String javaSource) {
   CodeSnippetParsingUtil parsingUtil = new CodeSnippetParsingUtil(true);
   CompilerOptions options = new CompilerOptions();
   options.complianceLevel = ClassFileConstants.JDK1_6;
   options.originalSourceLevel = ClassFileConstants.JDK1_6;
   options.sourceLevel = ClassFileConstants.JDK1_6;
   CompilationUnitDeclaration unit =
       parsingUtil.parseCompilationUnit(
           javaSource.toString().toCharArray(), options.getMap(), true);
   if (unit.compilationResult().hasProblems()) {
     return null;
   }
   return unit;
 }
  public static CompilerOptions getCompilerOptions() {
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_6;

    // Generate debug info for debugging the output.
    options.produceDebugAttributes =
        ClassFileConstants.ATTR_VARS
            | ClassFileConstants.ATTR_LINES
            | ClassFileConstants.ATTR_SOURCE;
    // Tricks like "boolean stopHere = true;" depend on this setting.
    options.preserveAllLocalVariables = true;
    // Let the JDT collect compilation unit dependencies
    options.produceReferenceInfo = true;

    // Turn off all warnings, saves some memory / speed.
    options.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = false;
    options.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = false;
    options.warningThreshold = 0;
    options.inlineJsrBytecode = true;
    return options;
  }