Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xlau committed Jul 13, 2022
2 parents 202d624 + 380c244 commit 8c55314
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

## [1.0.1] - 2022-07-14
- 修复 因旧表达式存在而导致的报错
- 修复 因qualifiedName参数为null而导致的IllegalArgumentException
- 优化 部分代码的对Null值得判断

## [1.0.0] - 2022-07-10
- 适配 LiteFlow 2.8.x 的特性
- https://gitee.com/liupeiqiang/LiteFlowX/issues/I5GD4S
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
pluginGroup = top.xystudio.plugin.idea
pluginName = LiteFlowX
# SemVer format -> https://semver.org
pluginVersion = 1.0.0
pluginVersion = 1.0.1

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

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
Expand Down
Binary file added img/LiteFLowX.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
public class findChainsImpl implements BiFunction<Project, String, List<? extends PsiElement>> {
@Override
public List<? extends PsiElement> apply(Project project, String name) {
String componentId = name;
if (componentId == null || componentId.equals("")){
if (name == null || name.equals("")){
return null;
}
List<XmlTag> result = new ArrayList<>();
List<DomFileElement<Flow>> flows = DomService.getInstance().getFileElements(Flow.class, project, GlobalSearchScope.allScope(project));
for (DomFileElement<Flow> flow : flows) {
for (Chain chain : flow.getRootElement().getChains()) {
if (chain.getName().getStringValue() != null && chain.getName().getStringValue().equals(componentId)){
if (chain.getName().getStringValue() != null && chain.getName().getStringValue().equals(name)){
result.add(chain.getXmlTag());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
public class findComponentsImpl implements BiFunction<Project, String, List<? extends PsiElement>> {
@Override
public List<? extends PsiElement> apply(Project project, String name) {
String componentId = name;

if (componentId == null || componentId.equals("")){
if (name == null || name.equals("")){
return null;
}

Expand All @@ -26,7 +25,7 @@ public List<? extends PsiElement> apply(Project project, String name) {
for (PsiClass psiClass : allComponent) {

String componentName = LiteFlowService.getInstance(project).getLiteFlowComponentNameByPsiClass(psiClass);
if (componentName != null && componentName.equals(componentId)){
if (componentName != null && componentName.equals(name)){
result.add(psiClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ public List<? extends PsiElement> apply(Project project, String name) {
List<LiteFlowStatement> result = new ArrayList<>();

LiteFlowCodes liteFlowCodes = PsiTreeUtil.getChildOfType(this.liteFlowFile, LiteFlowCodes.class);
if (liteFlowCodes == null){
return result;
}
for (LiteFlowStatement liteFlowStatement : liteFlowCodes.getStatementList()) {
try{
if(name.equals(liteFlowStatement.getAssignStatement().getAssignExpress().getRefExpress().getTypeRef().getText())){
if(liteFlowStatement.getAssignStatement() != null &&
name.equals(liteFlowStatement.getAssignStatement().getAssignExpress().getRefExpress().getTypeRef().getText())){
result.add(liteFlowStatement);
}
}catch (Exception e){
continue;
}
}catch (Exception ignored){ }
}
return result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ public static JavaService getInstance(@NotNull Project project) {

/**
* 获取项目里的所有Class
* @return
* @return 返回所有工程里的Class
*/
public Collection<PsiClass> getAllClasses() {
return AllClassesSearch.search(GlobalSearchScope.projectScope(project), project).findAll();
}

/**
* 获取一个全名为qualifiedName的Class
* @param qualifiedName
* @return
* @param qualifiedName 类的全名
* @return 返回一个PsiClass对象
*/
public PsiClass getClassByQualifiedName(@NotNull String qualifiedName) {
return javaPsiFacade.findClass(qualifiedName, GlobalSearchScope.allScope(this.project));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public PsiElement[] findAllLiteFlowChain(){
List<DomFileElement<Flow>> flows = DomService.getInstance().getFileElements(Flow.class, this.project, GlobalSearchScope.allScope(this.project));
for (DomFileElement<Flow> flow : flows) {
for (Chain chain : flow.getRootElement().getChains()) {
if (chain.getName().getStringValue() != null) {
if (chain.getName().getStringValue() != null && StringUtil.isNotEmpty(chain.getName().getStringValue())) {
result.add(chain.getXmlTag());
}
}
Expand All @@ -68,15 +68,17 @@ public PsiClass[] findAllLiteFlowComponent(){
for (DomFileElement<Flow> flow : flows) {
Nodes nodes = flow.getRootElement().getNodes();
for (Node node : nodes.getNodeList()) {
PsiClass aClass = javaService.getClassByQualifiedName(node.getClazz().getStringValue());
if (aClass != null) result.add(aClass);
String clazzValue = node.getClazz().getStringValue();
if (clazzValue == null) {continue;}
PsiClass aClass = javaService.getClassByQualifiedName(clazzValue);
if (aClass == null) {continue;}
result.add(aClass);
}
}

result.addAll(components);
result.addAll(liteFlowComponents);
List<PsiClass> collect = result.stream().distinct().filter(this::isLiteFlowClass).collect(Collectors.toList());
return collect.toArray(new PsiClass[0]);
return result.stream().distinct().filter(this::isLiteFlowClass).toArray(PsiClass[]::new);
}

/**
Expand All @@ -90,11 +92,16 @@ public String getLiteFlowComponentNameByPsiClass(@NotNull PsiClass psiClass){
return null;
}

String className = psiClass.getName();
if (className == null){
return null;
}

String componentValue = JavaService.getInstance(this.project).getAnnotationAttributeValueByClass(psiClass, Annotation.Component, "value");
if (componentValue != null){
/** 如果获取的value值为空,则默认使用字符串首字母小写的Class名称 */
/* 如果获取的value值为空,则默认使用字符串首字母小写的Class名称 */
if (componentValue.equals("")){
componentValue = StringUtils.lowerFirst(psiClass.getName());
componentValue = StringUtils.lowerFirst(className);
}
return componentValue;
}
Expand All @@ -106,9 +113,9 @@ public String getLiteFlowComponentNameByPsiClass(@NotNull PsiClass psiClass){

String name = StringUtil.isEmpty(liteFlowComponentValue)? liteFlowComponentId : liteFlowComponentValue;
if (name != null){
/** 如果获取的value或者id值为空,则默认使用字符串首字母小写的Class名称 */
/* 如果获取的value或者id值为空,则默认使用字符串首字母小写的Class名称 */
if (name.equals("")){
name = StringUtils.lowerFirst(psiClass.getName());
name = StringUtils.lowerFirst(className);
}
return name;
}
Expand All @@ -118,8 +125,13 @@ public String getLiteFlowComponentNameByPsiClass(@NotNull PsiClass psiClass){
for (DomFileElement<Flow> flow : flows) {
Nodes nodes = flow.getRootElement().getNodes();
for (Node node : nodes.getNodeList()) {
if (psiClass.getQualifiedName().equals(node.getClazz().getStringValue())){
return node.getId().getStringValue();
String clazzValue = node.getClazz().getStringValue();
String idValue = node.getId().getStringValue();
if (psiClass.getQualifiedName()==null || clazzValue == null || idValue==null) {
continue;
}
if (psiClass.getQualifiedName().equals(clazzValue)){
return idValue;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/language/xmlInjections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<injection language="LiteFlow" injector-id="xml">
<display-name>Chain (XmlTag)</display-name>
<place><![CDATA[
xmlTag()
.withLocalName(string().equalTo("chain"))
]]></place>
xmlTag().withLocalName(string().equalTo("chain")).inVirtualFile(virtualFile().withName(string().contains(".el.xml")))
]]></place>
</injection>
</component>

0 comments on commit 8c55314

Please sign in to comment.