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 262468 Details for
Bug 496207
[quickfix][eslint] quickfix for "no-self-assign" doesn't work in some cases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch including updated regression tests
496207.patch (text/plain), 4.07 KB, created by
Olivier Thomann
on 2016-06-15 14:23:55 EDT
(
hide
)
Description:
Proposed patch including updated regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2016-06-15 14:23:55 EDT
Size:
4.07 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/ternPlugins/quickfixes.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/ternPlugins/quickfixes.js >index 9a78604..6a6a3f8 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/ternPlugins/quickfixes.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/ternPlugins/quickfixes.js >@@ -278,17 +278,27 @@ define([ > var node = Finder.findNode(annot.start, file.ast, {parents:true}); > if(node) { > var p = node.parents[node.parents.length-1]; >- if(p.type === 'AssignmentExpression') { >- var end = p.range[1]; >- var tok = Finder.findToken(end, file.ast.tokens); >- if(tok) { >- //we want the next one, ignoring whitespace >- tok = file.ast.tokens[tok.index+1]; >- if(tok && tok.type === 'Punctuator' && tok.value === ';') { >- end = tok.range[1]; //clean up trailing semicolons >+ switch(p.type) { >+ case 'AssignmentExpression' : { >+ var end = p.range[1]; >+ var tokens = file.ast.tokens; >+ var tok = Finder.findToken(end, tokens); >+ if(tok) { >+ //we want the next one, ignoring whitespace >+ if((tok.type !== 'Punctuator' || tok.value !== ';') && tokens.length > tok.index + 1) { >+ tok = tokens[tok.index+1]; >+ } >+ if(tok && tok.type === 'Punctuator' && tok.value === ';') { >+ end = tok.range[1]; //clean up trailing semicolons >+ } > } >+ return {text: '', start: p.range[0], end: end}; >+ } >+ case 'VariableDeclarator' : { >+ // init is the same name as the id >+ var variableDeclarator = p; >+ return {text: '', start: variableDeclarator.id.range[1], end: variableDeclarator.range[1]}; > } >- return {text: '', start: p.range[0], end: end}; > } > } > }); >diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/quickfixTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/quickfixTests.js >index a8a8fcf..4159554 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/quickfixTests.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/quickfixTests.js >@@ -1173,7 +1173,7 @@ define([ > describe("no-self-assign", function() { > it("no-self-assign single 1", function(done) { > var rule = createTestRule("no-self-assign"); >- var expected = {value:'', start: 14, end: 23}; >+ var expected = {value:'', start: 14, end: 24}; > return getFixes({ > buffer: "var foo = 10; foo = foo;", > rule: rule, >@@ -1224,8 +1224,8 @@ define([ > it("no-self-assign multi 1", function(done) { > var rule = createTestRule("no-self-assign"); > var expected = [ >- {value:'', start: 14, end: 23}, >- {value:'', start: 40, end: 49} >+ {value:'', start: 14, end: 24}, >+ {value:'', start: 40, end: 50} > ]; > return getFixes({ > buffer: "var foo = 10; foo = foo; var bar = foo; bar = bar;", >@@ -1247,6 +1247,36 @@ define([ > callback: done > }); > }); >+ it("no-self-assign variable declarator init same as id", function(done) { >+ var rule = createTestRule("no-self-assign"); >+ var expected = {value:'', start: 7, end: 13}; >+ return getFixes({ >+ buffer: "var foo = foo;", >+ rule: rule, >+ expected: expected, >+ callback: done >+ }); >+ }); >+ it("no-self-assign variable declarator init same as id 2", function(done) { >+ var rule = createTestRule("no-self-assign"); >+ var expected = {value:'', start: 7, end: 15}; >+ return getFixes({ >+ buffer: "var foo = (foo);", >+ rule: rule, >+ expected: expected, >+ callback: done >+ }); >+ }); >+ it("no-self-assign variable declarator init same as id 3", function(done) { >+ var rule = createTestRule("no-self-assign"); >+ var expected = {value:'', start: 17, end: 25}; >+ return getFixes({ >+ buffer: "var bar = 10, foo = (foo);", >+ rule: rule, >+ expected: expected, >+ callback: done >+ }); >+ }); > }); > //NEW-PARENS > describe("new-parens", function() {
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 496207
: 262468