Skip to content

Commit 2b89a61

Browse files
committed
Alt+Enter intention now parsing url params.
Still to do: Call service Update file Replace GSON placeholder for net.servicestack:client:0.0.1 gradle dependency.
1 parent c2a1030 commit 2b89a61

File tree

3 files changed

+115
-73
lines changed

3 files changed

+115
-73
lines changed

src/ServiceStackIDEA/.idea/workspace.xml

Lines changed: 72 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceStackIDEA/src/AddRef.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private void onOK() throws IOException {
117117
if(!writeDtoFile(javaCodeLines,dtoPath)) {
118118
return;
119119
}
120+
refreshFile(dtoPath,false);
120121
dispose();
121122
}
122123

src/ServiceStackIDEA/src/UpdateServiceStackReference.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
import com.intellij.psi.PsiFile;
77
import com.intellij.psi.PsiJavaFile;
88
import com.intellij.util.IncorrectOperationException;
9+
import org.apache.http.client.utils.URIBuilder;
910
import org.jetbrains.annotations.NotNull;
1011

1112
import javax.swing.*;
13+
import java.net.MalformedURLException;
14+
import java.net.URISyntaxException;
15+
import java.net.URL;
16+
import java.util.ArrayList;
17+
import java.util.List;
18+
import java.util.Scanner;
1219

1320

1421
public class UpdateServiceStackReference extends QuickEditAction implements Iconable {
@@ -39,7 +46,41 @@ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile psiF
3946

4047
@Override
4148
public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException {
42-
String foo = "";
49+
String code = psiFile.getText();
50+
Scanner scanner = new Scanner(code);
51+
List<String> linesOfCode = new ArrayList<>();
52+
while (scanner.hasNextLine()) {
53+
String line = scanner.nextLine();
54+
linesOfCode.add(line);
55+
if(line.startsWith("*/")) break;
56+
}
57+
scanner.close();
58+
59+
int startParamsIndex = 0;
60+
String baseUrl = null;
61+
for(String item : linesOfCode) {
62+
startParamsIndex++;
63+
if(item.startsWith("BaseUrl:")) {
64+
baseUrl = item.split(":",2)[1].trim();
65+
break;
66+
}
67+
}
68+
69+
URIBuilder builder = null;
70+
try {
71+
builder = new URIBuilder(baseUrl);
72+
} catch (URISyntaxException e) {
73+
//Log error to IDEA warning bubble/window.
74+
return;
75+
}
76+
77+
for(int i = startParamsIndex; i < linesOfCode.size(); i++) {
78+
String configLine = linesOfCode.get(i);
79+
if(!configLine.startsWith("//") && configLine.contains(":")) {
80+
String[] keyVal = configLine.split(":");
81+
builder.addParameter(keyVal[0],keyVal[1].trim());
82+
}
83+
}
4384
}
4485

4586
@Override

0 commit comments

Comments
 (0)