1 11 package org.eclipse.jdt.internal.compiler.apt.util; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 import java.util.StringTokenizer ; 16 17 20 public final class Options { 21 private static final Set <String > ZERO_ARGUMENT_OPTIONS; 22 private static final Set <String > ONE_ARGUMENT_OPTIONS; 23 private static final Set <String > FILE_MANAGER_OPTIONS; 24 static { 25 ZERO_ARGUMENT_OPTIONS = new HashSet <String >(); 26 ZERO_ARGUMENT_OPTIONS.add("-progress"); ZERO_ARGUMENT_OPTIONS.add("-proceedOnError"); ZERO_ARGUMENT_OPTIONS.add("-time"); ZERO_ARGUMENT_OPTIONS.add("-v"); ZERO_ARGUMENT_OPTIONS.add("-version"); ZERO_ARGUMENT_OPTIONS.add("-showversion"); ZERO_ARGUMENT_OPTIONS.add("-deprecation"); ZERO_ARGUMENT_OPTIONS.add("-help"); ZERO_ARGUMENT_OPTIONS.add("-?"); ZERO_ARGUMENT_OPTIONS.add("-help:warn"); ZERO_ARGUMENT_OPTIONS.add("-?:warn"); ZERO_ARGUMENT_OPTIONS.add("-noExit"); ZERO_ARGUMENT_OPTIONS.add("-verbose"); ZERO_ARGUMENT_OPTIONS.add("-referenceInfo"); ZERO_ARGUMENT_OPTIONS.add("-inlineJSR"); ZERO_ARGUMENT_OPTIONS.add("-g"); ZERO_ARGUMENT_OPTIONS.add("-g:none"); ZERO_ARGUMENT_OPTIONS.add("-nowarn"); ZERO_ARGUMENT_OPTIONS.add("-warn:none"); ZERO_ARGUMENT_OPTIONS.add("-preserveAllLocals"); ZERO_ARGUMENT_OPTIONS.add("-enableJavadoc"); ZERO_ARGUMENT_OPTIONS.add("-Xemacs"); ZERO_ARGUMENT_OPTIONS.add("-X"); ZERO_ARGUMENT_OPTIONS.add("-O"); ZERO_ARGUMENT_OPTIONS.add("-1.3"); ZERO_ARGUMENT_OPTIONS.add("-1.4"); ZERO_ARGUMENT_OPTIONS.add("-1.5"); ZERO_ARGUMENT_OPTIONS.add("-5"); ZERO_ARGUMENT_OPTIONS.add("-5.0"); ZERO_ARGUMENT_OPTIONS.add("-1.6"); ZERO_ARGUMENT_OPTIONS.add("-6"); ZERO_ARGUMENT_OPTIONS.add("-6.0"); ZERO_ARGUMENT_OPTIONS.add("-proc:only"); ZERO_ARGUMENT_OPTIONS.add("-proc:none"); ZERO_ARGUMENT_OPTIONS.add("-XprintProcessorInfo"); ZERO_ARGUMENT_OPTIONS.add("-XprintRounds"); 63 FILE_MANAGER_OPTIONS = new HashSet <String >(); 64 FILE_MANAGER_OPTIONS.add("-bootclasspath"); FILE_MANAGER_OPTIONS.add("-encoding"); FILE_MANAGER_OPTIONS.add("-d"); FILE_MANAGER_OPTIONS.add("-classpath"); FILE_MANAGER_OPTIONS.add("-cp"); FILE_MANAGER_OPTIONS.add("-sourcepath"); FILE_MANAGER_OPTIONS.add("-extdirs"); FILE_MANAGER_OPTIONS.add("-endorseddirs"); FILE_MANAGER_OPTIONS.add("-s"); FILE_MANAGER_OPTIONS.add("-processorpath"); 75 ONE_ARGUMENT_OPTIONS = new HashSet <String >(); 76 ONE_ARGUMENT_OPTIONS.addAll(FILE_MANAGER_OPTIONS); 77 ONE_ARGUMENT_OPTIONS.add("-log"); ONE_ARGUMENT_OPTIONS.add("-repeat"); ONE_ARGUMENT_OPTIONS.add("-maxProblems"); ONE_ARGUMENT_OPTIONS.add("-source"); ONE_ARGUMENT_OPTIONS.add("-target"); ONE_ARGUMENT_OPTIONS.add("-processor"); 84 } 85 public static int processOptionsFileManager(String option) { 86 if (option == null) return -1; 87 if (FILE_MANAGER_OPTIONS.contains(option)) { 88 return 1; 89 } 90 return -1; 91 } 92 93 public static int processOptions(String option) { 94 if (option == null) return -1; 95 if (ZERO_ARGUMENT_OPTIONS.contains(option)) { 96 return 0; 97 } 98 if (ONE_ARGUMENT_OPTIONS.contains(option)) { 99 return 1; 100 } 101 if (option.startsWith("-g")) { int length = option.length(); 103 if (length > 3) { 104 StringTokenizer tokenizer = 105 new StringTokenizer (option.substring(3, option.length()), ","); while (tokenizer.hasMoreTokens()) { 107 String token = tokenizer.nextToken(); 108 if ("vars".equals(token) || "lines".equals(token) || "source".equals(token)) { continue; 110 } 111 return -1; 112 } 113 return 0; 114 } 115 return -1; 116 } 117 if (option.startsWith("-warn")) { int length = option.length(); 119 if (length <= 6) { 120 return -1; 121 } 122 int warnTokenStart; 123 switch (option.charAt(6)) { 124 case '+' : 125 warnTokenStart = 7; 126 break; 127 case '-' : 128 warnTokenStart = 7; 129 break; 130 default: 131 warnTokenStart = 6; 132 } 133 134 StringTokenizer tokenizer = 135 new StringTokenizer (option.substring(warnTokenStart, option.length()), ","); int tokenCounter = 0; 137 138 while (tokenizer.hasMoreTokens()) { 139 String token = tokenizer.nextToken(); 140 tokenCounter++; 141 if ("constructorName".equals(token) || token.equals("pkgDefaultMethod") || token.equals("packageDefaultMethod") || token.equals("maskedCatchBlock") || token.equals("maskedCatchBlocks") || token.equals("deprecation") || token.equals("allDeprecation") || token.equals("unusedLocal") || token.equals("unusedLocals") || token.equals("unusedArgument") || token.equals("unusedArguments") || token.equals("unusedImport") || token.equals("unusedImports") || token.equals("unusedPrivate") || token.equals("unusedLabel") || token.equals("localHiding") || token.equals("fieldHiding") || token.equals("specialParamHiding") || token.equals("conditionAssign") || token.equals("syntheticAccess") || token.equals("synthetic-access") || token.equals("nls") || token.equals("staticReceiver") || token.equals("indirectStatic") || token.equals("noEffectAssign") || token.equals("intfNonInherited") || token.equals("interfaceNonInherited") || token.equals("charConcat") || token.equals("noImplicitStringConversion") || token.equals("semicolon") || token.equals("serial") || token.equals("emptyBlock") || token.equals("uselessTypeCheck") || token.equals("unchecked") || token.equals("unsafe") || token.equals("raw") || token.equals("finalBound") || token.equals("suppress") || token.equals("warningToken") || token.equals("unnecessaryElse") || token.equals("javadoc") || token.equals("allJavadoc") || token.equals("assertIdentifier") || token.equals("enumIdentifier") || token.equals("finally") || token.equals("unusedThrown") || token.equals("unqualifiedField") || token.equals("unqualified-field-access") || token.equals("typeHiding") || token.equals("varargsCast") || token.equals("null") || token.equals("boxing") || token.equals("over-ann") || token.equals("dep-ann") || token.equals("intfAnnotation") || token.equals("enumSwitch") || token.equals("incomplete-switch") || token.equals("hiding") || token.equals("static-access") || token.equals("unused") || token.equals("paramAssign") || token.equals("discouraged") || token.equals("forbidden") || token.equals("fallthrough")) { continue; 206 } else if (token.equals("tasks")) { String taskTags = ""; int start = token.indexOf('('); 209 int end = token.indexOf(')'); 210 if (start >= 0 && end >= 0 && start < end){ 211 taskTags = token.substring(start+1, end).trim(); 212 taskTags = taskTags.replace('|',','); 213 } 214 if (taskTags.length() == 0){ 215 return -1; 216 } 217 continue; 218 } else { 219 return -1; 220 } 221 } 222 if (tokenCounter == 0) { 223 return -1; 224 } else { 225 return 0; 226 } 227 } 228 if (option.startsWith("-J") || option.startsWith("-X") || option.startsWith("-A")) { return 0; 232 } 233 return -1; 234 } 235 } 236 | Popular Tags |