Lines 29-38
Link Here
|
29 |
import java.text.MessageFormat; |
29 |
import java.text.MessageFormat; |
30 |
import java.util.ArrayList; |
30 |
import java.util.ArrayList; |
31 |
import java.util.Arrays; |
31 |
import java.util.Arrays; |
|
|
32 |
import java.util.Collections; |
32 |
import java.util.Comparator; |
33 |
import java.util.Comparator; |
33 |
import java.util.Date; |
34 |
import java.util.Date; |
34 |
import java.util.HashMap; |
35 |
import java.util.HashMap; |
35 |
import java.util.Iterator; |
36 |
import java.util.Iterator; |
|
|
37 |
import java.util.LinkedList; |
36 |
import java.util.Locale; |
38 |
import java.util.Locale; |
37 |
import java.util.Map; |
39 |
import java.util.Map; |
38 |
import java.util.MissingResourceException; |
40 |
import java.util.MissingResourceException; |
Lines 42-49
Link Here
|
42 |
|
44 |
|
43 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
45 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
44 |
import org.eclipse.jdt.core.compiler.CharOperation; |
46 |
import org.eclipse.jdt.core.compiler.CharOperation; |
45 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
|
|
46 |
import org.eclipse.jdt.core.compiler.IProblem; |
47 |
import org.eclipse.jdt.core.compiler.IProblem; |
|
|
48 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
47 |
import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager; |
49 |
import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager; |
48 |
import org.eclipse.jdt.internal.compiler.ClassFile; |
50 |
import org.eclipse.jdt.internal.compiler.ClassFile; |
49 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
51 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
Lines 63-71
Link Here
|
63 |
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; |
65 |
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; |
64 |
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; |
66 |
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; |
65 |
import org.eclipse.jdt.internal.compiler.util.GenericXMLWriter; |
67 |
import org.eclipse.jdt.internal.compiler.util.GenericXMLWriter; |
|
|
68 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; |
66 |
import org.eclipse.jdt.internal.compiler.util.Messages; |
69 |
import org.eclipse.jdt.internal.compiler.util.Messages; |
67 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
70 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
68 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; |
|
|
69 |
import org.eclipse.jdt.internal.compiler.util.Util; |
71 |
import org.eclipse.jdt.internal.compiler.util.Util; |
70 |
|
72 |
|
71 |
public class Main implements ProblemSeverities, SuffixConstants { |
73 |
public class Main implements ProblemSeverities, SuffixConstants { |
Lines 3076-3205
Link Here
|
3076 |
ArrayList currentRuleSpecs = new ArrayList(defaultSize); |
3078 |
ArrayList currentRuleSpecs = new ArrayList(defaultSize); |
3077 |
StringTokenizer tokenizer = new StringTokenizer(currentPath, |
3079 |
StringTokenizer tokenizer = new StringTokenizer(currentPath, |
3078 |
File.pathSeparator + "[]", true); //$NON-NLS-1$ |
3080 |
File.pathSeparator + "[]", true); //$NON-NLS-1$ |
|
|
3081 |
LinkedList list = new LinkedList(Collections.list(tokenizer)); |
3082 |
|
3079 |
// state machine |
3083 |
// state machine |
3080 |
final int start = 0; |
3084 |
// process list in reverse order, start refers to end of list |
3081 |
final int readyToClose = 1; |
3085 |
final int start = 0; |
3082 |
// 'path' 'path1[rule];path2' |
3086 |
final int rulesStart = 1; |
3083 |
final int readyToCloseEndingWithRules = 2; |
3087 |
// // '][-d bin]' '][-d bin]:path' |
3084 |
// 'path[rule]' 'path1;path2[rule]' |
3088 |
final int rulesReadyToCloseOrOtherRule = 2; |
3085 |
final int readyToCloseOrOtherEntry = 3; |
3089 |
// 'rule]' 'rule1:rule2]' |
3086 |
// 'path[rule];' 'path;' 'path1;path2;' |
3090 |
final int rulesNeedAnotherRule = 3; |
3087 |
final int rulesNeedAnotherRule = 4; |
3091 |
// ':rule2]' ':rule2:rule3]:path' |
3088 |
// 'path[rule1;' |
3092 |
final int readyForPath = 4; |
3089 |
final int rulesStart = 5; |
3093 |
// '[rule]' '[rule1:rule2]' '[rule][-d bin] |
3090 |
// 'path[' 'path1;path2[' |
3094 |
final int readyToCloseOrOtherEntry = 5; |
3091 |
final int rulesReadyToClose = 6; |
3095 |
// 'path[rule]' 'path' 'path1:path2' 'path[-d bin]' path[rule][-d bin] |
3092 |
// 'path[rule' 'path[rule1;rule2' |
3096 |
final int readyForPathOrRules = 6; |
3093 |
final int destinationPathReadyToClose = 7; |
3097 |
// ':path[rule]' ':path' |
3094 |
// 'path[-d bin' |
3098 |
final int rulesOrDestinationStart = 7; |
3095 |
final int readyToCloseEndingWithDestinationPath = 8; |
3099 |
// ']' ']:path' |
3096 |
// 'path[-d bin]' 'path[rule][-d bin]' |
3100 |
final int destinationPathReadyToClose = 8; |
3097 |
final int destinatonPathStart = 9; |
3101 |
// // '-d bin]' '-d bin]:path' |
3098 |
// 'path[rule][' |
3102 |
final int readyForPathOrRulesWithDestination = 9; |
|
|
3103 |
// '[-d bin]' '[-d bin]:path' |
3099 |
final int error = 99; |
3104 |
final int error = 99; |
3100 |
int state = start; |
3105 |
int state = start; |
|
|
3106 |
|
3107 |
if (((String)list.getFirst()).equalsIgnoreCase(File.pathSeparator)) { |
3108 |
list.removeFirst(); |
3109 |
} |
3101 |
String token = null; |
3110 |
String token = null; |
3102 |
while (tokenizer.hasMoreTokens() && state != error) { |
3111 |
while (!list.isEmpty() && state != error) { |
3103 |
token = tokenizer.nextToken(); |
3112 |
token = (String)list.removeLast(); |
3104 |
if (token.equals(File.pathSeparator)) { |
3113 |
if (token.equals(File.pathSeparator)) { |
3105 |
switch (state) { |
3114 |
switch (state) { |
3106 |
case start: |
3115 |
case start: |
3107 |
case readyToCloseOrOtherEntry: |
3116 |
case rulesNeedAnotherRule: |
|
|
3117 |
case readyForPathOrRules: |
3108 |
break; |
3118 |
break; |
3109 |
case readyToClose: |
3119 |
case readyToCloseOrOtherEntry: |
3110 |
case readyToCloseEndingWithRules: |
3120 |
Collections.reverse(currentRuleSpecs); |
3111 |
case readyToCloseEndingWithDestinationPath: |
|
|
3112 |
state = readyToCloseOrOtherEntry; |
3113 |
addNewEntry(paths, currentClasspathName, currentRuleSpecs, |
3121 |
addNewEntry(paths, currentClasspathName, currentRuleSpecs, |
3114 |
customEncoding, currentDestinationPath, isSourceOnly, |
3122 |
customEncoding, currentDestinationPath, isSourceOnly, |
3115 |
rejectDestinationPathOnJars); |
3123 |
rejectDestinationPathOnJars); |
3116 |
currentRuleSpecs.clear(); |
3124 |
currentRuleSpecs.clear(); |
|
|
3125 |
currentDestinationPath = null; |
3126 |
currentClasspathName = null; |
3127 |
state = readyForPathOrRules; |
3117 |
break; |
3128 |
break; |
3118 |
case rulesReadyToClose: |
3129 |
case rulesReadyToCloseOrOtherRule: |
3119 |
state = rulesNeedAnotherRule; |
3130 |
state = rulesNeedAnotherRule; |
3120 |
break; |
3131 |
break; |
3121 |
case destinationPathReadyToClose: |
|
|
3122 |
throw new InvalidInputException( |
3123 |
this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$ |
3124 |
currentPath)); |
3125 |
default: |
3132 |
default: |
3126 |
state = error; |
3133 |
state = error; |
3127 |
} |
3134 |
} |
3128 |
} else if (token.equals("[")) { //$NON-NLS-1$ |
3135 |
} else if (token.equals("[")) { //$NON-NLS-1$ |
3129 |
switch (state) { |
3136 |
switch (state) { |
3130 |
case readyToClose: |
3137 |
case rulesReadyToCloseOrOtherRule: |
3131 |
state = rulesStart; |
3138 |
state = readyForPath; |
3132 |
break; |
|
|
3133 |
case readyToCloseEndingWithRules: |
3134 |
state = destinatonPathStart; |
3135 |
break; |
3139 |
break; |
3136 |
case readyToCloseEndingWithDestinationPath: |
3140 |
case destinationPathReadyToClose: |
3137 |
state = rulesStart; |
3141 |
state = readyForPathOrRulesWithDestination; |
3138 |
break; |
3142 |
break; |
3139 |
default: |
3143 |
default: |
3140 |
state = error; |
3144 |
state = error; |
3141 |
} |
3145 |
} |
3142 |
} else if (token.equals("]")) { //$NON-NLS-1$ |
3146 |
} else if (token.equals("]")) { //$NON-NLS-1$ |
3143 |
switch (state) { |
3147 |
switch (state) { |
3144 |
case rulesReadyToClose: |
3148 |
case start: |
3145 |
state = readyToCloseEndingWithRules; |
3149 |
case readyForPathOrRules: |
|
|
3150 |
state = rulesOrDestinationStart; |
3146 |
break; |
3151 |
break; |
3147 |
case destinationPathReadyToClose: |
3152 |
case readyForPathOrRulesWithDestination: |
3148 |
state = readyToCloseEndingWithDestinationPath; |
3153 |
state = rulesStart; |
3149 |
break; |
3154 |
break; |
3150 |
default: |
3155 |
default: |
|
|
3156 |
// give a useful error message if we can |
3157 |
if (list.size() > 2) { |
3158 |
if (((String)list.getLast()).startsWith("-d ") //$NON-NLS-1$ |
3159 |
&& ((String)list.get(list.size()-2)).equalsIgnoreCase("[")) { //$NON-NLS-1$ |
3160 |
throw new InvalidInputException( |
3161 |
this.bind("configure.accessRuleAfterDestinationPath", //$NON-NLS-1$ |
3162 |
currentPath)); |
3163 |
} |
3164 |
} |
3151 |
state = error; |
3165 |
state = error; |
3152 |
} |
3166 |
} |
3153 |
} else { |
3167 |
} else { |
3154 |
// regular word |
3168 |
// regular word |
3155 |
switch (state) { |
3169 |
switch (state) { |
3156 |
case start: |
3170 |
case start: |
3157 |
case readyToCloseOrOtherEntry: |
3171 |
case readyForPath: |
3158 |
state = readyToClose; |
3172 |
case readyForPathOrRules: |
3159 |
currentClasspathName = token; |
3173 |
case readyForPathOrRulesWithDestination: |
|
|
3174 |
currentClasspathName = getPath(list, token); |
3175 |
state = readyToCloseOrOtherEntry; |
3176 |
break; |
3177 |
case rulesOrDestinationStart: |
3178 |
if (token.startsWith("-d ")) { //$NON-NLS-1$ |
3179 |
currentDestinationPath = token.substring(3).trim(); |
3180 |
state = destinationPathReadyToClose; |
3181 |
} else { |
3182 |
currentRuleSpecs.add(token); |
3183 |
state = rulesReadyToCloseOrOtherRule; |
3184 |
} |
3160 |
break; |
3185 |
break; |
3161 |
case rulesStart: |
3186 |
case rulesStart: |
|
|
3187 |
case rulesNeedAnotherRule: |
3162 |
if (token.startsWith("-d ")) { //$NON-NLS-1$ |
3188 |
if (token.startsWith("-d ")) { //$NON-NLS-1$ |
3163 |
if (currentDestinationPath != null) { |
3189 |
if (currentDestinationPath != null) { |
3164 |
throw new InvalidInputException( |
3190 |
throw new InvalidInputException( |
3165 |
this.bind("configure.duplicateDestinationPathEntry", //$NON-NLS-1$ |
3191 |
this.bind("configure.duplicateDestinationPathEntry", //$NON-NLS-1$ |
3166 |
currentPath)); |
3192 |
currentPath)); |
3167 |
} |
3193 |
} else { |
3168 |
currentDestinationPath = token.substring(3).trim(); |
3194 |
throw new InvalidInputException( |
3169 |
state = destinationPathReadyToClose; |
3195 |
this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$ |
3170 |
break; |
|
|
3171 |
} // else we proceed with a rule |
3172 |
case rulesNeedAnotherRule: |
3173 |
if (currentDestinationPath != null) { |
3174 |
throw new InvalidInputException( |
3175 |
this.bind("configure.accessRuleAfterDestinationPath", //$NON-NLS-1$ |
3176 |
currentPath)); |
3196 |
currentPath)); |
|
|
3197 |
} |
3177 |
} |
3198 |
} |
3178 |
state = rulesReadyToClose; |
|
|
3179 |
currentRuleSpecs.add(token); |
3199 |
currentRuleSpecs.add(token); |
3180 |
break; |
3200 |
state = rulesReadyToCloseOrOtherRule; |
3181 |
case destinatonPathStart: |
|
|
3182 |
if (!token.startsWith("-d ")) { //$NON-NLS-1$ |
3183 |
state = error; |
3184 |
} else { |
3185 |
currentDestinationPath = token.substring(3).trim(); |
3186 |
state = destinationPathReadyToClose; |
3187 |
} |
3188 |
break; |
3201 |
break; |
3189 |
default: |
3202 |
default: |
3190 |
state = error; |
3203 |
state = error; |
3191 |
} |
3204 |
} |
3192 |
} |
3205 |
} |
3193 |
} |
3206 |
} |
|
|
3207 |
|
3194 |
switch(state) { |
3208 |
switch(state) { |
|
|
3209 |
case readyForPathOrRules: |
3195 |
case readyToCloseOrOtherEntry: |
3210 |
case readyToCloseOrOtherEntry: |
3196 |
break; |
3211 |
Collections.reverse(currentRuleSpecs); |
3197 |
case readyToClose: |
|
|
3198 |
case readyToCloseEndingWithRules: |
3199 |
case readyToCloseEndingWithDestinationPath: |
3200 |
addNewEntry(paths, currentClasspathName, currentRuleSpecs, |
3212 |
addNewEntry(paths, currentClasspathName, currentRuleSpecs, |
3201 |
customEncoding, currentDestinationPath, isSourceOnly, |
3213 |
customEncoding, currentDestinationPath, isSourceOnly, |
3202 |
rejectDestinationPathOnJars); |
3214 |
rejectDestinationPathOnJars); |
3203 |
break; |
3215 |
break; |
3204 |
default : |
3216 |
default : |
3205 |
// we go on anyway |
3217 |
// we go on anyway |
Lines 3209-3214
Link Here
|
3209 |
} |
3221 |
} |
3210 |
} |
3222 |
} |
3211 |
|
3223 |
|
|
|
3224 |
private String getPath(LinkedList list, String path) { |
3225 |
while (!list.isEmpty()) { |
3226 |
if (File.pathSeparator.equalsIgnoreCase((String)list.getLast())) |
3227 |
break; |
3228 |
path = (String)list.removeLast() + path; |
3229 |
} |
3230 |
return path; |
3231 |
} |
3232 |
|
3212 |
private int processPaths(String[] args, int index, String currentArg, ArrayList paths) throws InvalidInputException { |
3233 |
private int processPaths(String[] args, int index, String currentArg, ArrayList paths) throws InvalidInputException { |
3213 |
int localIndex = index; |
3234 |
int localIndex = index; |
3214 |
int count = 0; |
3235 |
int count = 0; |