Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.126 diff -u -r1.126 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 10 Sep 2003 10:41:55 -0000 1.126 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 18 Sep 2003 16:02:08 -0000 @@ -36,6 +36,7 @@ import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.IProblemFactory; +import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; @@ -72,6 +73,8 @@ public int globalWarningsCount; public long lineCount; public String log; + public String checker; + public String requestor; public boolean noWarn = false; @@ -422,6 +425,8 @@ final int InsideSource = 32; final int InsideDefaultEncoding = 64; final int InsideBootClasspath = 128; + final int InsideChecker = 256; + final int InsideRequestor = 512; final int Default = 0; String[] bootclasspaths = null; int DEFAULT_SIZE_CLASSPATH = 4; @@ -897,6 +902,14 @@ mode = TargetSetting; continue; } + if (currentArg.equals("-checker")) { //$NON-NLS-1$ + mode = InsideChecker; + continue; + } + if (currentArg.equals("-requestor")) { //$NON-NLS-1$ + mode = InsideRequestor; + continue; + } if (currentArg.equals("-preserveAllLocals")) { //$NON-NLS-1$ this.options.put( CompilerOptions.OPTION_PreserveUnusedLocal, @@ -1005,7 +1018,17 @@ } mode = Default; continue; - } + } + if (mode == InsideChecker) { + checker = currentArg; + mode = Default; + continue; + } + if (mode == InsideRequestor) { + requestor = currentArg; + mode = Default; + continue; + } //default is input directory currentArg = currentArg.replace('/', File.separatorChar); if (currentArg.endsWith(File.separator)) @@ -1278,6 +1301,18 @@ * Answer the component to which will be handed back compilation results from the compiler */ public ICompilerRequestor getBatchRequestor() { + // return the user provided requestor if there is one + if (requestor != null) { + try { + Class klass = Class.forName(requestor); + return (ICompilerRequestor)klass.newInstance(); + } + catch (Exception e) + { + err.println(e.getMessage()); + } + } + return new ICompilerRequestor() { int lineDelta = 0; public void acceptResult(CompilationResult compilationResult) { @@ -1485,6 +1520,20 @@ // set the non-externally configurable options. compilerOptions.setVerboseMode(this.verbose); compilerOptions.produceReferenceInfo(this.produceRefInfo); + + // set the checker class + if (checker != null) { + try { + Class klass = Class.forName(checker); + batchCompiler.checker = (IAbstractSyntaxTreeVisitor)klass.newInstance(); + } + catch (Exception e) + { + err.println(e.getMessage()); + } + } + + // compile batchCompiler.compile(getCompilationUnits()); // cleanup Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v retrieving revision 1.60 diff -u -r1.60 IProblem.java --- compiler/org/eclipse/jdt/core/compiler/IProblem.java 28 Aug 2003 12:57:42 -0000 1.60 +++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 18 Sep 2003 16:02:10 -0000 @@ -47,6 +47,13 @@ * UnusedConstructorDeclaredThrownException * InvalidCatchBlockSequence * UnqualifiedFieldAccess + * + * SAS - added the following constants + * StringConcat + * LocaleSensitiveMethod + * EmbeddedString + * EmbeddedCharacter + * ****************************************************************************/ package org.eclipse.jdt.core.compiler; @@ -672,4 +679,13 @@ /** @since 3.0 */ int UnboundAnnotationReference = Internal + 473; + // internationalization + /** @since 3.0 */ + int StringConcat = Internal + 480; + /** @since 3.0 */ + int LocaleSensitiveMethod = Internal + 481; + /** @since 3.0 */ + int EmbeddedString = Internal + 482; + /** @since 3.0 */ + int EmbeddedCharacter = Internal + 483; } Index: compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java,v retrieving revision 1.30 diff -u -r1.30 CompilationResult.java --- compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java 1 Apr 2003 11:40:31 -0000 1.30 +++ compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java 18 Sep 2003 16:02:10 -0000 @@ -94,7 +94,7 @@ if (problem.isError()){ priority += P_ERROR; } - ReferenceContext context = problemsMap == null ? null : (ReferenceContext) problemsMap.get(problem); + ReferenceContext context = getProblemContext(problem); if (context != null){ if (context instanceof AbstractMethodDeclaration){ AbstractMethodDeclaration method = (AbstractMethodDeclaration) context; @@ -423,5 +423,11 @@ buffer.append("No PROBLEM\n"); //$NON-NLS-1$ } return buffer.toString(); + } + + public ReferenceContext getProblemContext(IProblem problem) + { + ReferenceContext context = problemsMap == null ? null : (ReferenceContext) problemsMap.get(problem); + return context; } } Index: compiler/org/eclipse/jdt/internal/compiler/Compiler.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java,v retrieving revision 1.51 diff -u -r1.51 Compiler.java --- compiler/org/eclipse/jdt/internal/compiler/Compiler.java 4 Sep 2003 08:08:15 -0000 1.51 +++ compiler/org/eclipse/jdt/internal/compiler/Compiler.java 18 Sep 2003 16:02:10 -0000 @@ -27,6 +27,7 @@ public ICompilerRequestor requestor; public CompilerOptions options; public ProblemReporter problemReporter; + public IAbstractSyntaxTreeVisitor checker; // management of unit to be processed //public CompilationUnitResult currentCompilationUnitResult; @@ -513,6 +514,10 @@ // type checking unit.resolve(); + + // AST checking + if ( checker != null) + unit.traverse(checker, unit.scope); // flow analysis unit.analyseCode(); Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.107 diff -u -r1.107 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Aug 2003 12:57:42 -0000 1.107 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 18 Sep 2003 16:02:16 -0000 @@ -509,6 +509,12 @@ case IProblem.Task : return Warning; + case IProblem.StringConcat : + case IProblem.LocaleSensitiveMethod : + case IProblem.EmbeddedCharacter : + case IProblem.EmbeddedString : + return Warning; + case IProblem.LocalVariableHidingLocalVariable: case IProblem.LocalVariableHidingField: case IProblem.ArgumentHidingLocalVariable: @@ -3235,6 +3241,42 @@ public void nonExternalizedStringLiteral(AstNode location) { this.handle( IProblem.NonExternalizedStringLiteral, + NoArgument, + NoArgument, + location.sourceStart, + location.sourceEnd); +} + +public void stringConcat(AstNode location) { + this.handle( + IProblem.StringConcat, + NoArgument, + NoArgument, + location.sourceStart, + location.sourceEnd); +} + +public void localeSensitiveMethod(MethodBinding method, AstNode location) { + this.handle( + IProblem.LocaleSensitiveMethod, + new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)}, + new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)}, + location.sourceStart, + location.sourceEnd); +} + +public void embeddedString(AstNode location) { + this.handle( + IProblem.EmbeddedString, + NoArgument, + NoArgument, + location.sourceStart, + location.sourceEnd); +} + +public void embeddedCharacter(AstNode location) { + this.handle( + IProblem.EmbeddedCharacter, NoArgument, NoArgument, location.sourceStart, Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v retrieving revision 1.78 diff -u -r1.78 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 28 Aug 2003 12:57:42 -0000 1.78 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 18 Sep 2003 16:02:16 -0000 @@ -331,4 +331,9 @@ 450 = {0} {1} -460 = Empty block should be documented \ No newline at end of file +460 = Empty block should be documented + +480 = I18N:COS String concatenation +481 = I18N:LSM Locale sensitive method use +482 = I18N:EMS Embedded String Literal +483 = I18N:EMC Embedded Character Literal