Open muradu opened 10 years ago
I didn't look closely enough: there's actually a + in both cases, but the annotation body still can't be unfolded (clicking to unfold it folds the entire declaration).
Actually, using the Eclipse command Expand All
does unfold the doc, but the problem reverses itself with -s instead of +s: now the annotation body can't unfold.
Seems there is a problem with nested folds perhaps? Just guessing, We need to have a look at this.
Seems that way. I don't know enough to determine if the problem can be fixed in this project or if the issue belongs to Eclipse IMP.
Yeah, the folding/unfolding of @doc
is quite often wonky: you start typing it, it immediately folds, you need to reopen it to keep going, and then it folds itself at seemingly random moments, but when you try to fold it yourself by clicking on plusses and minuses, the result sometimes eats up parts of your code.
…and people still ask me why I am not convinced by projectional editors…
@vadim do you perhaps have some time to look at it?
On Fri, Mar 14, 2014 at 1:44 PM, Vadim Zaytsev notifications@github.comwrote:
Yeah, the folding/unfolding of @doc is quite often wonky: you start typing it, it immediately folds, you need to reopen it to keep going, and then it folds itself at seemingly random moments, but when you try to fold it yourself by clicking on plusses and minuses, the result sometimes eats up parts of your code.
...and people still ask me why I am not convinced by projectional editors...
Reply to this email directly or view it on GitHubhttps://github.com/cwi-swat/rascal/issues/521#issuecomment-37642994 .
Jurgen Vinju
Universiteit van Amsterdam
www: http://jurgen.vinju.org, http://www.rascal-mpl.org, http://twitter.com/jurgenvinju skype: jurgen.vinju
This problem is caused by having two collapsible annotations starting on the same line (i.e. they have the same startOffset). This it what happens when you declare a function + documentation. This explains why the collapsed/not-collapsed icon does not change when you click it. By clicking it, you will collapse the bottom block (the method, it will 'eat' your code), but the icon that is showing is for the documentation.
Example:
module \test
@doc{blala
}
void bla(){
}
With FolderBase.fDebugMode = true
console shows this:
Collecting folding annotations for src/test.rsc
Adding folding annotation for extent [16:33]
Adding folding annotation for extent [16:15]
Annotation @ 16:33
Annotation @ 16:15
The method FolderBase.makeAnnotation(Object n, boolean collapsed)
does not use the correct startOffset for method declarations. The method declaration AST node contains the AST node of the @doc{ .. } node, hence the location of both will have the same startOffset.
In the example above, if I manually change startOffset of the first one (16:33) to 40, folding of both the method declaration and documentation works just fine.
In order to fix this, we would need some way to get the correct startOffset for the actual method declaration. The closest thing I can find in the AST would be the location of the visibility modifier, but I don't think using that for startOffset would be a good solution.
For example, opening Grammar.rsc in Eclipse results in the following text displayed in the editor:
The documentation body is folded. Rather than a + besides the annotation, there is a -, clicking which folds the above to the following:
As a result, there is no way to unfold the doc annotation in the editor.