Skip to content

Commit c2a1030

Browse files
committed
Alt+Enter intention working for update reference.
1 parent 9a05b5e commit c2a1030

File tree

12 files changed

+295
-79
lines changed

12 files changed

+295
-79
lines changed

src/ServiceStackIDEA/.idea/libraries/org_apache_httpcomponents_com_springsource_org_apache_httpcomponents_httpclient_4_2.xml

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

src/ServiceStackIDEA/.idea/workspace.xml

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

src/ServiceStackIDEA/META-INF/plugin.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626

2727
<extensions defaultExtensionNs="com.intellij">
2828
<!-- Add your extensions here -->
29+
<intentionAction>
30+
<className>UpdateServiceStackReference</className>
31+
<category>ServiceStack</category>
32+
<descriptionDirectoryName>ServiceStack</descriptionDirectoryName>
33+
</intentionAction>
2934
</extensions>
3035

3136
<application-components>

src/ServiceStackIDEA/ServiceStackIDEA.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<orderEntry type="inheritedJdk" />
1010
<orderEntry type="sourceFolder" forTests="false" />
1111
<orderEntry type="library" exported="" name="com.google.code.gson:gson:2.3.1" level="project" />
12+
<orderEntry type="library" exported="" name="org.apache.httpcomponents:com.springsource.org.apache.httpcomponents.httpclient:4.2" level="project" />
1213
</component>
1314
</module>

src/ServiceStackIDEA/out/production/ServiceStackIDEA/intentionDescriptions/UpdateServiceStackReference/after.java.template

Whitespace-only changes.

src/ServiceStackIDEA/out/production/ServiceStackIDEA/intentionDescriptions/UpdateServiceStackReference/before.java.template

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<body>
3+
Write your description here.
4+
<!-- tooltip end -->
5+
Text after this comment will not be shown in tooltips.
6+
</body>
7+
</html>

src/ServiceStackIDEA/src/AddRef.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
99
import com.intellij.openapi.vfs.VirtualFile;
1010
import com.intellij.openapi.vfs.VirtualFileManager;
11+
import org.apache.http.client.utils.URIBuilder;
1112
import org.jetbrains.annotations.Nullable;
1213

1314
import javax.swing.*;
1415
import java.awt.event.*;
1516
import java.io.*;
1617
import java.net.MalformedURLException;
18+
import java.net.URISyntaxException;
1719
import java.net.URL;
1820
import java.net.URLConnection;
1921
import java.util.ArrayList;
@@ -110,6 +112,7 @@ private void onOK() throws IOException {
110112
javaCodeLines.add(metadataInputLine);
111113

112114
javaResponseReader.close();
115+
113116
String dtoPath = getDtoPath();
114117
if(!writeDtoFile(javaCodeLines,dtoPath)) {
115118
return;
@@ -236,11 +239,12 @@ private String createUrl(String text) throws MalformedURLException {
236239
}
237240

238241
if(packageBrowse.getText() != null && !packageBrowse.getText().isEmpty()) {
239-
String packVal = "Package=" + packageBrowse.getText();
240-
if(serverUrl.contains("?")) {
241-
serverUrl += "&" + packVal;
242-
} else {
243-
serverUrl += "?" + packVal;
242+
try {
243+
URIBuilder builder = new URIBuilder(serverUrl);
244+
builder.addParameter("Package",packageBrowse.getText());
245+
serverUrl = builder.build().toString();
246+
} catch (URISyntaxException e) {
247+
e.printStackTrace();
244248
}
245249
}
246250

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import com.intellij.codeInsight.intention.impl.QuickEditAction;
2+
import com.intellij.openapi.editor.Editor;
3+
import com.intellij.openapi.project.Project;
4+
import com.intellij.openapi.util.Iconable;
5+
import com.intellij.psi.PsiClass;
6+
import com.intellij.psi.PsiFile;
7+
import com.intellij.psi.PsiJavaFile;
8+
import com.intellij.util.IncorrectOperationException;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
import javax.swing.*;
12+
13+
14+
public class UpdateServiceStackReference extends QuickEditAction implements Iconable {
15+
16+
@Override
17+
public String getText() {
18+
return "Update ServiceStack reference";
19+
}
20+
21+
@Override
22+
public String getFamilyName() {
23+
return "UpdateServiceStackReference";
24+
}
25+
26+
@Override
27+
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile psiFile) {
28+
try {
29+
PsiJavaFile classFile = (PsiJavaFile)psiFile;
30+
String className= classFile.getClasses()[0].getName();
31+
if(className.equals("dto")){
32+
return true;
33+
}
34+
} catch (Exception e) {
35+
e.printStackTrace();
36+
}
37+
return false;
38+
}
39+
40+
@Override
41+
public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException {
42+
String foo = "";
43+
}
44+
45+
@Override
46+
public boolean startInWriteAction() {
47+
return true;
48+
}
49+
50+
@Override
51+
public Icon getIcon(@IconFlags int i) {
52+
return new ImageIcon(this.getClass().getResource("/icons/logo-16.png"));
53+
}
54+
}

src/ServiceStackIDEA/src/intentionDescriptions/UpdateServiceStackReference/after.java.template

Whitespace-only changes.

0 commit comments

Comments
 (0)