-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated handling of formatter settings
- Loading branch information
Showing
10 changed files
with
130 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/de/gebit/intellij/autoconfig/state/TransientPluginState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.gebit.intellij.autoconfig.state; | ||
|
||
import com.intellij.openapi.fileTypes.FileType; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Transient plugin state used for configuration parts that can not be reliably tied to a project. | ||
* | ||
* @param formatFileTypes List of file types that should be formatted. | ||
* @param organizeImportFileTypes List of file types having their imports organised. | ||
*/ | ||
public record TransientPluginState(@NotNull Collection<FileType> formatFileTypes, @NotNull Collection<FileType> organizeImportFileTypes) { | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/de/gebit/intellij/autoconfig/state/TransientPluginStateService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.gebit.intellij.autoconfig.state; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.components.Service; | ||
import com.intellij.openapi.fileTypes.FileType; | ||
import com.intellij.openapi.fileTypes.FileTypeRegistry; | ||
import com.intellij.openapi.fileTypes.UnknownFileType; | ||
import com.intellij.openapi.project.Project; | ||
import de.gebit.intellij.autoconfig.FormatOnSaveOptionsDefaultsProvider; | ||
import lombok.Getter; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* The application wide settings for the autoconfig plugin. They are necessary because the {@link FormatOnSaveOptionsDefaultsProvider} does not have | ||
* access to the {@link Project} and can therefore not read the configured values. | ||
*/ | ||
@Getter | ||
@Service(Service.Level.APP) | ||
public final class TransientPluginStateService { | ||
/** | ||
* Transient state of plugin. | ||
*/ | ||
private TransientPluginState pluginState; | ||
|
||
public static TransientPluginStateService getInstance() { | ||
return ApplicationManager.getApplication().getService(TransientPluginStateService.class); | ||
} | ||
|
||
public void initFormatterSettings(List<String> formatFileTypes, List<String> organizeImportFileTypes) { | ||
pluginState = new TransientPluginState(getFileTypes(formatFileTypes), getFileTypes(organizeImportFileTypes)); | ||
} | ||
|
||
@NotNull | ||
private static List<FileType> getFileTypes(List<String> formatFileTypes) { | ||
List<FileType> fileTypes = new ArrayList<>(); | ||
for (String type : formatFileTypes) { | ||
FileType fileTypeByExtension = FileTypeRegistry.getInstance().getFileTypeByExtension(type); | ||
if (!(fileTypeByExtension instanceof UnknownFileType)) { | ||
fileTypes.add(fileTypeByExtension); | ||
} | ||
} | ||
return fileTypes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
<idea-plugin url="https://gitlab.local.gebit.de/intellij/trend-tools"> | ||
<id>de.gebit.intellij.autoconfig</id> | ||
<name>Configuration updater plugin for IntelliJ</name> | ||
<name>Autoconfig</name> | ||
<vendor email="[email protected]" url="https://www.gebit.de">GEBIT Solutions GmbH</vendor> | ||
|
||
<description><![CDATA[<em>Change this by patchPluginXml gradle task</em>]]></description> | ||
<change-notes><![CDATA[<em>Change this by patchPluginXml gradle task</em>]]></change-notes> | ||
<version>0.0.0</version> | ||
<idea-version since-build="231.1"/> | ||
<vendor url="https://github.com/GEBIT/autoconfig-intellij-plugin" | ||
email="info@gebit.de">GEBIT Solutions GmbH</vendor> | ||
email="jetbrains@gebit.de">GEBIT Solutions GmbH</vendor> | ||
<description><![CDATA[ | ||
TODO: HTML text describing the autoconfig plugin functionality. | ||
]]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters