Skip to content

Commit 52f0627

Browse files
committed
New version 2.1 with enhanced comment logic.
This includes that now comments and be folded based on section comments like (* ::Section:: *). Beside this improved highlighter and completion logic for comments.
1 parent 9f776ab commit 52f0627

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

resources/META-INF/plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<id>de.halirutan.mathematica</id>
2424
<name>Mathematica Support</name>
2525
<category>Custom Language</category>
26-
<version>2.0.32</version>
26+
<version>2.1</version>
2727
<idea-version since-build="163"/>
2828
<vendor email="patrick@halirutan.de" url="http://mathematicaplugin.halirutan.de">Patrick Scheibe</vendor>
2929
<depends>com.intellij.modules.lang</depends>
@@ -67,6 +67,7 @@
6767
<i>New features and bug-fixes:</i>
6868
<br/>
6969
<ul>
70+
<li>Code folding based on section comments like (* ::Section:: *)</li>
7071
<li>SurroundWith (Ctrl+Alt+T) will now do something useful when pressed without an active selection</li>
7172
<li>Added Ctrl+Space completion inside comments</li>
7273
<li>Reimplemented parsing of comments and comment annotation</li>

src/de/halirutan/mathematica/codeinsight/folding/MathematicaExpressionFoldingBuilder.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ private void collectCommentRegion(@NotNull ASTNode node,
195195
final int currentLine = document.getLineNumber(comment.getTextOffset());
196196
int endOffset = document.getTextLength();
197197

198+
if (currentLine < document.getLineCount() - 1) {
199+
final PsiComment nextLineComment = PsiTreeUtil.findElementOfClassAtRange(
200+
file,
201+
document.getLineStartOffset(currentLine + 1),
202+
document.getLineEndOffset(currentLine + 1),
203+
PsiComment.class
204+
);
205+
if (nextLineComment != null && !Comments.isCorrectSectionComment(nextLineComment)) {
206+
placeHolderText.append(Comments.getStrippedText(nextLineComment));
207+
} else {
208+
placeHolderText.append("No description given");
209+
}
210+
}
211+
198212
for (int i = currentLine + 1; i < document.getLineCount(); i++) {
199213
int start = document.getLineStartOffset(i);
200214
int end = document.getLineEndOffset(i);
@@ -203,19 +217,6 @@ private void collectCommentRegion(@NotNull ASTNode node,
203217
final CommentStyle commentStyle = Comments.getStyle(commentsInLine);
204218
if (commentStyle != null && commentStyle.compareTo(style) <= 0) {
205219
endOffset = start - 1;
206-
if (i < document.getLineCount() - 1) {
207-
final PsiComment nextLineComment = PsiTreeUtil.findElementOfClassAtRange(
208-
file,
209-
document.getLineStartOffset(i + 1),
210-
document.getLineEndOffset(i + 1),
211-
PsiComment.class
212-
);
213-
if (nextLineComment != null && !Comments.isCorrectSectionComment(nextLineComment)) {
214-
placeHolderText.append(Comments.getStrippedText(nextLineComment));
215-
} else {
216-
placeHolderText.append("No description given");
217-
}
218-
}
219220
break;
220221
}
221222
}

0 commit comments

Comments
 (0)