1 11 package org.eclipse.jdt.internal.compiler.tool; 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"); ONE_ARGUMENT_OPTIONS.add("-classNames"); 85 } 86 public static int processOptionsFileManager(String option) { 87 if (option == null) return -1; 88 if (FILE_MANAGER_OPTIONS.contains(option)) { 89 return 1; 90 } 91 return -1; 92 } 93 94 public static int processOptions(String option) { 95 if (option == null) return -1; 96 if (ZERO_ARGUMENT_OPTIONS.contains(option)) { 97 return 0; 98 } 99 if (ONE_ARGUMENT_OPTIONS.contains(option)) { 100 return 1; 101 } 102 if (option.startsWith("-g")) { int length = option.length(); 104 if (length > 3) { 105 StringTokenizer tokenizer = 106 new StringTokenizer (option.substring(3, option.length()), ","); while (tokenizer.hasMoreTokens()) { 108 String token = tokenizer.nextToken(); 109 if ("vars".equals(token) || "lines".equals(token) || "source".equals(token)) { continue; 111 } 112 return -1; 113 } 114 return 0; 115 } 116 return -1; 117 } 118 if (option.startsWith("-warn")) { int length = option.length(); 120 if (length <= 6) { 121 return -1; 122 } 123 int warnTokenStart; 124 switch (option.charAt(6)) { 125 case '+' : 126 warnTokenStart = 7; 127 break; 128 case '-' : 129 warnTokenStart = 7; 130 break; 131 default: 132 warnTokenStart = 6; 133 } 134 135 StringTokenizer tokenizer = 136 new StringTokenizer (option.substring(warnTokenStart, option.length()), ","); int tokenCounter = 0; 138 139 while (tokenizer.hasMoreTokens()) { 140 String token = tokenizer.nextToken(); 141 tokenCounter++; 142 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; 207 } else if (token.equals("tasks")) { String taskTags = ""; int start = token.indexOf('('); 210 int end = token.indexOf(')'); 211 if (start >= 0 && end >= 0 && start < end){ 212 taskTags = token.substring(start+1, end).trim(); 213 taskTags = taskTags.replace('|',','); 214 } 215 if (taskTags.length() == 0){ 216 return -1; 217 } 218 continue; 219 } else { 220 return -1; 221 } 222 } 223 if (tokenCounter == 0) { 224 return -1; 225 } else { 226 return 0; 227 } 228 } 229 if (option.startsWith("-J") || option.startsWith("-X") || option.startsWith("-A")) { return 0; 233 } 234 return -1; 235 } 236 } 237 | Popular Tags |