Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Quarkus completion is available in all *.properties files in a Quarkus project #1184

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2022 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.intellij.microprofile.lang;

import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.util.IconLoader;
import com.redhat.devtools.intellij.quarkus.lang.QuarkusIconProvider;
import com.redhat.devtools.intellij.qute.lang.QuteLanguage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
* MicroProfile language file type.
*/
public class MicroProfileFileType extends LanguageFileType {
private static final Icon QUARKUS_ICON = IconLoader.findIcon("/quarkus_icon_rgb_16px_default.png", QuarkusIconProvider.class);

@NotNull
public static final MicroProfileFileType INSTANCE = new MicroProfileFileType();

private MicroProfileFileType() {
super(MicroProfileLanguage.INSTANCE);
}

@Override
public @NotNull String getName() {
return "MicroProfile";
}

@Override
public @NotNull
String getDescription() {
return "MicroProfile";
}

@Override
public @NotNull String getDefaultExtension() {
return "properties";
}

@Override
public @Nullable Icon getIcon() {
return QUARKUS_ICON;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2022 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.intellij.microprofile.lang;

import com.intellij.lang.InjectableLanguage;
import com.intellij.lang.Language;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.templateLanguages.TemplateLanguage;
import org.jetbrains.annotations.NotNull;

/**
* Qute language.
*/
public class MicroProfileLanguage extends Language {

@NotNull
public static final MicroProfileLanguage INSTANCE = new MicroProfileLanguage();

private MicroProfileLanguage() {
super("MicroProfile");
}

@Override
public @NotNull
@NlsSafe String getDisplayName() {
return "MicroProfile";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.redhat.devtools.intellij.microprofile.lang;

import com.intellij.lang.Language;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.LanguageSubstitutor;
import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class MicroProfileLanguageSubstitutor extends LanguageSubstitutor {

@Override
public @Nullable Language getLanguage(@NotNull VirtualFile file, @NotNull Project project) {
if (QuarkusModuleUtil.isQuarkusPropertiesFile(file, project) || QuarkusModuleUtil.isQuarkusYAMLFile(file, project)) {
return MicroProfileLanguage.INSTANCE;
}
return null;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/lsp4ij-quarkus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
]]>
</description>
</server>
<languageMapping language="Properties" serverId="quarkus"/>
<languageMapping language="MicroProfile" serverId="quarkus"/>
<languageMapping language="JAVA" serverId="quarkus"/>
<serverIconProvider serverId="quarkus" class="com.redhat.devtools.intellij.microprofile.lang.MicroProfileServerIconProvider" />
</extensions>
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@
order="before javaClassReference"
implementationClass="com.redhat.devtools.intellij.quarkus.lang.QuarkusPropertyClassNameCompletionRemover"/>

<!-- MicroProfile -->
<lang.substitutor language="Properties" implementationClass="com.redhat.devtools.intellij.microprofile.lang.MicroProfileLanguageSubstitutor"/>
<fileType name="MicroProfile"
language="MicroProfile"
instance="INSTANCE"
implementationClass="com.redhat.devtools.intellij.microprofile.lang.MicroProfileFileType"/>

<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"/>
Expand Down
Loading