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 2348 Details for
Bug 25092
Detect/Warn on possible user typos
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
First proposed patch
nooppatch.patch (text/plain), 4.43 KB, created by
Genady Beryozkin
on 2002-11-08 11:44:36 EST
(
hide
)
Description:
First proposed patch
Filename:
MIME Type:
Creator:
Genady Beryozkin
Created:
2002-11-08 11:44:36 EST
Size:
4.43 KB
patch
obsolete
>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.23 >diff -u -r1.23 IProblem.java >--- org/eclipse/jdt/core/compiler/IProblem.java 30 Sep 2002 14:26:01 -0000 1.23 >+++ org/eclipse/jdt/core/compiler/IProblem.java 8 Nov 2002 16:41:57 -0000 >@@ -489,4 +489,6 @@ > // detected task > /** @since 2.1 */ > int Task = Internal + 450; >+ >+ int NoOpAssignment = 498; > } >Index: org/eclipse/jdt/internal/compiler/ast/Assignment.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java,v >retrieving revision 1.22 >diff -u -r1.22 Assignment.java >--- org/eclipse/jdt/internal/compiler/ast/Assignment.java 21 Oct 2002 14:21:55 -0000 1.22 >+++ org/eclipse/jdt/internal/compiler/ast/Assignment.java 8 Nov 2002 16:41:58 -0000 >@@ -19,7 +19,7 @@ > > public Reference lhs; > public Expression expression; >- >+ public TypeBinding lhsType; > public Assignment(Expression lhs, Expression expression, int sourceEnd) { > //lhs is always a reference by construction , > //but is build as an expression ==> the checkcast cannot fail >@@ -69,6 +69,8 @@ > if (this.resolvedType == null || rhsType == null) > return null; > >+ checkNoOp(scope); >+ > // Compile-time conversion of base-types : implicit narrowing integer into byte/short/character > // may require to widen the rhs expression at runtime > if ((expression.isConstantValueOfTypeAssignableToType(rhsType, this.resolvedType) >@@ -84,6 +86,26 @@ > return null; > } > >+ Binding getBinding(Expression ref) { >+ if (ref instanceof FieldReference) { >+ return ((Reference)ref).fieldBinding(); >+ } else if (ref instanceof NameReference) { >+ return ((NameReference)ref).binding; >+ } >+ return null; >+ } >+ >+ private void checkNoOp(BlockScope scope) { >+ >+ Binding lhsBinding = getBinding(lhs); >+ Binding rhsBinding = getBinding(expression); >+ if (lhsBinding == rhsBinding) { >+ scope.problemReporter().noOpAssignment(this); >+ } >+ } >+ >+ >+ > public String toString(int tab) { > > //no () when used as a statement >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.58 >diff -u -r1.58 ProblemReporter.java >--- org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 27 Oct 2002 17:39:48 -0000 1.58 >+++ org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 8 Nov 2002 16:42:11 -0000 >@@ -549,7 +549,10 @@ > if ((warningThreshold & CompilerOptions.StaticAccessReceiver) != 0){ > return Warning; > } >- return Ignore; >+ return Ignore; >+ case IProblem.NoOpAssignment: >+ return Warning; >+ > case IProblem.Task : > return Warning; > default: >@@ -2631,6 +2634,16 @@ > location.sourceStart, > location.sourceEnd); > } >+ >+public void noOpAssignment(Assignment assignment) { >+ this.handle( >+ IProblem.NoOpAssignment, >+ new String[] {assignment.lhs.toString(), assignment.expression.toString()}, >+ new String[] {assignment.toString() }, >+ assignment.sourceStart, >+ assignment.sourceEnd); >+} >+ > public void typeMismatchErrorActualTypeExpectedType(Expression expression, TypeBinding constantType, TypeBinding expectedType) { > String constantTypeName = new String(constantType.readableName()); > String expectedTypeName = new String(expectedType.readableName()); >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.33 >diff -u -r1.33 messages.properties >--- org/eclipse/jdt/internal/compiler/problem/messages.properties 14 Oct 2002 12:36:06 -0000 1.33 >+++ org/eclipse/jdt/internal/compiler/problem/messages.properties 8 Nov 2002 16:42:01 -0000 >@@ -268,4 +268,6 @@ > > 440 = ''assert'' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on > >-450 = {0} {1} >\ No newline at end of file >+450 = {0} {1} >+ >+498 = The {0} assignment is a no-op
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 25092
: 2348