Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix emmet bug not inserting the correct template #31

Closed
wants to merge 1 commit into from

Conversation

unlocomqx
Copy link
Contributor

Somewhat hacky but should fix #19

Debug info below

In
com.intellij.codeInsight.template.emmet.XmlEmmetParser#getDefaultTemplateKey
then
com.intellij.codeInsight.template.emmet.ZenCodingUtil#isHtml ,
the language is checked and must be HTML or XML and so on
To pass that condition, you need to override getBaseLanguage in SvelteLanguage and return HtmlLanguage.INSTANCE

Even so, emmet fails because it creates the wrong dummy file type (SvelteFile instead of HTML File)
This is because it reads the file language (which is SvelteLanguage) and doesn't look for a base language that is HTML
So then com.intellij.codeInsight.template.emmet.tokens.TemplateToken#getXmlTag fails to find the XML tag that was added dynamically and null is returned
screenshot_16

So basically com.intellij.codeInsight.template.emmet.tokens.TemplateToken#setTemplateText should use the HTML language instead of the file language which it gets through callback.getFile().getLanguage()

Or we should find a way to allow PsiTreeUtil to find an XmlTag inside HTML_FRAGMENT elements

@unlocomqx unlocomqx force-pushed the emmet branch 2 times, most recently from d295fb8 to e051257 Compare July 16, 2019 11:21
@nightwolfz
Copy link

@unlocomqx Could you release a jar somewhere with all your changes? I can't get anything to build (my knowledge of java = 0) and @tomblachut seems to be taking a long holiday

@unlocomqx
Copy link
Contributor Author

I will merge my PR's in one branch and produce a JAR to have it installed. I need that as well

@unlocomqx
Copy link
Contributor Author

@nightwolfz Upon testing with other PR's, this PR seems to break some functionality
I will close it for now and look for a better way
If @tiatin could provide an installable package from my install branch, that would be awesome
I couldn't build because I ran into issues
Here's the install branch https://github.com/unlocomqx/svelte-intellij/tree/install

@unlocomqx unlocomqx closed this Jul 17, 2019
@tiatin
Copy link

tiatin commented Jul 18, 2019

@unlocomqx - yesterday I already merged some your PRs (and I skipped this "emmet" one) into test branch https://github.com/tiatin/svelte-intellij. I also merged #18, but not sure if it is complete or not. And I also ran into issue with building. Reason was in old idea version. Updating versions fixed the build: tiatin@92ef521. And I created a release based on this test branch: https://github.com/tiatin/svelte-intellij/releases/tag/v0.7.1.

So far I can tell that your PR #30 seems not working (maybe #18 has influence on this, not yet sure): on:click is still highlighted with a tool-tip "Attribute on:click is not allowed here". But one thing was fixed for me: correct code formatting for {#each, {#if, etc. I guess adding "{" and "}" into <HTML_TAG> made parser to understand such constructions as HTML tags, and now auto-code formatting works fine with them.

I also have such strange issue:
eachIssue

Also
onClick
It would be nice to have an option to navigate to openActivityPopup by ctrl+clicking it.

Later today I will build your install branch and will let you know, but I will update versions like this tiatin@92ef521 if you don't mind, otherwise I will fail to build.

Update: actually #30 works. Its goal was to fix {} without quotes but not on:click, so we are fine here.

@tiatin
Copy link

tiatin commented Jul 18, 2019

@unlocomqx @nightwolfz - release based on install branch: https://github.com/tiatin/svelte-intellij/releases/tag/v0.7.2. It has the same issues with store variables and on:click as in 0.7.1. But at least auto-tag-complete and auto-import-complete work.

@unlocomqx
Copy link
Contributor Author

Thanks for the build, I will try your commit to successfully build it as well
I couldn't figure out resolving JS references in attributes and interpolations because they're inside a CODE_FRAGMENT and I don't quite understand that part just yet
Basically the IDE can't find JS Elements or HTML Elements inside the CODE_FRAGMENT, that's as far as I understood from debugging the API
What's the issue which has most priority in your opinion?

@tiatin
Copy link

tiatin commented Jul 18, 2019

Code navigation is a nice feature, but I would update lexer in first priority to avoid incorrect syntax highlights. I will try to fix it myself as well. Thank you!

@unlocomqx
Copy link
Contributor Author

I don't fully understand the lexer part just yet. If you make any progress, I will surely learn from it :))

@tomblachut
Copy link
Owner

tomblachut commented Jul 18, 2019

@nightwolfz @tiatin @nightwolfz I'm back from the dead (actually from deadline at work but I guess it's the same). I have another upcoming deadline so it's not so great but I'll try to be responsive.

Let me know how can I help you understand codebase.

@tiatin about updating versions. It's strange, because for me it works. I wanted to lock versions so everyone will use the same build but maybe it would be better to use latest snapshot in light of your issues.

#18 requied some testing. I didn't want to rush and break everyones IDEs.

@unlocomqx
Copy link
Contributor Author

@tomblachut not to worry at all, I also get drowned in work sometimes so I know what it's like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emmet is not working as expected
4 participants