Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Conversation

@eztierney
Copy link
Contributor

Implement codehints and jump-to-def for javascript inside <script> tags in a .html file.

To support html hinting, the code strips out the non-javascript parts of the html file. We replace them with whitespace so that the offset and cursor positions don't have to be translated. Then the javascript-only contents are sent to tern for processing so that the html tags don't confuse the js parser tern uses.

Also adds a few units tests to make sure html hinting continues to work.

eztierney added 2 commits May 2, 2013 16:28
For HTML files, we replace the HTML sections with whitespace, leaving only the text of the script tags for Tern to see.
This way the offset/cursor positions don't need to be translated, which would be necessary to get jump-to-def to work.
Also fix some bugs with jump-to-def and function type hints uncovered by the tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's code very similar to this in HTMLUtils.findStyleBlocks(). Should we consolidate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterflynn good idea, will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored HTMLUtils.findStyleBlocks in eztierney@5d7dc76

eztierney added 4 commits May 3, 2013 10:00
The js code hinting code needed to find script blocks, so refactor the style block code to find any kind of block, and call that instead of having another copy of the code.  findStyleBlocks now just calls the generic method, looking for "css" blocks.

Also fixed up the block finding code to handle empty blocks, which I ran into when looking for "javascript" blocks.
Fixup branch so it will merge cleanly again.

Conflicts:
	src/extensions/default/JavaScriptCodeHints/unittests.js
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "offset" used? Can you remove the variable declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is not, will delete.

@dloverin
Copy link

dloverin commented May 9, 2013

I've reviewed the JS Code Hinting changes. Could someone in brackets review the HTMLUtils.js changes. Thanks.

@RaymondLim
Copy link
Contributor

Sure. I'll review the HTMLUtils.js changes.

@ghost ghost assigned RaymondLim May 9, 2013
@gruehle
Copy link
Member

gruehle commented May 9, 2013

To @RaymondLim for review

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update this comment (or just remove it) since it is referring to style block.

@RaymondLim
Copy link
Contributor

Done reviewing. I found only one minor nit for an old comment.

@eztierney
Copy link
Contributor Author

Updated the old comment to no longer refer to style blocks, or CSS tokens

dloverin pushed a commit that referenced this pull request May 10, 2013
[JS Code Hints] Html script hinting
@dloverin dloverin merged commit c27664b into adobe:master May 10, 2013
@dloverin
Copy link

merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants