Skip to content

Commit f370ece

Browse files
committed
Release 2.1.9, build for 222.x
1 parent a0e4c07 commit f370ece

File tree

7 files changed

+40
-30
lines changed

7 files changed

+40
-30
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# SequenceDiagram Changelog
22

33
## [Unreleased]
4+
## [2.1.9]
5+
### Changed
6+
- Build for 222.x
7+
- Add parent CallStack parameter to IGenerator
8+
49
## [2.1.8]
510
### Fixed
611
- Unable to export large images #122, #119

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
pluginGroup = vanstudio
55
pluginName = SequenceDiagram
6-
pluginVersion = 2.1.8
6+
pluginVersion = 2.1.9
77

88
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
99
# for insight into build numbers and IntelliJ Platform versions.
1010
pluginSinceBuild = 201
11-
pluginUntilBuild = 221.*
11+
pluginUntilBuild = 222.*
1212

1313
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
1414
# See https://jb.gg/intellij-platform-builds-list for available build versions.
15-
pluginVerifierIdeVersions = 2020.1.4, 2020.2.4, 2020.3.4, 2021.1.3, 2021.2.2
15+
pluginVerifierIdeVersions = 2020.1.4, 2020.2.4, 2020.3.4, 2021.1.3, 2021.2.2, 2022.1.2
1616

1717
platformType = IC
1818
platformVersion = 2020.2.4

src/main/java/org/intellij/sequencer/SequencePanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void generate() {
146146
true);
147147
ReadAction
148148
.nonBlocking(() -> {
149-
final CallStack callStack = generator.generate(psiElement);
149+
final CallStack callStack = generator.generate(psiElement, null);
150150
buildNaviIndex(callStack, "1");
151151
_titleName = callStack.getMethod().getTitleName();
152152
generate(callStack.generateSequence());
@@ -177,7 +177,7 @@ public String generatePumlMmd(String ext) {
177177

178178
IGenerator generator = GeneratorFactory.createGenerator(psiElement.getLanguage(), _sequenceParams);
179179

180-
final CallStack callStack = generator.generate(psiElement);
180+
final CallStack callStack = generator.generate(psiElement, null);
181181

182182
if ("mmd".equalsIgnoreCase(ext))
183183
return callStack.generateMmd();

src/main/java/org/intellij/sequencer/generator/CallStack.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ public CallStack methodCall(@NotNull MethodDescription method) {
2929
return callStack;
3030
}
3131

32-
public CallStack merge(CallStack callStack) {
33-
callStack.setParent(this);
34-
_calls.add(callStack);
35-
return this;
36-
}
37-
3832
private void setParent(CallStack callStack) {
3933
this._parent = callStack;
4034
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package org.intellij.sequencer.generator;
22

33
import com.intellij.psi.PsiElement;
4-
import com.intellij.psi.PsiMethod;
4+
import org.jetbrains.annotations.Nullable;
55

66
public interface IGenerator {
7-
CallStack generate(PsiElement psiElement);
7+
/**
8+
* Generate <code>CallStack</code> based on <code>PsiElement</code>.
9+
* @param psiElement instanceof PsiMethod, KtFunction
10+
* @param parent current CallStack or null if called from UI
11+
* @return <code>CallStack</code> includes method call of FsiMethod/KtFunction and calls in its body.
12+
*/
13+
CallStack generate(PsiElement psiElement, @Nullable CallStack parent);
814
}

src/main/java/org/intellij/sequencer/generator/KtSequenceGenerator.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public KtSequenceGenerator(SequenceParams params, int offset, int depth) {
4343
}
4444

4545
@Override
46-
public CallStack generate(PsiElement psiElement) {
46+
public CallStack generate(PsiElement psiElement, CallStack parent) {
47+
if (parent != null) {
48+
topStack = parent;
49+
currentStack = topStack;
50+
}
51+
4752
if (LOGGER.isDebugEnabled()) {
4853
LOGGER.debug("[generate]" + psiElement.getText());
4954
}
@@ -78,21 +83,19 @@ private void generateClass(KtClass psiElement, int textOffset) {
7883
makeMethodCallExceptCurrentStackIsRecursive(method);
7984
}
8085

81-
public CallStack generate(KtFunction ktFunction) {
86+
private CallStack generate(KtFunction ktFunction) {
8287
ktFunction.accept(this);
8388
return topStack;
8489
}
8590

86-
public CallStack generate(PsiMethod psiMethod) {
91+
private CallStack generate(PsiMethod psiMethod) {
8792
final SequenceGenerator sequenceGenerator =
8893
offsetStack.isEmpty() ? new SequenceGenerator(params) : new SequenceGenerator(params, offsetStack.pop(), depth);
89-
CallStack javaCall = sequenceGenerator.generate(psiMethod);
94+
CallStack javaCall = sequenceGenerator.generate(psiMethod, currentStack);
9095
LOGGER.debug("[JAVACall]:" + javaCall.generateText());
9196
if (topStack == null) {
9297
topStack = javaCall;
9398
currentStack = topStack;
94-
} else {
95-
currentStack.merge(javaCall);
9699
}
97100
return topStack;
98101
}
@@ -153,8 +156,8 @@ public void visitCallExpression(@NotNull KtCallExpression expression) {
153156

154157
@Override
155158
public void visitObjectLiteralExpression(@NotNull KtObjectLiteralExpression expression) {
156-
CallStack objLiteralExpr = new KtSequenceGenerator(params).generate(expression.getObjectDeclaration());
157-
currentStack = currentStack.merge(objLiteralExpr);
159+
CallStack objLiteralExpr = new KtSequenceGenerator(params).generate(expression.getObjectDeclaration(), currentStack);
160+
//currentStack = currentStack.methodCall(objLiteralExpr);
158161
//super.visitObjectLiteralExpression(expression);
159162
}
160163

@@ -182,7 +185,7 @@ private void methodCall(PsiElement psiElement, int offset) {
182185
depth++;
183186
LOGGER.debug("+ depth = " + depth + " method = " + psiElement.getText());
184187
offsetStack.push(offset);
185-
generate(psiElement);
188+
generate(psiElement,null); // here, No NEW Generator created, call with null
186189
depth--;
187190
LOGGER.debug("- depth = " + depth + " method = " + psiElement.getText());
188191
currentStack = oldStack;

src/main/java/org/intellij/sequencer/generator/SequenceGenerator.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ public SequenceGenerator(SequenceParams params, int offset, int depth) {
3737
}
3838

3939
@Override
40-
public CallStack generate(PsiElement psiElement) {
40+
public CallStack generate(PsiElement psiElement, CallStack parent) {
41+
if (parent != null) {
42+
topStack = parent;
43+
currentStack = topStack;
44+
}
45+
4146
if (psiElement instanceof PsiMethod)
4247
return generate((PsiMethod) psiElement);
4348
else if (psiElement instanceof PsiLambdaExpression) {
@@ -55,14 +60,14 @@ else if (psiElement instanceof PsiLambdaExpression) {
5560
* @param expression lambda expression
5661
* @return CallStack
5762
*/
58-
public CallStack generate(PsiLambdaExpression expression) {
63+
private CallStack generate(PsiLambdaExpression expression) {
5964
MethodDescription method = createMethod(expression);
6065
makeMethodCallExceptCurrentStackIsRecursive(method);
6166
super.visitLambdaExpression(expression);
6267
return topStack;
6368
}
6469

65-
public CallStack generate(PsiMethod psiMethod) {
70+
private CallStack generate(PsiMethod psiMethod) {
6671
if (psiMethod.getLanguage().equals(JavaLanguage.INSTANCE)) {
6772
return generateJava(psiMethod);
6873
} else if (psiMethod.getLanguage().equals(KotlinLanguage.INSTANCE)) {
@@ -82,12 +87,10 @@ private CallStack generateKotlin(PsiMethod psiMethod) {
8287

8388
final KtSequenceGenerator ktSequenceGenerator =
8489
offsetStack.isEmpty() ? new KtSequenceGenerator(params) : new KtSequenceGenerator(params, offsetStack.pop(), depth);
85-
CallStack kotlinCall = ktSequenceGenerator.generate(psiMethod.getNavigationElement());
90+
CallStack kotlinCall = ktSequenceGenerator.generate(psiMethod.getNavigationElement(), currentStack);
8691
if (topStack == null) {
8792
topStack = kotlinCall;
8893
currentStack = topStack;
89-
} else {
90-
currentStack.merge(kotlinCall);
9194
}
9295
return topStack;
9396
}
@@ -334,8 +337,7 @@ public void visitAssignmentExpression(PsiAssignmentExpression expression) {
334337

335338
@Override
336339
public void visitLambdaExpression(PsiLambdaExpression expression) {
337-
CallStack lambdaExpr = new SequenceGenerator(params).generate(expression);
338-
currentStack = currentStack.merge(lambdaExpr);
340+
new SequenceGenerator(params).generate(expression, currentStack);
339341
}
340342

341343
private boolean makeMethodCallExceptCurrentStackIsRecursive(MethodDescription method) {

0 commit comments

Comments
 (0)