Skip to content

Commit a889434

Browse files
committed
Implement inlined annotations
2 parents bd6079a + 04d9650 commit a889434

33 files changed

+735
-94
lines changed

openapi-feature/feature.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feature
33
id="com.xliic.openapi"
44
label="OpenAPI (Swagger) Editor"
5-
version="1.0.53"
5+
version="1.0.54"
66
provider-name="42Crunch"
77
plugin="openapi-plugin">
88

@@ -703,7 +703,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
703703
id="openapi-plugin"
704704
download-size="0"
705705
install-size="0"
706-
version="1.0.53"
706+
version="1.0.54"
707707
unpack="false"/>
708708

709709
<plugin

openapi-feature/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.xliic.openapi</groupId>
99
<artifactId>openapi-parent</artifactId>
10-
<version>1.0.53</version>
10+
<version>1.0.54</version>
1111
</parent>
1212

1313
<artifactId>com.xliic.openapi</artifactId>

openapi-plugin/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Eclipse-openapi
44
Bundle-SymbolicName: openapi-plugin;singleton:=true
5-
Bundle-Version: 1.0.53
5+
Bundle-Version: 1.0.54
66
Require-Bundle: org.eclipse.ui,
77
org.eclipse.core.runtime,
88
org.eclipse.core.resources;bundle-version="3.13.700",

openapi-plugin/icons/scanAnno.png

987 Bytes
Loading

openapi-plugin/icons/tryitAnno.png

949 Bytes
Loading

openapi-plugin/plugin.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@
274274
<service serviceClass="com.xliic.openapi.config.IConfigService"></service>
275275
</serviceFactory>
276276

277+
<serviceFactory factoryClass="com.xliic.openapi.inlined.AnnotationServiceFactory">
278+
<service serviceClass="com.xliic.openapi.inlined.IAnnotationService"></service>
279+
</serviceFactory>
280+
277281
</extension>
278282

279283
<extension

openapi-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.xliic.openapi</groupId>
77
<artifactId>openapi-parent</artifactId>
8-
<version>1.0.53</version>
8+
<version>1.0.54</version>
99
</parent>
1010

1111
<artifactId>openapi-plugin</artifactId>

openapi-plugin/src/main/java/com/xliic/core/editor/Editor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public LogicalPosition offsetToLogicalPosition(int offset) {
9999

100100
public IAnnotationModel getModel() {
101101
ITextEditor editor = getTextEditor();
102-
return editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
102+
return editor == null ? null : editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
103103
}
104104

105105
public ISourceViewer getSourceViewer() {

openapi-plugin/src/main/java/com/xliic/core/fileEditor/FileDocumentManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ public IEditorInput getEditorInput(@NotNull Document document) {
7070
}
7171
return null;
7272
}
73+
74+
@Nullable
75+
public IEditorInput getEditorInput(@NotNull VirtualFile file) {
76+
for (IEditorInput input : EclipseUtil.getAllSupportedEditorInputs()) {
77+
if (file.equals(EclipseUtil.getVirtualFile(input))) {
78+
return input;
79+
}
80+
}
81+
return null;
82+
}
7383
}

openapi-plugin/src/main/java/com/xliic/core/psi/PsiManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.xliic.core.psi;
22

33
import org.jetbrains.annotations.NotNull;
4-
import org.jetbrains.annotations.Nullable;
54

65
import com.xliic.core.project.Project;
76
import com.xliic.core.vfs.VirtualFile;
@@ -22,7 +21,7 @@ public static PsiManager getInstance(@NotNull Project project) {
2221
return psiManager;
2322
}
2423

25-
@Nullable
24+
@NotNull
2625
public PsiFile findFile(@NotNull VirtualFile file) {
2726
return new PsiFile(project, file);
2827
}

openapi-plugin/src/main/java/com/xliic/core/util/EclipseUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.jetbrains.annotations.NotNull;
4646
import org.jetbrains.annotations.Nullable;
4747

48+
import com.xliic.core.fileEditor.FileDocumentManager;
4849
import com.xliic.core.vfs.VirtualFile;
4950
import com.xliic.openapi.parser.ast.Range;
5051
import com.xliic.openapi.parser.ast.node.Node;
@@ -79,6 +80,15 @@ public static ISourceViewer getSourceViewer(@NotNull IEditorInput input) {
7980
return null;
8081
}
8182

83+
@Nullable
84+
public static ISourceViewer getSourceViewer(@NotNull VirtualFile file) {
85+
IEditorInput input = FileDocumentManager.getInstance().getEditorInput(file);
86+
if (input == null) {
87+
return null;
88+
}
89+
return getSourceViewer(input);
90+
}
91+
8292
@Nullable
8393
public static ITextEditor getTextEditor(@NotNull IEditorInput input) {
8494
IWorkbench workbench = PlatformUI.getWorkbench();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.xliic.openapi;
2+
3+
import java.util.LinkedList;
4+
import java.util.List;
5+
6+
import org.jetbrains.annotations.NotNull;
7+
import org.jetbrains.annotations.Nullable;
8+
9+
import com.xliic.openapi.parser.ast.node.Node;
10+
11+
public abstract class DfsHandler<T> {
12+
13+
@NotNull
14+
protected String fileName = "";
15+
@Nullable
16+
protected OpenApiVersion version = null;
17+
@NotNull
18+
protected final List<T> data = new LinkedList<>();
19+
20+
public void init(@NotNull String fileName, @Nullable OpenApiVersion version) {
21+
this.fileName = fileName;
22+
this.version = version;
23+
data.clear();
24+
}
25+
26+
public abstract boolean visit(@NotNull Node node);
27+
28+
public abstract void finish(boolean success);
29+
30+
protected boolean isOpenAPI() {
31+
return version == OpenApiVersion.V2 || version == OpenApiVersion.V3;
32+
}
33+
}

openapi-plugin/src/main/java/com/xliic/openapi/OpenAPIImages.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ public class OpenAPIImages {
4949

5050
public static final ImageDescriptor TryIt;
5151
public static final ImageDescriptor TryItPanel;
52+
public static final ImageDescriptor TryItAnno;
5253

5354
public static final ImageDescriptor Scan;
5455
public static final ImageDescriptor ScanPanel;
56+
public static final ImageDescriptor ScanAnno;
5557

5658
public static final ImageDescriptor EnvPanel;
5759

@@ -104,8 +106,10 @@ public class OpenAPIImages {
104106

105107
TryIt = createImageDescriptor("/icons/tryit.png");
106108
TryItPanel = createImageDescriptor("/icons/tryitPanel.png");
109+
TryItAnno = createImageDescriptor("/icons/tryitAnno.png");
107110
Scan = createImageDescriptor("/icons/scan.png");
108111
ScanPanel = createImageDescriptor("/icons/scanPanel.png");
112+
ScanAnno = createImageDescriptor("/icons/scanAnno.png");
109113
EnvPanel = createImageDescriptor("/icons/envPanel.png");
110114
Config = createImageDescriptor("/icons/config.png");
111115
ConfigPanel = createImageDescriptor("/icons/configPanel.png");

openapi-plugin/src/main/java/com/xliic/openapi/OpenAPIStartupActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.xliic.core.project.Project;
77
import com.xliic.core.startup.StartupActivity;
88
import com.xliic.openapi.environment.EnvService;
9+
import com.xliic.openapi.inlined.AnnotationService;
910
import com.xliic.openapi.platform.PlatformConnection;
1011
import com.xliic.openapi.services.AuditService;
1112
import com.xliic.openapi.services.DictionaryService;
@@ -32,6 +33,7 @@ public void runActivity(@NotNull Project project) {
3233
DictionaryService.getInstance(project).subscribe();
3334
ScanService.getInstance(project).subscribe();
3435
EnvService.getInstance(project).subscribe();
36+
AnnotationService.getInstance(project).subscribe();
3537
// Platform
3638
PlatformService platformService = PlatformService.getInstance(project);
3739
if (PlatformConnection.isPlatformIntegrationEnabled()) {

openapi-plugin/src/main/java/com/xliic/openapi/config/jcef/messages/SaveConfig.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import com.xliic.core.ide.util.PropertiesComponent;
2121
import com.xliic.core.project.Project;
2222
import com.xliic.openapi.SecurityPropertiesComponent;
23+
import com.xliic.openapi.platform.PlatformConnection;
24+
import com.xliic.openapi.settings.Settings;
25+
import com.xliic.openapi.settings.Settings.Platform;
2326
import com.xliic.openapi.settings.Settings.Platform.Scan.ScandMgr;
2427
import com.xliic.openapi.topic.SettingsListener;
2528
import com.xliic.openapi.utils.Utils;
@@ -78,6 +81,7 @@ public void run(@Nullable Object payload) {
7881
}
7982
}
8083
if (!updatedKeys.isEmpty() && !project.isDisposed()) {
84+
addPlatformTurnOnOffKeys(updatedKeys, prevData);
8185
project.getMessageBus().syncPublisher(SettingsListener.TOPIC).propertiesUpdated(updatedKeys, prevData);
8286
}
8387
}
@@ -111,4 +115,23 @@ private void updateByKeyIfNotEqual(String key, Object value, Object newValue, bo
111115
prevData.put(key, value);
112116
}
113117
}
118+
119+
private void addPlatformTurnOnOffKeys(Set<String> updatedKeys, Map<String, Object> prevData) {
120+
final String prevApiKey = (String) prevData.get(Settings.Platform.Credentials.API_KEY);
121+
boolean wasPltEnabled = !prevApiKey.isEmpty();
122+
boolean nowPltEnabled = PlatformConnection.isPlatformIntegrationEnabled();
123+
if (nowPltEnabled && !wasPltEnabled) {
124+
updatedKeys.add(Platform.TURNED_ON);
125+
return;
126+
}
127+
if (!nowPltEnabled && wasPltEnabled) {
128+
updatedKeys.add(Platform.TURNED_OFF);
129+
return;
130+
}
131+
}
114132
}
133+
134+
135+
136+
137+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.xliic.openapi.inlined;
2+
3+
import org.eclipse.jface.text.source.Annotation;
4+
import org.eclipse.jface.text.source.IAnnotationAccess;
5+
6+
public class AnnotationAccess implements IAnnotationAccess {
7+
8+
@Override
9+
public Object getType(Annotation annotation) {
10+
return annotation.getType();
11+
}
12+
13+
@Override
14+
public boolean isMultiLine(Annotation annotation) {
15+
return true;
16+
}
17+
18+
@Override
19+
public boolean isTemporary(Annotation annotation) {
20+
return true;
21+
}
22+
}

0 commit comments

Comments
 (0)