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 26010 Details for
Bug 53773
[plan] [compiler] Warning on assignments to parameters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Suggested patch for compiler
org.eclipse.jdt.core_01.txt (text/plain), 11.61 KB, created by
Maxime Daniel
on 2005-08-11 06:02:02 EDT
(
hide
)
Description:
Suggested patch for compiler
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2005-08-11 06:02:02 EDT
Size:
11.61 KB
patch
obsolete
>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.199.2.2 >diff -u -r1.199.2.2 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 28 Jul 2005 17:08:41 -0000 1.199.2.2 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 10 Aug 2005 16:27:50 -0000 >@@ -1870,6 +1870,10 @@ > this.options.put( > CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, > isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); >+ } else if (token.equals("parameter-assignment")) { //$NON-NLS-1$ >+ this.options.put( >+ CompilerOptions.OPTION_ReportParameterAssignment, >+ isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE); > } else { > throw new InvalidInputException(Main.bind("configure.invalidWarning", token)); //$NON-NLS-1$ > } >Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v >retrieving revision 1.440.2.3 >diff -u -r1.440.2.3 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 2 Aug 2005 20:33:42 -0000 1.440.2.3 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 10 Aug 2005 16:27:50 -0000 >@@ -152,6 +152,7 @@ > \ noEffectAssign + assignment without effect\n\ > \ null missing or redundant null check\n\ > \ over-ann missing @Override annotation\n\ >+\ parameter-assignment assignment to a parameter\n\ > \ pkgDefaultMethod + attempt to override package-default method\n\ > \ semicolon unnecessary semicolon, empty statement\n\ > \ serial + missing serialVersionUID\n\ >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.150.2.5 >diff -u -r1.150.2.5 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 7 Jul 2005 10:52:49 -0000 1.150.2.5 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 10 Aug 2005 16:27:50 -0000 >@@ -72,6 +72,8 @@ > * IBM Corporation - added the following constants > * IllegalUsageOfQualifiedTypeReference > * InvalidDigit >+ * IBM Corporation - added the following constants >+ * ParameterAssignment > *******************************************************************************/ > package org.eclipse.jdt.core.compiler; > >@@ -287,7 +289,10 @@ > int TooManyArrayDimensions = Internal + 68; > /** @since 2.1 */ > int BytecodeExceeds64KLimitForConstructor = Internal + 69; >- >+ /** @since 3.2 */ >+ int ParameterAssignment = Internal + 860; >+ // REVIEW argument would be more homogeneous with existing code, but JLS puts a clear emphasis on parameter -- see p.211 for parameter/argument disc. >+ > // fields > int UndefinedField = FieldRelated + 70; > int NotVisibleField = FieldRelated + 71; >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.73.2.3 >diff -u -r1.73.2.3 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 1 Jul 2005 14:17:30 -0000 1.73.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 10 Aug 2005 16:27:50 -0000 >@@ -119,6 +119,9 @@ > currentScope.problemReporter().cannotAssignToFinalOuterLocal(localBinding, this); > } > } >+ else /* avoid double diagnostic */ if (localBinding.isArgument) { >+ currentScope.problemReporter().parameterAssignment(localBinding, this); >+ } > flowInfo.markAsDefinitelyAssigned(localBinding); > } > manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo); >Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v >retrieving revision 1.141 >diff -u -r1.141 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 22 Jun 2005 15:44:23 -0000 1.141 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 10 Aug 2005 16:27:51 -0000 >@@ -101,6 +101,7 @@ > public static final String OPTION_ReportDiscouragedReference = "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$ > public static final String OPTION_SuppressWarnings = "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$ > public static final String OPTION_ReportUnhandledWarningToken = "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; //$NON-NLS-1$ >+ public static final String OPTION_ReportParameterAssignment = "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$ > > // Backward compatibility > public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$ >@@ -180,6 +181,7 @@ > public static final long MissingDeprecatedAnnotation = ASTNode.Bit43L; > public static final long DiscouragedReference = ASTNode.Bit44L; > public static final long UnhandledWarningToken = ASTNode.Bit45L; >+ public static final long ParameterAssignment = ASTNode.Bit46L; > > // TODO (olivier) remove once http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21540 is fixed > private static final int IntMissingSerialVersion = (int) (MissingSerialVersion >>> 32); >@@ -187,6 +189,7 @@ > private static final int IntTypeParameterHiding = (int) (TypeParameterHiding >>> 32); > private static final int IntIncompleteEnumSwitch = (int) (IncompleteEnumSwitch >>> 32); > private static final int IntMissingDeprecatedAnnotation = (int) (MissingDeprecatedAnnotation >>> 32); >+ private static final int IntParameterAssignment = (int) (ParameterAssignment >>> 32); > > // Default severity level for handlers > public long errorThreshold = 0; >@@ -310,7 +313,7 @@ > } > > public Map getMap() { >- Map optionsMap = new HashMap(30); >+ Map optionsMap = new HashMap(96, 1.0f); > optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & Vars) != 0 ? GENERATE : DO_NOT_GENERATE); > optionsMap.put(OPTION_LineNumberAttribute, (this.produceDebugAttributes & Lines) != 0 ? GENERATE : DO_NOT_GENERATE); > optionsMap.put(OPTION_SourceFileAttribute, (this.produceDebugAttributes & Source) != 0 ? GENERATE : DO_NOT_GENERATE); >@@ -387,6 +390,7 @@ > optionsMap.put(OPTION_ReportNullReference, getSeverityString(NullReference)); > optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED); > optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken)); >+ optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment)); > return optionsMap; > } > >@@ -618,6 +622,7 @@ > if ((optionValue = optionsMap.get(OPTION_ReportMissingDeprecatedAnnotation)) != null) updateSeverity(MissingDeprecatedAnnotation, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportIncompleteEnumSwitch)) != null) updateSeverity(IncompleteEnumSwitch, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportUnhandledWarningToken)) != null) updateSeverity(UnhandledWarningToken, optionValue); >+ if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue); > > // Javadoc options > if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) { >@@ -780,6 +785,7 @@ > buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$ > buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$ > buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$ >+ buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$ > return buf.toString(); > } > >@@ -875,6 +881,7 @@ > OPTION_ReportUnusedPrivateMember, > OPTION_ReportVarargsArgumentNeedCast, > OPTION_ReportUnhandledWarningToken, >+ OPTION_ReportParameterAssignment, > }; > return result; > } >@@ -923,6 +930,8 @@ > return "incomplete-switch"; //$NON-NLS-1$ > case IntMissingDeprecatedAnnotation : > return "dep-ann"; //$NON-NLS-1$ >+ case IntParameterAssignment : >+ return "parameter-assignment"; //$NON-NLS-1$ > } > } > return null; >@@ -959,6 +968,10 @@ > if ("nls".equals(warningToken)) //$NON-NLS-1$ > return NonExternalizedString; > break; >+ case 'p' : >+ if ("parameter-assignment".equals(warningToken)) //$NON-NLS-1$ >+ return ParameterAssignment; >+ break; > case 's' : > if ("serial".equals(warningToken)) //$NON-NLS-1$ > return MissingSerialVersion; >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.252.2.5 >diff -u -r1.252.2.5 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jul 2005 10:52:49 -0000 1.252.2.5 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 10 Aug 2005 16:27:52 -0000 >@@ -1447,6 +1447,9 @@ > > case IProblem.JavadocMissing: > return CompilerOptions.MissingJavadocComments; >+ >+ case IProblem.ParameterAssignment: >+ return CompilerOptions.ParameterAssignment; > } > return 0; > >@@ -4328,6 +4331,15 @@ > compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceStart, > compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceEnd); > } >+public void parameterAssignment(LocalVariableBinding local, ASTNode location) { >+ String[] arguments = new String[] { new String(local.readableName())}; >+ this.handle( >+ IProblem.ParameterAssignment, >+ arguments, >+ arguments, >+ location.sourceStart, >+ location.sourceEnd); >+} > private String parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort) { > StringBuffer nameBuffer = new StringBuffer(10); > if (typeVariable.firstBound == typeVariable.superclass) { >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.178.2.3 >diff -u -r1.178.2.3 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 6 Jul 2005 16:17:00 -0000 1.178.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 10 Aug 2005 16:27:52 -0000 >@@ -553,3 +553,6 @@ > 857 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}> > 858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4}) > 859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}> >+ >+860 = The parameter {0} should not be assigned >+### REVIEW the 'accidental' seems extraneous here (see assignment in condition)
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 53773
:
26010
|
26011
|
30477
|
32461
|
32684