Skip to content

Commit 1531cc4

Browse files
committed
Generating url, getting code back but loosing formatting..
1 parent 29c54c2 commit 1531cc4

File tree

2 files changed

+66
-52
lines changed

2 files changed

+66
-52
lines changed

src/ServiceStackIDEA/.idea/workspace.xml

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

src/ServiceStackIDEA/src/UpdateServiceStackReference.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) thr
6868
break;
6969
}
7070
}
71+
if(baseUrl == null) {
72+
//throw error
73+
return;
74+
}
75+
if(!baseUrl.endsWith("/")) {
76+
baseUrl += "/";
77+
}
7178

7279
URIBuilder builder = null;
7380
try {
@@ -76,7 +83,7 @@ public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) thr
7683
//Log error to IDEA warning bubble/window.
7784
return;
7885
}
79-
86+
builder.setPath("/types/java");
8087
for(int i = startParamsIndex; i < linesOfCode.size(); i++) {
8188
String configLine = linesOfCode.get(i);
8289
if(!configLine.startsWith("//") && configLine.contains(":")) {
@@ -85,19 +92,28 @@ public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) thr
8592
}
8693
}
8794

88-
String serverUrl = builder.toString();
8995

90-
// URL metadataUrl = new URL(serverUrl);
91-
// URLConnection metadataConnection = metadataUrl.openConnection();
92-
// metadataConnection.setRequestProperty("content-type", "application/json; charset=utf-8");
93-
// BufferedReader metadataBufferReader = new BufferedReader(
94-
// new InputStreamReader(
95-
// metadataConnection.getInputStream()));
96-
// String metadataInputLine;
97-
// StringBuilder metadataResponse = new StringBuilder();
98-
// while ((metadataInputLine = metadataBufferReader.readLine()) != null)
99-
// metadataResponse.append(metadataInputLine);
96+
try {
97+
String serverUrl = builder.build().toString();
98+
URL javaCodeUrl = new URL(serverUrl);
99+
100+
URLConnection javaCodeConnection = javaCodeUrl.openConnection();
101+
javaCodeConnection.setRequestProperty("content-type", "application/json; charset=utf-8");
102+
BufferedReader javaCodeBufferReader = new BufferedReader(
103+
new InputStreamReader(
104+
javaCodeConnection.getInputStream()));
105+
String javaCodeInput;
106+
StringBuilder metadataResponse = new StringBuilder();
107+
while ((javaCodeInput = javaCodeBufferReader.readLine()) != null)
108+
metadataResponse.append(javaCodeInput);
109+
110+
//Line formatting lost...
111+
editor.getDocument().setText(metadataResponse);
100112

113+
} catch (Exception e) {
114+
//Log with IDEA bubble
115+
e.printStackTrace();
116+
}
101117
}
102118

103119
@Override

0 commit comments

Comments
 (0)