Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 5523 Details for
Bug 38332
Add hooks for additional compiler diagnostics such as internationalization warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Repatched for latest HEAD sources (~3.0m2).
shikari.patch (text/plain), 14.23 KB, created by
Ed Burnette
on 2003-07-21 16:15:55 EDT
(
hide
)
Description:
Repatched for latest HEAD sources (~3.0m2).
Filename:
MIME Type:
Creator:
Ed Burnette
Created:
2003-07-21 16:15:55 EDT
Size:
14.23 KB
patch
obsolete
>Index: 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.117 >diff -u -r1.117 Main.java >--- org/eclipse/jdt/internal/compiler/batch/Main.java 19 Jul 2003 14:00:02 -0000 1.117 >+++ org/eclipse/jdt/internal/compiler/batch/Main.java 21 Jul 2003 19:32:02 -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; > >@@ -90,6 +93,59 @@ > > public boolean verbose = false; > >+ private class CompilerRequestor implements ICompilerRequestor { >+ int lineDelta = 0; >+ public void acceptResult(CompilationResult compilationResult) { >+ if (compilationResult.lineSeparatorPositions != null) { >+ int unitLineCount = compilationResult.lineSeparatorPositions.length; >+ lineCount += unitLineCount; >+ lineDelta += unitLineCount; >+ if (showProgress && lineDelta > 2000) { // in -log mode, dump a dot every 2000 lines compiled >+ out.print('.'); >+ lineDelta = 0; >+ } >+ } >+ if (compilationResult.hasProblems() || compilationResult.hasTasks()) { >+ IProblem[] problems = compilationResult.getAllProblems(); >+ int count = problems.length; >+ int localErrorCount = 0; >+ for (int i = 0; i < count; i++) { >+ if (problems[i] != null) { >+ globalProblemsCount++; >+ if (localErrorCount == 0) >+ err.println("----------"); //$NON-NLS-1$ >+ err.print(globalProblemsCount + ". " //$NON-NLS-1$ >+ + (problems[i].isError() ? Main.bind("requestor.error") //$NON-NLS-1$ >+ : Main.bind("requestor.warning"))); //$NON-NLS-1$ >+ if (problems[i].isError()) { >+ globalErrorsCount++; >+ } else { >+ globalWarningsCount++; >+ } >+ err.print(" "); //$NON-NLS-1$ >+ err.print(Main.bind("requestor.in", new String(problems[i].getOriginatingFileName()))); //$NON-NLS-1$ >+ try { >+ err.println(((DefaultProblem) problems[i]).errorReportSource(compilationResult.compilationUnit)); >+ err.println(problems[i].getMessage()); >+ } catch (Exception e) { >+ err.println(Main.bind("requestor.notRetrieveErrorMessage", problems[i].toString())); //$NON-NLS-1$ >+ } >+ err.println("----------"); //$NON-NLS-1$ >+ if (problems[i].isError()) >+ localErrorCount++; >+ } >+ } >+ // exit? >+ if (systemExitWhenFinished && !proceedOnError && (localErrorCount > 0)) { >+ err.flush(); >+ out.flush(); >+ System.exit(-1); >+ } >+ } >+ outputClassFiles(compilationResult); >+ } >+ } >+ > public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) { > > this.out = outWriter; >@@ -418,6 +474,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; >@@ -871,6 +929,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$ > options.put( > CompilerOptions.OPTION_PreserveUnusedLocal, >@@ -979,7 +1045,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)) >@@ -1246,66 +1322,20 @@ > * Answer the component to which will be handed back compilation results from the compiler > */ > public ICompilerRequestor getBatchRequestor() { >- return new ICompilerRequestor() { >- int lineDelta = 0; >- public void acceptResult(CompilationResult compilationResult) { >- if (compilationResult.lineSeparatorPositions != null) { >- int unitLineCount = compilationResult.lineSeparatorPositions.length; >- lineCount += unitLineCount; >- lineDelta += unitLineCount; >- if (showProgress >- && lineDelta > 2000) { // in -log mode, dump a dot every 2000 lines compiled >- out.print('.'); >- lineDelta = 0; >- } >- } >- if (compilationResult.hasProblems() || compilationResult.hasTasks()) { >- IProblem[] problems = compilationResult.getAllProblems(); >- int count = problems.length; >- int localErrorCount = 0; >- for (int i = 0; i < count; i++) { >- if (problems[i] != null) { >- globalProblemsCount++; >- if (localErrorCount == 0) >- err.println("----------"); //$NON-NLS-1$ >- err.print( >- globalProblemsCount >- + ". " //$NON-NLS-1$ >- + (problems[i].isError() >- ? Main.bind("requestor.error") //$NON-NLS-1$ >- : Main.bind("requestor.warning"))); //$NON-NLS-1$ >- if (problems[i].isError()) { >- globalErrorsCount++; >- } else { >- globalWarningsCount++; >- } >- err.print(" "); //$NON-NLS-1$ >- err.print( >- Main.bind("requestor.in", new String(problems[i].getOriginatingFileName()))); //$NON-NLS-1$ >- try { >- err.println( >- ((DefaultProblem) problems[i]).errorReportSource( >- compilationResult.compilationUnit)); >- err.println(problems[i].getMessage()); >- } catch (Exception e) { >- err.println( >- Main.bind("requestor.notRetrieveErrorMessage", problems[i].toString())); //$NON-NLS-1$ >- } >- err.println("----------"); //$NON-NLS-1$ >- if (problems[i].isError()) >- localErrorCount++; >- } >- } >- // exit? >- if (systemExitWhenFinished && !proceedOnError && (localErrorCount > 0)) { >- err.flush(); >- out.flush(); >- System.exit(-1); >- } >- } >- outputClassFiles(compilationResult); >+ // 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()); >+ } >+ } >+ >+ // use the built-in requestor >+ return new CompilerRequestor(); > } > /* > * Build the set of compilation source units >@@ -1456,6 +1486,20 @@ > // set the non-externally configurable options. > compilerOptions.setVerboseMode(verbose); > compilerOptions.produceReferenceInfo(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: 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.58 >diff -u -r1.58 IProblem.java >--- org/eclipse/jdt/core/compiler/IProblem.java 19 Jul 2003 14:00:36 -0000 1.58 >+++ org/eclipse/jdt/core/compiler/IProblem.java 21 Jul 2003 19:32:15 -0000 >@@ -38,10 +38,23 @@ > * IndirectAccessToStaticField > * IndirectAccessToStaticMethod > * IndirectAccessToStaticType >+<<<<<<< IProblem.java > * UndocumentedEmptyBlock > * UnnecessaryCast > * UnnecessaryArgumentCast > * UnnecessaryInstanceof >+ * SAS - added the following constants >+ * StringConcat >+ * LocaleSensitiveMethod >+ * EmbeddedString >+ * EmbeddedCharacter >+ * >+======= >+ * UndocumentedEmptyBlock >+ * UnnecessaryCast >+ * UnnecessaryArgumentCast >+ * UnnecessaryInstanceof >+>>>>>>> 1.58 > ****************************************************************************/ > package org.eclipse.jdt.core.compiler; > >@@ -644,4 +657,11 @@ > // block > /** @since 3.0 */ > int UndocumentedEmptyBlock = Internal + 460; >+ >+ // internationalization >+ /** @since 3.0 */ >+ int StringConcat = Internal + 470; >+ int LocaleSensitiveMethod = Internal + 471; >+ int EmbeddedString = Internal + 472; >+ int EmbeddedCharacter = Internal + 473; > } >Index: 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 >--- org/eclipse/jdt/internal/compiler/CompilationResult.java 1 Apr 2003 11:40:31 -0000 1.30 >+++ org/eclipse/jdt/internal/compiler/CompilationResult.java 21 Jul 2003 19:32:15 -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: 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.50 >diff -u -r1.50 Compiler.java >--- org/eclipse/jdt/internal/compiler/Compiler.java 18 Jul 2003 09:36:07 -0000 1.50 >+++ org/eclipse/jdt/internal/compiler/Compiler.java 21 Jul 2003 19:32:15 -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; >@@ -534,6 +535,10 @@ > > // type checking > unit.resolve(); >+ >+ // AST checking >+ if ( checker != null) >+ unit.traverse(checker, unit.scope); > > // flow analysis > unit.analyseCode(); >Index: 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.104 >diff -u -r1.104 ProblemReporter.java >--- org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 20 Jul 2003 16:59:06 -0000 1.104 >+++ org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 21 Jul 2003 19:32:21 -0000 >@@ -508,6 +508,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: >@@ -3170,6 +3176,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: 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.77 >diff -u -r1.77 messages.properties >--- org/eclipse/jdt/internal/compiler/problem/messages.properties 19 Jul 2003 13:33:34 -0000 1.77 >+++ org/eclipse/jdt/internal/compiler/problem/messages.properties 21 Jul 2003 19:32:21 -0000 >@@ -327,4 +327,9 @@ > > 450 = {0} {1} > >-460 = Empty block should be documented >\ No newline at end of file >+460 = Empty block should be documented >+ >+470 = I18N:COS String concatenation >+471 = I18N:LSM Locale sensitive method use >+472 = I18N:EMS Embedded String Literal >+473 = I18N:EMC Embedded Character Literal >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 38332
:
5100
|
5188
|
5523
|
6147