Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
qligier committed Sep 12, 2024
1 parent 3b37d72 commit b892f97
Show file tree
Hide file tree
Showing 35 changed files with 380 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/main/resources/fsh/fsh.tmbundle"]
path = src/main/resources/fsh/fsh.tmbundle
url = git@github.com:qligier/fsh.tmbundle.git
url = https://github.com/qligier/fsh.tmbundle.git
7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ tools.

<p align="center">

![GitHub](https://img.shields.io/github/license/qligier/jetbrains-plugin-fhir?style=flat-square)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/qligier/jetbrains-plugin-fhir?style=flat-square)
![GitHub last commit](https://img.shields.io/github/last-commit/qligier/jetbrains-plugin-fhir?style=flat-square)
![JDK 17](https://img.shields.io/badge/JDK-11-blue?style=flat-square)
![GitHub](https://img.shields.io/github/license/qligier/jetbrains-plugin-fss?style=flat-square)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/qligier/jetbrains-plugin-fss?style=flat-square)
![GitHub last commit](https://img.shields.io/github/last-commit/qligier/jetbrains-plugin-fss?style=flat-square)
![JDK 17](https://img.shields.io/badge/JDK-17-blue?style=flat-square)
</p>

## IG Publisher support
Expand Down Expand Up @@ -39,7 +39,7 @@ This plugin adds, for FSH files:
### Notice

The FHIR
Shorthand ![FSH icon](https://github.com/qligier/jetbrains-plugin-fhir/raw/master/src/main/resources/icons/fsh_flame.png)
Shorthand ![FSH icon](https://github.com/qligier/jetbrains-plugin-fss/raw/master/src/main/resources/icons/fsh_flame.png)
is maybe copyrighted?

The logo is derived from [Burn Fire Flame Hot](https://www.svgrepo.com/svg/404501/burn-fire-flame-hot), published
Expand Down
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ repositories {
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
implementation(libs.annotations)
implementation(libs.jspecify)
testImplementation(libs.junit)

// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
Expand All @@ -58,6 +59,8 @@ dependencies {
// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
intellijPlatform {
pluginConfiguration {
name = providers.gradleProperty("pluginName")
id = providers.gradleProperty("pluginId")
version = providers.gradleProperty("pluginVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
Expand Down Expand Up @@ -139,6 +142,14 @@ tasks {
publishPlugin {
dependsOn(patchChangelog)
}

prepareSandbox {
from("src/main/resources/fsh/fsh.tmbundle") {
include("info.plist")
include("Syntaxes/fsh.tmLanguage")
into("${intellijPlatform.pluginConfiguration.id.get()}/textmate")
}
}
}

intellijPlatformTesting {
Expand Down
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#
# Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.
#
pluginGroup=ch.qligier.jetbrains.plugin.fhir
pluginGroup=ch.qligier.jetbrains.plugin.fss
pluginName=FHIR and SUSHI Support
pluginRepositoryUrl=https://github.com/qligier/jetbrains-plugin-fhir
pluginId=jetbrains-plugin-fss
pluginRepositoryUrl=https://github.com/qligier/jetbrains-plugin-fss
# SemVer format -> https://semver.org
pluginVersion=0.0.1
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=233
# To depend on the TextMate bundle API, the plugin must start build from 241
pluginSinceBuild=241
pluginUntilBuild=242.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2023.3.7
platformVersion=2024.1
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
platformPlugins=
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# libraries
junit = "4.13.2"
annotations = "24.1.0"
jspecify = "1.0.0"

# plugins
changelog = "2.2.1"
Expand All @@ -13,6 +14,7 @@ qodana = "2024.1.9"
[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
jspecify = { group = "org.jspecify", name = "jspecify", version.ref = "jspecify" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

rootProject.name = "jetbrains-plugin-fhir"
rootProject.name = "jetbrains-plugin-fss"

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/ch/qligier/jetbrains/plugin/fhir/package-info.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.

package ch.qligier.jetbrains.plugin.fss.common;

import com.intellij.ide.FileIconProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.vfs.VirtualFile;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

import javax.swing.*;

/**
* A custom icon provider: it is used to give a better icon to files such as <em>ig.ini</em> and <em>sushi-config
* .yaml</em>.
*
* @author Quentin Ligier
**/
public class FssIconProvider implements FileIconProvider {

/**
* Provides a custom icon for the given virtual file, or {@code null} it there is no icon to provide.
*
* @param file The target file.
* @param flags Some flags.
* @param project The project.
* @return an icon to override the default one or {@code null}.
*/
@Override
public @Nullable Icon getIcon(@NonNull final VirtualFile file,
final @Iconable.IconFlags int flags,
@Nullable final Project project) {
if ("ig.ini".equals(file.getName())) {
return Icons.FHIR_FLAME;
} else if ("sushi-config.yaml".equals(file.getName())) {
return Icons.FSH_FLAME;
} else if (file.getPath().endsWith("/input/includes/menu.xml")) {
return Icons.MENU_XML;
}
return null;
}
}
42 changes: 42 additions & 0 deletions src/main/java/ch/qligier/jetbrains/plugin/fss/common/Icons.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.

package ch.qligier.jetbrains.plugin.fss.common;

import com.intellij.openapi.util.IconLoader;

import javax.swing.*;

/**
* The icons used by this plugin.
*
* @author Quentin Ligier
* @see <a href="https://plugins.jetbrains.com/docs/intellij/work-with-icons-and-images.html">Working with Icons and
* Images</a>
* @see <a href="https://jetbrains.design/intellij/principles/icons/">Icons</a>
* @see <a href="https://jetbrains.design/intellij/resources/icons_list/">Icons list</a>
* @see <a href="https://bjansen.github.io/intellij-icon-generator/">IntelliJ Icon Generator</a>
* @see <a href="https://intellij-icons.jetbrains.design">IntelliJ Platform Icons</a>
**/
public class Icons {

// 16x16 icon for the language type
public static final Icon FSH_FLAME = IconLoader.getIcon("/icons/fsh_flame.png", Icons.class);
public static final Icon FHIR_FLAME = IconLoader.getIcon("/icons/fhir.png", Icons.class);
public static final Icon MENU_XML = IconLoader.getIcon("/icons/menu.svg", Icons.class);

/**
* Icons based on <a href="https://jetbrains.design/intellij/resources/icons_list/">JetBrains ones</a>.
*/
public static final Icon FSH_FILE = IconLoader.getIcon("/icons/fsh_file.svg", Icons.class);
public static final Icon VALUESET = IconLoader.getIcon("/icons/valueset.svg", Icons.class);
public static final Icon PROFILE = IconLoader.getIcon("/icons/profile.svg", Icons.class);
public static final Icon EXTENSION = IconLoader.getIcon("/icons/extension.svg", Icons.class);
public static final Icon RESOURCE = IconLoader.getIcon("/icons/resource.svg", Icons.class);
public static final Icon MAPPING = IconLoader.getIcon("/icons/mapping.svg", Icons.class);
public static final Icon ALIAS = IconLoader.getIcon("/icons/alias.svg", Icons.class);
public static final Icon LOGICAL = IconLoader.getIcon("/icons/logical.svg", Icons.class);
public static final Icon CODESYSTEM = IconLoader.getIcon("/icons/codesystem.svg", Icons.class);
public static final Icon RULESET = IconLoader.getIcon("/icons/ruleset.svg", Icons.class);
public static final Icon INVARIANT = IconLoader.getIcon("/icons/invariant.svg", Icons.class);
public static final Icon INSTANCE = IconLoader.getIcon("/icons/instance.svg", Icons.class);
}
59 changes: 59 additions & 0 deletions src/main/java/ch/qligier/jetbrains/plugin/fss/fsh/FshFileType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.

package ch.qligier.jetbrains.plugin.fss.fsh;

import ch.qligier.jetbrains.plugin.fss.common.Icons;
import com.intellij.openapi.fileTypes.LanguageFileType;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

import javax.swing.*;

/**
* Definition of the FSH file type.
*
* @author Quentin Ligier
* @see <a href="https://plugins.jetbrains.com/docs/intellij/language-and-filetype.html">Language and File Type</a>
**/
public class FshFileType extends LanguageFileType {
public static final FshFileType INSTANCE = new FshFileType();

private FshFileType() {
super(FshLanguage.INSTANCE);
}

/**
* Returns the name of the file type. The name must be unique among all file types registered in the system.
*/
@Override
public
@NonNull String getName() {
return "FSH";
}

/**
* Returns the user-readable description of the file type.
*/
@Override
public
@NonNull String getDescription() {
return "FSH (SUSHI) file";
}

/**
* Returns the default extension for files of the type, <em>not</em> including the leading '.'.
*/
@Override
public
@NonNull String getDefaultExtension() {
return "fsh";
}

/**
* Returns the icon used for showing files of the type, or {@code null} if no icon should be shown.
*/
@Override
public @Nullable Icon getIcon() {
return Icons.FSH_FILE;
}
}
19 changes: 19 additions & 0 deletions src/main/java/ch/qligier/jetbrains/plugin/fss/fsh/FshLanguage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.

package ch.qligier.jetbrains.plugin.fss.fsh;

import com.intellij.lang.Language;

/**
* Definition of the FSH language.
*
* @author Quentin Ligier
* @see <a href="https://plugins.jetbrains.com/docs/intellij/language-and-filetype.html">Language and File Type</a>
**/
public class FshLanguage extends Language {
public static final FshLanguage INSTANCE = new FshLanguage();

private FshLanguage() {
super("FSH");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.

package ch.qligier.jetbrains.plugin.fss.fsh;

import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.diagnostic.Logger;
import org.jetbrains.plugins.textmate.api.TextMateBundleProvider;
import org.jspecify.annotations.NonNull;

import java.io.File;
import java.util.List;

/**
* The provider of the FSH TextMate bundle.
*
* @author Quentin Ligier
**/
public class FshTextMateBundleProvider implements TextMateBundleProvider {
private static final Logger LOG = Logger.getInstance(FshTextMateBundleProvider.class);

@Override
public @NonNull List<PluginBundle> getBundles() {
final File directory = PluginPathManager.getPluginResource(this.getClass(), "textmate");
if (directory == null) {
LOG.error("Could not find the FSH TextMate bundle");
return List.of();
}
LOG.warn("Found the FSH TextMate bundle at " + directory.getAbsolutePath());
System.out.println("Found the FSH TextMate bundle at " + directory.getAbsolutePath());
return List.of(new PluginBundle("FSH", directory.toPath()));
}
}
17 changes: 17 additions & 0 deletions src/main/java/ch/qligier/jetbrains/plugin/fss/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 Quentin Ligier. Use of this source code is governed by the MIT license.

/**
* The main package of the plugin "FHIR and SUSHI Support" (FSS).
* <p>
* The package is marked with JSpecify's {@code @NullMarked} to ensure that the plugin doesn't contain any null
* pointers.
*
* @author Quentin Ligier
* @see <a href="https://jspecify.dev/docs/user-guide/">Nullness User Guide</a>
* @see <a href="https://jspecify.dev/docs/api/org/jspecify/annotations/NullMarked.html">Annotation Interface
* NullMarked</a>
**/
@NullMarked
package ch.qligier.jetbrains.plugin.fss;

import org.jspecify.annotations.NullMarked;
Loading

0 comments on commit b892f97

Please sign in to comment.