-
Notifications
You must be signed in to change notification settings - Fork 21
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
Show Views in the Class' Structure tool window #113
Conversation
Whoa. This is interesting. Not what I imagined this feature to be. It pretty much adds the whole tree of the stapled class/view to the structured view of the other side. 🤔 The way I understand Stapler is that views are kinda like methods of the Class (e.g., |
<!-- jelly file definition parser --> | ||
<lang.parserDefinition language="Jelly" | ||
implementationClass="org.kohsuke.stapler.idea.language.JellyParserDefinition"/> | ||
<!-- Additional link to jelly file from a java file --> | ||
<lang.structureViewExtension implementation="org.kohsuke.stapler.idea.extension.JavaStructureViewExtension"/> | ||
<!-- Additional link to java file from a jelly file --> | ||
<lang.structureViewExtension implementation="org.kohsuke.stapler.idea.extension.JellyStructureViewExtension"/> |
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.
I've been on the fence about this for a while now. I am just unsure what kind of XML support features are lost versus what is gained by this.
Given structure view extension is "attached" to a PSI class, you kinda needed this. That said, you could have probably just used the XmlDocument.class
and did the JellyFileTypeSchema.isJelly(parent.getContainingFile())
in the getChildren
method.
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.
Actually the JellyLanguage
extends the XMLLanguage
, therefore all XML features are included in Jelly language.
With this, checking the file instance against JellyFile
is enough.
More, this method JellyFileTypeSchema.isJelly(parent.getContainingFile())
simply checks the extension and we redeclare jelly
and jellytag
, but we shouldn't anymore as it's already linked/declared here.
i.e : if we add a new extension for jelly, like jellyanothertag
, we would need to update plugin.xml
, and also JellyFileTypeSchema
, which sounds like a duplicate/overhead to me (?)
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.
I see what you mean. All the File Type, Language and PSI classes extend corresponding XML ones, so theoretically all the extensions that look for those types should still work with these derived types. I suspected that this type of change is necessary to get proper JEXL integration, but I am not sure, and JEXL support is just too much work.
I got burned by doing incremental changes to the file types before. You can see it if you read through https://github.com/jenkinsci/idea-stapler-plugin/releases
There is also a question of what happens if the end-user made a manual association between jelly
extension and XML file type. From my previous experience, manual assosciation takes precedence, so the introduction of a new file type might break some old setups.
I'll need to ponder and test some more.
which sounds like a duplicate/overhead to me (?)
It was duplication even before your change. It looked unavoidable. I used JavaFX plugin for inspiration when I implemented the file type checking in that way. With the introduction of the Jelly File type, those public static predicates should no longer be needed.
src/main/java/org/kohsuke/stapler/idea/extension/JavaStructureViewExtension.java
Outdated
Show resolved
Hide resolved
src/main/java/org/kohsuke/stapler/idea/extension/AbstractStructureViewExtension.java
Outdated
Show resolved
Hide resolved
src/main/java/org/kohsuke/stapler/idea/extension/JavaStructureViewExtension.java
Outdated
Show resolved
Hide resolved
It would be nice to treat groovy views the same. |
- additional LinkJellyFileImpl to avoid infinite loops when displaying structure view
@jglick, not really. GotoViewAction is analogous but less feature reach. I wrote down Issue #12 to note the improvements that should get it closer to NetBeans analogue. |
|
Could be part of another dev? |
@duemir: new jelly icon added |
Build failed: |
Ok now |
I'll build a snapshot and run it locally for a few days to see if I notice any regressions or anything. |
@duemir : spotted an issue when creating unit tests : feature was not working correctly with nested inner classes. |
@jgreffe, the plugin is lacking in terms of tests, so any new ones are welcome. I'll pull and re-build and try to review. |
src/test/java/org/kohsuke/stapler/idea/mock/PsiElementMockWrapper.java
Outdated
Show resolved
Hide resolved
@duemir : pushed unchecked warning fix |
src/main/java/org/kohsuke/stapler/idea/language/JellyFileType.java
Outdated
Show resolved
Hide resolved
…java Co-authored-by: Denys Digtiar <duemir@gmail.com>
src/main/java/org/kohsuke/stapler/idea/extension/JavaStructureViewExtension.java
Show resolved
Hide resolved
… obsolete unit tests
That last commit wasn't necessary. It just adds more noise to an already large review. |
This reverts commit 1ef8e38.
@duemir: reverted last commit |
src/main/java/org/kohsuke/stapler/idea/language/JellyParserDefinition.java
Outdated
Show resolved
Hide resolved
🎊 |
Fixes #102
from java file
src/main/java/this/is/a/test.java
, we look for all jelly files contained insrc/main/resources/this/is/a/test
directoryfrom jelly file
src/main/resources/another/test/*.jelly
, we look for java classsrc/main/java/another/test.java
Manual tests with Intellij 2022.1.