Skip to content

Commit bbe4925

Browse files
committed
Fix xml val bug and make update not lang specific
1 parent 9c9c38a commit bbe4925

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/ServiceStackIDEA/src/main/java/net/servicestack/idea/IDEAPomFileHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ private static boolean pomDependencyElementMatch(Node dependencyElement, String
183183
NodeList dependencyProperties = dependencyElement.getChildNodes();
184184
for(int j = 0; j < dependencyProperties.getLength(); j++) {
185185
Node depProp = dependencyProperties.item(j);
186-
if(depProp.getNodeName().equals("groupId") && depProp.getTextContent() != null && depProp.getTextContent().equals(groupId)) {
186+
if(depProp.getNodeName().equals("groupId") && depProp.getTextContent() != null && depProp.getTextContent().trim().equals(groupId)) {
187187
groupIdMatch = true;
188188
}
189-
if(depProp.getNodeName().equals("artifactId") && depProp.getTextContent() != null && depProp.getTextContent().equals(packageId)) {
189+
if(depProp.getNodeName().equals("artifactId") && depProp.getTextContent() != null && depProp.getTextContent().trim().equals(packageId)) {
190190
artifactIdMatch = true;
191191
}
192192
}

src/ServiceStackIDEA/src/main/java/net/servicestack/idea/UpdateServiceStackReference.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public class UpdateServiceStackReference extends AnAction {
2626

2727
@Override
2828
public void actionPerformed(AnActionEvent anActionEvent) {
29-
final PsiJavaFile psiJavaFile = getPsiFile(anActionEvent);
30-
if(UpdateServiceStackUtils.containsOptionsHeader(psiJavaFile)) {
29+
final PsiFile psiFile = getPsiFile(anActionEvent);
30+
if(UpdateServiceStackUtils.containsOptionsHeader(psiFile)) {
3131
ApplicationManager.getApplication().runWriteAction(new Runnable() {
3232
@Override
3333
public void run() {
34-
UpdateServiceStackUtils.updateServiceStackReference(psiJavaFile);
34+
UpdateServiceStackUtils.updateServiceStackReference(psiFile);
3535
}
3636
});
3737
}
@@ -40,13 +40,19 @@ public void run() {
4040
@Override
4141
public void update(AnActionEvent e) {
4242
Module module = getModule(e);
43-
PsiJavaFile psiJavaFile = getPsiFile(e);
44-
if (psiJavaFile == null || !isAndroidProject(module)) {
43+
PsiFile psiFile = getPsiFile(e);
44+
if (psiFile == null || !isAndroidProject(module)) {
4545
e.getPresentation().setVisible(false);
4646
return;
4747
}
4848

49-
if(!UpdateServiceStackUtils.containsOptionsHeader(psiJavaFile)) {
49+
if(!psiFile.getFileType().getDefaultExtension().equals("java") &&
50+
!psiFile.getFileType().getDefaultExtension().equals("kt")) {
51+
e.getPresentation().setVisible(false);
52+
return;
53+
}
54+
55+
if(!UpdateServiceStackUtils.containsOptionsHeader(psiFile)) {
5056
e.getPresentation().setVisible(false);
5157
return;
5258
}
@@ -74,7 +80,7 @@ private static boolean isAndroidProject(@NotNull Module module) {
7480
return false;
7581
}
7682

77-
private static PsiJavaFile getPsiFile(AnActionEvent e) {
83+
private static PsiFile getPsiFile(AnActionEvent e) {
7884

7985
Module module = getModule(e);
8086
if(module == null) {
@@ -95,14 +101,7 @@ private static PsiJavaFile getPsiFile(AnActionEvent e) {
95101
return null;
96102
}
97103

98-
if(!isJavaFile(psiFile)) {
99-
return null;
100-
}
101-
return (PsiJavaFile)psiFile;
102-
}
103-
104-
private static boolean isJavaFile(@Nullable PsiFile psiFile) {
105-
return psiFile != null && psiFile instanceof PsiJavaFile;
104+
return psiFile;
106105
}
107106

108107
static Module getModule(AnActionEvent e) {

0 commit comments

Comments
 (0)