| Summary: | The quick fix for "missing-doc" malfunctions for js code inside a html file. | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Troy Tao <troytao> |
| Component: | JS Tools | Assignee: | Curtis Windatt <curtis.windatt.public> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | steve_northover |
| Version: | 11.0 | ||
| Target Milestone: | 12.0 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=313390a406b9fda1fa020579317d22ab939b5f65 Fixed in master There are two parts to this problem: 1) The fix always threw an error and failed to set the caret after because the fake editorContext from compilationUnit didn't include the setCaretOffset function. 2) The generate doc command tries to generate a compilation unit for the text it is given if the content type is HTML. For quick fixes, we have already created a compilation unit for the HTML contents and further calls to getText return only the Javascript contents. The fix is to modify the content type we return from the compilation unit. It only returns Javascript so its content type should be Javascript. Note that (2) would have also affected quickfixes that run the rename command. (2) Could only be reproduced after loading the page because editing the file would create a correct compilation unit that is saved in a cache. |
To reproduce this bug, first turn on the "missing-doc" rule and start with: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>test</title> <script> /*eslint-env node */ var test = { run: function() { return ; } }; console.log(test); </script> </head> </html> Notice that as long as the file is clean (no content edit since last save), the quick fix for "missing-doc" won't work. And when the file becomes dirty, the quick fix will work but with an error showing: "TypeError: editorContext.setCaretOffset is not a function" which refers to line 102 of the generateDocCommand.js