Skip to content

Commit

Permalink
chore: compatibility with 2024.3
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Sep 16, 2024
1 parent 9fb002d commit fe28668
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.ProjectActivity;
import com.intellij.openapi.startup.StartupActivity;
import com.redhat.devtools.intellij.lsp4mp4ij.classpath.ClasspathResourceChangedManager;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.project.PsiMicroProfileProjectManager;
import com.redhat.devtools.intellij.quarkus.run.QuarkusRunConfigurationManager;
Expand All @@ -36,7 +35,6 @@ public Object execute(@NotNull Project project, @NotNull Continuation<? super Un
// - and after the QuarkusLanguageClient throws an event to trigger Java validation.
// As java validation requires the properties cache, it needs that cache must be updated before.
PsiMicroProfileProjectManager.getInstance(project);
QuarkusProjectService.getInstance(project);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.intellij.quarkus;
package com.redhat.devtools.intellij.quarkus.json;

import com.intellij.json.JsonFileType;
import com.intellij.openapi.Disposable;
Expand All @@ -25,6 +25,7 @@
import com.redhat.devtools.intellij.lsp4mp4ij.classpath.ClasspathResourceChangedManager;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.PropertiesManager;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.internal.core.ls.PsiUtilsLSImpl;
import com.redhat.devtools.intellij.quarkus.QuarkusPluginDisposable;
import org.apache.commons.lang3.tuple.MutablePair;
import org.eclipse.lsp4mp.commons.ClasspathKind;
import org.eclipse.lsp4mp.commons.DocumentFormat;
Expand All @@ -40,23 +41,22 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class QuarkusProjectService implements ClasspathResourceChangedManager.Listener, Disposable {
private static final Logger LOGGER = LoggerFactory.getLogger(QuarkusProjectService.class);
public class QuarkusJsonSchemaProjectService implements ClasspathResourceChangedManager.Listener, Disposable {
private static final Logger LOGGER = LoggerFactory.getLogger(QuarkusJsonSchemaProjectService.class);

private final Map<Module, MutablePair<VirtualFile, Boolean>> schemas = new ConcurrentHashMap<>();

public static QuarkusProjectService getInstance(@NotNull Project project) {
return project.getService(QuarkusProjectService.class);
public static QuarkusJsonSchemaProjectService getInstance(@NotNull Project project) {
return project.getService(QuarkusJsonSchemaProjectService.class);
}

private final MessageBusConnection connection;

public QuarkusProjectService(Project project) {
public QuarkusJsonSchemaProjectService(Project project) {
connection = project.getMessageBus().connect(QuarkusPluginDisposable.getInstance(project));
connection.subscribe(ClasspathResourceChangedManager.TOPIC, this);
}


public VirtualFile getSchema(Module module) {
var schemaEntry = schemas.get(module);
if (schemaEntry == null || !schemaEntry.getRight()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.jetbrains.jsonSchema.extension.SchemaType;
import com.redhat.devtools.lsp4ij.LSPIJUtils;
import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil;
import com.redhat.devtools.intellij.quarkus.QuarkusProjectService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -46,7 +45,7 @@ public String getName() {
@Nullable
@Override
public VirtualFile getSchemaFile() {
return QuarkusProjectService.getInstance(module.getProject()).getSchema(module);
return QuarkusJsonSchemaProjectService.getInstance(module.getProject()).getSchema(module);
}

@NotNull
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/plugin-json.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<idea-plugin>

<extensions defaultExtensionNs="com.intellij">
<projectService
serviceImplementation="com.redhat.devtools.intellij.quarkus.json.QuarkusJsonSchemaProjectService"/>
</extensions>

<extensions defaultExtensionNs="JavaScript.JsonSchema">
<ProviderFactory implementation="com.redhat.devtools.intellij.quarkus.json.QuarkusSchemasProviderFactory"/>
</extensions>
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@

<properties.implicitPropertyUsageProvider
implementation="com.redhat.devtools.intellij.quarkus.lang.QuarkusImplicitPropertyUsageProvider"/>
<projectService serviceImplementation="com.redhat.devtools.intellij.quarkus.QuarkusProjectService"/>
<projectService
serviceImplementation="com.redhat.devtools.intellij.lsp4mp4ij.classpath.ClasspathResourceChangedManager"/>
<projectService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
import com.intellij.util.ui.UIUtil;
import com.redhat.devtools.intellij.MavenModuleImportingTestCase;
import com.redhat.devtools.intellij.quarkus.QuarkusProjectService;
import com.redhat.devtools.intellij.quarkus.json.QuarkusJsonSchemaProjectService;
import org.jetbrains.yaml.schema.YamlJsonSchemaHighlightingInspection;
import org.junit.Test;

Expand All @@ -36,7 +36,7 @@ public void testApplicationYamlFile() throws Exception {
Module module = createMavenModule(new File("projects/maven/hibernate-orm-resteasy-yaml"));
((CodeInsightTestFixture)myTestFixture).setTestDataPath(ModuleUtilCore.getModuleDirPath(module));
((CodeInsightTestFixture)myTestFixture).configureByFile("src/main/resources/application.yaml");
QuarkusProjectService.getInstance(module.getProject()).getSchema(module);
QuarkusJsonSchemaProjectService.getInstance(module.getProject()).getSchema(module);
UIUtil.dispatchAllInvocationEvents();
((CodeInsightTestFixture)myTestFixture).checkHighlighting();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.intellij.testFramework.fixtures.TestFixtureBuilder;
import com.redhat.devtools.intellij.lsp4mp4ij.classpath.ClasspathResourceChangedManager;
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.project.PsiMicroProfileProjectManager;
import com.redhat.devtools.intellij.quarkus.QuarkusProjectService;
import com.redhat.devtools.intellij.quarkus.json.QuarkusJsonSchemaProjectService;
import org.jetbrains.annotations.NotNull;
import org.junit.*;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -57,7 +57,7 @@ public static void init() throws Exception {

@AfterClass
public static void tearDown() throws Exception {
QuarkusProjectService.getInstance(myFixture.getProject()).dispose();
QuarkusJsonSchemaProjectService.getInstance(myFixture.getProject()).dispose();
PsiMicroProfileProjectManager.getInstance(myFixture.getProject()).dispose();
ClasspathResourceChangedManager.getInstance(myFixture.getProject()).dispose();
myFixture.tearDown();
Expand Down

0 comments on commit fe28668

Please sign in to comment.