Skip to content

Commit

Permalink
Release 2.1.9, build for 222.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanco committed Jun 4, 2022
1 parent a0e4c07 commit f370ece
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# SequenceDiagram Changelog

## [Unreleased]
## [2.1.9]
### Changed
- Build for 222.x
- Add parent CallStack parameter to IGenerator

## [2.1.8]
### Fixed
- Unable to export large images #122, #119
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

pluginGroup = vanstudio
pluginName = SequenceDiagram
pluginVersion = 2.1.8
pluginVersion = 2.1.9

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

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

platformType = IC
platformVersion = 2020.2.4
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/intellij/sequencer/SequencePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void generate() {
true);
ReadAction
.nonBlocking(() -> {
final CallStack callStack = generator.generate(psiElement);
final CallStack callStack = generator.generate(psiElement, null);
buildNaviIndex(callStack, "1");
_titleName = callStack.getMethod().getTitleName();
generate(callStack.generateSequence());
Expand Down Expand Up @@ -177,7 +177,7 @@ public String generatePumlMmd(String ext) {

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

final CallStack callStack = generator.generate(psiElement);
final CallStack callStack = generator.generate(psiElement, null);

if ("mmd".equalsIgnoreCase(ext))
return callStack.generateMmd();
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/intellij/sequencer/generator/CallStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ public CallStack methodCall(@NotNull MethodDescription method) {
return callStack;
}

public CallStack merge(CallStack callStack) {
callStack.setParent(this);
_calls.add(callStack);
return this;
}

private void setParent(CallStack callStack) {
this._parent = callStack;
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/intellij/sequencer/generator/IGenerator.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package org.intellij.sequencer.generator;

import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.Nullable;

public interface IGenerator {
CallStack generate(PsiElement psiElement);
/**
* Generate <code>CallStack</code> based on <code>PsiElement</code>.
* @param psiElement instanceof PsiMethod, KtFunction
* @param parent current CallStack or null if called from UI
* @return <code>CallStack</code> includes method call of FsiMethod/KtFunction and calls in its body.
*/
CallStack generate(PsiElement psiElement, @Nullable CallStack parent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public KtSequenceGenerator(SequenceParams params, int offset, int depth) {
}

@Override
public CallStack generate(PsiElement psiElement) {
public CallStack generate(PsiElement psiElement, CallStack parent) {
if (parent != null) {
topStack = parent;
currentStack = topStack;
}

if (LOGGER.isDebugEnabled()) {
LOGGER.debug("[generate]" + psiElement.getText());
}
Expand Down Expand Up @@ -78,21 +83,19 @@ private void generateClass(KtClass psiElement, int textOffset) {
makeMethodCallExceptCurrentStackIsRecursive(method);
}

public CallStack generate(KtFunction ktFunction) {
private CallStack generate(KtFunction ktFunction) {
ktFunction.accept(this);
return topStack;
}

public CallStack generate(PsiMethod psiMethod) {
private CallStack generate(PsiMethod psiMethod) {
final SequenceGenerator sequenceGenerator =
offsetStack.isEmpty() ? new SequenceGenerator(params) : new SequenceGenerator(params, offsetStack.pop(), depth);
CallStack javaCall = sequenceGenerator.generate(psiMethod);
CallStack javaCall = sequenceGenerator.generate(psiMethod, currentStack);
LOGGER.debug("[JAVACall]:" + javaCall.generateText());
if (topStack == null) {
topStack = javaCall;
currentStack = topStack;
} else {
currentStack.merge(javaCall);
}
return topStack;
}
Expand Down Expand Up @@ -153,8 +156,8 @@ public void visitCallExpression(@NotNull KtCallExpression expression) {

@Override
public void visitObjectLiteralExpression(@NotNull KtObjectLiteralExpression expression) {
CallStack objLiteralExpr = new KtSequenceGenerator(params).generate(expression.getObjectDeclaration());
currentStack = currentStack.merge(objLiteralExpr);
CallStack objLiteralExpr = new KtSequenceGenerator(params).generate(expression.getObjectDeclaration(), currentStack);
//currentStack = currentStack.methodCall(objLiteralExpr);
//super.visitObjectLiteralExpression(expression);
}

Expand Down Expand Up @@ -182,7 +185,7 @@ private void methodCall(PsiElement psiElement, int offset) {
depth++;
LOGGER.debug("+ depth = " + depth + " method = " + psiElement.getText());
offsetStack.push(offset);
generate(psiElement);
generate(psiElement,null); // here, No NEW Generator created, call with null
depth--;
LOGGER.debug("- depth = " + depth + " method = " + psiElement.getText());
currentStack = oldStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public SequenceGenerator(SequenceParams params, int offset, int depth) {
}

@Override
public CallStack generate(PsiElement psiElement) {
public CallStack generate(PsiElement psiElement, CallStack parent) {
if (parent != null) {
topStack = parent;
currentStack = topStack;
}

if (psiElement instanceof PsiMethod)
return generate((PsiMethod) psiElement);
else if (psiElement instanceof PsiLambdaExpression) {
Expand All @@ -55,14 +60,14 @@ else if (psiElement instanceof PsiLambdaExpression) {
* @param expression lambda expression
* @return CallStack
*/
public CallStack generate(PsiLambdaExpression expression) {
private CallStack generate(PsiLambdaExpression expression) {
MethodDescription method = createMethod(expression);
makeMethodCallExceptCurrentStackIsRecursive(method);
super.visitLambdaExpression(expression);
return topStack;
}

public CallStack generate(PsiMethod psiMethod) {
private CallStack generate(PsiMethod psiMethod) {
if (psiMethod.getLanguage().equals(JavaLanguage.INSTANCE)) {
return generateJava(psiMethod);
} else if (psiMethod.getLanguage().equals(KotlinLanguage.INSTANCE)) {
Expand All @@ -82,12 +87,10 @@ private CallStack generateKotlin(PsiMethod psiMethod) {

final KtSequenceGenerator ktSequenceGenerator =
offsetStack.isEmpty() ? new KtSequenceGenerator(params) : new KtSequenceGenerator(params, offsetStack.pop(), depth);
CallStack kotlinCall = ktSequenceGenerator.generate(psiMethod.getNavigationElement());
CallStack kotlinCall = ktSequenceGenerator.generate(psiMethod.getNavigationElement(), currentStack);
if (topStack == null) {
topStack = kotlinCall;
currentStack = topStack;
} else {
currentStack.merge(kotlinCall);
}
return topStack;
}
Expand Down Expand Up @@ -334,8 +337,7 @@ public void visitAssignmentExpression(PsiAssignmentExpression expression) {

@Override
public void visitLambdaExpression(PsiLambdaExpression expression) {
CallStack lambdaExpr = new SequenceGenerator(params).generate(expression);
currentStack = currentStack.merge(lambdaExpr);
new SequenceGenerator(params).generate(expression, currentStack);
}

private boolean makeMethodCallExceptCurrentStackIsRecursive(MethodDescription method) {
Expand Down

0 comments on commit f370ece

Please sign in to comment.