-
Notifications
You must be signed in to change notification settings - Fork 14
Code Folding issue #100 #130
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
base: main
Are you sure you want to change the base?
Conversation
A few more things worth mentioning:
Screen.Recording.2025-03-02.at.19.18.24.movThis seems to be a common issue, e.g. see this forum post. We could not find a way to solve this issue completely.
|
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.
What are theese fleet files for?
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.
They weren't supposed to be there. I have removed the files related to task 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.
- How does it work with nested features?
- Did you try changing the the code annotation language files in a manner related to this post:
https://platform.jetbrains.com/t/injected-language-tags-that-sorounds-base-code/490
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.
- Nested features can also be folded individually. Basically every line with a begin marker can be folded up until its corresponding end marker. The placeholder text always contains the name of the outer feature but it can be changed to contain the names of all nested feature by modifying the FeatureLocation classes to also store the nested feature locations.
- The project already has a language injector (CodeAnnotationInjector) so we didn't have to write one. But: to create a folding region, a root node has to be passed:
new FoldingDescriptor(
root,
range,
group,
placeholder);
We discovered that this doesn't necessarily need to be related to the end node in the AST (otherwise it wouldn't work with java language). The problem is rather that this root node cannot be located in the file since (from our observations) its position seems to be relative to the injected code. Of course the line numbers can be gotten from the feature file mappings but the folding descriptor also needs the root node to exist in the given range. We tried folding every possible AST node (with all possible ranges from FeatureFileMapping) and nothing happened. We did experiment a lot with both language options but since java worked we didn't see the need to investigate the language injection thing further. And the overriding problem would still be there regardless of the language.
|
||
<!-- &begin[CodeFolding] --> | ||
<lang.foldingBuilder | ||
language="JAVA" order="first" |
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.
What happens if we have someother language like xml or C#?
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.
Then nothing happens unless there is XML/C# code in the project files. The folding builder only detects PsiElements in the specified language and calls buildFoldRegions()
on them
df9041a
to
51575d6
Compare
Added a FoldingBuilder
fixed a bug in featureLocationManager
Motivation and description of the problem to be solved:
IntelliJ supports the feature of folding code from e.g., classes or methods which hides the code related to the class or method. Using this mechanism, it may be beneficial in some situations to be able to hide code to a specific feature.
During implementation it has come to light that the featureLocationBlocks did not work correctly; only the last annotation block of any given feature in a file would be saved as a featureLocationBlock. The fault lay with the add method of the FeatureFileMapping Class; Given a feature and a file path, any featureLocationBlock with the same feature and file path after the first featureLocationBlock would overwrite it's previous entry instead of being added. This issue has been fixed.
Related Issue
Related issue: #100
##Implemented Functionality
We developed a feature of code folding that specifically allows folding of feature annotation blocks. Any feature annotation block (that is any block that is saved as a featureLocationBlock) can now be folded. When folded, it will instead display the feature of the feature annotation block which has been folded. Feature annotation lines are not foldable however. This implementation is a new feature with non breaking change.
The user can use folding to "fold away" currently irrelevant and/or finished features. This could also help the user's orientation when searching for specific features.
How Has This Been Tested?
Various manual integration testing has been done using a simulated environment using the plugin. Console logs and stack traces have been referenced to confirm expected inner workings and resulting effects.
Screenshots (if appropriate):
Types of changes
Checklist:
Demo Link: https://youtu.be/WekOyfbLxy0