properly set sourceRange and astNode on inline documents #480
Conversation
src/model/document.ts
Outdated
// not have to be set awkwardly after the fact. | ||
sourceRange: SourceRange|undefined = undefined; | ||
astNode: dom5.Node|undefined = undefined; | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra semicolon
src/test/analyzer_test.ts
Outdated
const jsDoc = jsDocs.values().next().value; | ||
assert.deepEqual(jsDoc.sourceRange, { | ||
file: 'static/inline-documents/inline-documents.html', | ||
start: {line: 3, column: 2}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the CodeUnderliner rather than doing equality checking against source range
src/test/analyzer_test.ts
Outdated
assert.equal(cssDocs.size, 1); | ||
const cssDoc = cssDocs.values().next().value; | ||
assert.deepEqual(cssDoc.sourceRange, { | ||
file: 'static/inline-documents/inline-documents.html', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/test/analyzer_test.ts
Outdated
}); | ||
assert.isObject(jsDoc.astNode); | ||
assert.equal(jsDoc.astNode!.tagName, 'script'); | ||
assert.equal(jsDoc.astNode!.parentNode!.tagName, 'head'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the assertion on the parent node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chose it as a simple proxy for checking that the astNode was accurate. But having worked with the analyzer more now I feel we can assume that if the astNode is set it is accurate (at least in a larger analyzer test like this). So I'll back this out.
sourceRange
andastNode
on inlined documents./cc @rictic @justinfagnani