Skip to content

Commit 114da44

Browse files
authored
chore: fix formatting (#35)
1 parent f088ddc commit 114da44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+300
-280
lines changed

build.gradle.kts

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id("java")
33
id("jacoco")
4+
id("com.diffplug.spotless") version "6.25.0"
45
id("org.jetbrains.kotlin.jvm") version "1.9.24"
56
id("org.jetbrains.intellij") version "1.17.3"
67
id("org.jetbrains.grammarkit") version "2022.3.2"
@@ -22,6 +23,8 @@ dependencies {
2223
implementation("org.apache.commons:commons-lang3:3.14.0")
2324
implementation("dev.openfga:openfga-language:v0.2.0-beta.1")
2425

26+
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
27+
2528
testImplementation("junit:junit:4.13.2")
2629
}
2730

@@ -43,6 +46,15 @@ grammarKit {
4346
intellijRelease.set("203.7717.81")
4447
}
4548

49+
spotless {
50+
java {
51+
target("src/main/java/dev/openfga/intellijplugin/**/*.java")
52+
palantirJavaFormat()
53+
removeUnusedImports()
54+
importOrder()
55+
}
56+
}
57+
4658
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
4759
kotlinOptions {
4860
jvmTarget = "17"
@@ -120,3 +132,4 @@ tasks {
120132
token.set(System.getenv("PUBLISH_TOKEN"))
121133
}
122134
}
135+

src/main/java/dev/openfga/intellijplugin/Notifier.java

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static void notifyError(Project project, String content) {
1616
.createNotification(content, NotificationType.ERROR)
1717
.notify(project);
1818
}
19+
1920
public static void notifyError(String title, String content) {
2021
notifyError(null, title, content);
2122
}

src/main/java/dev/openfga/intellijplugin/OpenFGAColorSettingsPage.java

+19-22
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
import com.intellij.openapi.options.colors.AttributesDescriptor;
66
import com.intellij.openapi.options.colors.ColorDescriptor;
77
import com.intellij.openapi.options.colors.ColorSettingsPage;
8+
import java.util.Map;
9+
import javax.swing.*;
810
import org.jetbrains.annotations.NotNull;
911
import org.jetbrains.annotations.Nullable;
1012

11-
import javax.swing.*;
12-
import java.util.Map;
13-
14-
public class OpenFGAColorSettingsPage implements ColorSettingsPage {
13+
public class OpenFGAColorSettingsPage implements ColorSettingsPage {
1514

16-
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
17-
new AttributesDescriptor("Keyword", OpenFGASyntaxHighlighter.KEYWORD),
18-
new AttributesDescriptor("Comment", OpenFGASyntaxHighlighter.COMMENT),
19-
new AttributesDescriptor("Type identifier", OpenFGASyntaxHighlighter.TYPE_IDENTIFIER),
20-
new AttributesDescriptor("Relation name", OpenFGASyntaxHighlighter.RELATION_NAME),
21-
new AttributesDescriptor("Schema version", OpenFGASyntaxHighlighter.SCHEMA_VERSIONS),
15+
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[] {
16+
new AttributesDescriptor("Keyword", OpenFGASyntaxHighlighter.KEYWORD),
17+
new AttributesDescriptor("Comment", OpenFGASyntaxHighlighter.COMMENT),
18+
new AttributesDescriptor("Type identifier", OpenFGASyntaxHighlighter.TYPE_IDENTIFIER),
19+
new AttributesDescriptor("Relation name", OpenFGASyntaxHighlighter.RELATION_NAME),
20+
new AttributesDescriptor("Schema version", OpenFGASyntaxHighlighter.SCHEMA_VERSIONS),
2221
};
2322

2423
@Nullable
@@ -36,16 +35,15 @@ public SyntaxHighlighter getHighlighter() {
3635
@NotNull
3736
@Override
3837
public String getDemoText() {
39-
return "# Administrator model\n" +
40-
"model\n" +
41-
" schema 1.1\n" +
42-
"\n" +
43-
"type user\n" +
44-
"type organization\n" +
45-
" relations\n" +
46-
" define administrator : [user]\n" +
47-
" define entity_of: [entity]\n" +
48-
" define member: administrator or member from entity_of";
38+
return "# Administrator model\n" + "model\n"
39+
+ " schema 1.1\n"
40+
+ "\n"
41+
+ "type user\n"
42+
+ "type organization\n"
43+
+ " relations\n"
44+
+ " define administrator : [user]\n"
45+
+ " define entity_of: [entity]\n"
46+
+ " define member: administrator or member from entity_of";
4947
}
5048

5149
@Nullable
@@ -69,5 +67,4 @@ public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMa
6967
public String getDisplayName() {
7068
return "OpenFGA";
7169
}
72-
73-
}
70+
}

src/main/java/dev/openfga/intellijplugin/OpenFGACommenter.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ public String getCommentedBlockCommentPrefix() {
3434
public String getCommentedBlockCommentSuffix() {
3535
return null;
3636
}
37-
38-
}
37+
}

src/main/java/dev/openfga/intellijplugin/OpenFGADefaultTemplatePropertiesProvider.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import com.intellij.ide.fileTemplates.DefaultTemplatePropertiesProvider;
44
import com.intellij.psi.PsiDirectory;
5-
import org.jetbrains.annotations.NotNull;
6-
75
import java.util.Properties;
6+
import org.jetbrains.annotations.NotNull;
87

98
public class OpenFGADefaultTemplatePropertiesProvider implements DefaultTemplatePropertiesProvider {
109
@Override

src/main/java/dev/openfga/intellijplugin/OpenFGAFile.java

-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ public FileType getFileType() {
2121
public String toString() {
2222
return getFileType().getName();
2323
}
24-
2524
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
package dev.openfga.intellijplugin;
22

33
import com.intellij.openapi.fileTypes.LanguageFileType;
4+
import javax.swing.*;
45
import org.jetbrains.annotations.NotNull;
56
import org.jetbrains.annotations.Nullable;
67

7-
import javax.swing.*;
8-
98
public class OpenFGAFileType extends LanguageFileType {
109

1110
public static final OpenFGAFileType INSTANCE = new OpenFGAFileType();
1211

13-
private OpenFGAFileType() {
12+
private OpenFGAFileType() {
1413
super(OpenFGALanguage.INSTANCE);
1514
}
1615

1716
@NotNull
1817
@Override
1918
public String getName() {
20-
return "OpenFGA File";
19+
return "OpenFGA Model File";
2120
}
2221

2322
@NotNull
2423
@Override
2524
public String getDescription() {
26-
return "OpenFGA DSL file";
25+
return "OpenFGA Model file";
2726
}
2827

2928
@NotNull
@@ -37,6 +36,4 @@ public String getDefaultExtension() {
3736
public Icon getIcon() {
3837
return OpenFGAIcons.FILE;
3938
}
40-
4139
}
42-

src/main/java/dev/openfga/intellijplugin/OpenFGAHighlightVisitor.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,17 @@ public void visit(@NotNull PsiElement element) {
5454

5555
for (var attributesKey : attributesKeys) {
5656
builder = builder.textAttributes(attributesKey);
57-
5857
}
5958

6059
return builder.range(element).create();
6160
}
6261

6362
@Override
64-
public boolean analyze(@NotNull PsiFile file, boolean updateWholeFile, @NotNull HighlightInfoHolder holder, @NotNull Runnable action) {
63+
public boolean analyze(
64+
@NotNull PsiFile file,
65+
boolean updateWholeFile,
66+
@NotNull HighlightInfoHolder holder,
67+
@NotNull Runnable action) {
6568
myHolder = holder;
6669
openfgaHighlighter = new OpenFGASyntaxHighlighter();
6770
try {
@@ -72,5 +75,4 @@ public boolean analyze(@NotNull PsiFile file, boolean updateWholeFile, @NotNull
7275
}
7376
return true;
7477
}
75-
7678
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package dev.openfga.intellijplugin;
22

33
import com.intellij.openapi.util.IconLoader;
4-
54
import javax.swing.*;
65

76
public interface OpenFGAIcons {
87

98
Icon FILE = IconLoader.getIcon("/icons/openfga-color-transparent-16x16.svg", OpenFGAIcons.class);
109
Icon TOOL_WINDOW = IconLoader.getIcon("/icons/tool-window.svg", OpenFGAIcons.class);
11-
1210
}

src/main/java/dev/openfga/intellijplugin/OpenFGALanguage.java

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ public class OpenFGALanguage extends Language {
99
private OpenFGALanguage() {
1010
super("OpenFGA");
1111
}
12-
1312
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package dev.openfga.intellijplugin;
22

3-
import dev.openfga.intellijplugin.parsing.OpenFGALexer;
43
import com.intellij.lexer.FlexAdapter;
4+
import dev.openfga.intellijplugin.parsing.OpenFGALexer;
55

66
public class OpenFGALexerAdapter extends FlexAdapter {
77

88
public OpenFGALexerAdapter() {
99
super(new OpenFGALexer(null));
1010
}
11-
12-
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package dev.openfga.intellijplugin;
2+
3+
import com.intellij.openapi.fileTypes.LanguageFileType;
4+
import javax.swing.*;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
import org.jetbrains.yaml.YAMLLanguage;
8+
9+
public class OpenFGAStoreFileType extends LanguageFileType {
10+
11+
public static final OpenFGAStoreFileType INSTANCE = new OpenFGAStoreFileType();
12+
13+
private OpenFGAStoreFileType() {
14+
super(YAMLLanguage.INSTANCE);
15+
}
16+
17+
@NotNull
18+
@Override
19+
public String getName() {
20+
return "OpenFGA Store File";
21+
}
22+
23+
@NotNull
24+
@Override
25+
public String getDescription() {
26+
return "OpenFGA Store file";
27+
}
28+
29+
@NotNull
30+
@Override
31+
public String getDefaultExtension() {
32+
return "fga.yaml";
33+
}
34+
35+
@Nullable
36+
@Override
37+
public Icon getIcon() {
38+
return OpenFGAIcons.FILE;
39+
}
40+
}

src/main/java/dev/openfga/intellijplugin/OpenFGASyntaxHighlighter.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package dev.openfga.intellijplugin;
22

3-
import dev.openfga.intellijplugin.parsing.OpenFGATokenSets;
4-
import dev.openfga.intellijplugin.psi.OpenFGATypes;
3+
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
4+
55
import com.intellij.lexer.Lexer;
66
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
77
import com.intellij.openapi.editor.colors.TextAttributesKey;
88
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
99
import com.intellij.psi.tree.IElementType;
10+
import dev.openfga.intellijplugin.parsing.OpenFGATokenSets;
11+
import dev.openfga.intellijplugin.psi.OpenFGATypes;
1012
import org.jetbrains.annotations.NotNull;
1113

12-
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
13-
1414
public class OpenFGASyntaxHighlighter extends SyntaxHighlighterBase {
1515
public static final TextAttributesKey KEYWORD =
1616
createTextAttributesKey("OPENFGA_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD);
@@ -30,25 +30,26 @@ public class OpenFGASyntaxHighlighter extends SyntaxHighlighterBase {
3030
createTextAttributesKey("OPENFGA_CONDITION_IDENTIFIER", DefaultLanguageHighlighterColors.CLASS_NAME);
3131
public static final TextAttributesKey CONDITION_REFERENCE =
3232
createTextAttributesKey("OPENFGA_CONDITION_REFERENCE", DefaultLanguageHighlighterColors.CLASS_REFERENCE);
33-
public static final TextAttributesKey CONDITION_PARAM_IDENTIFIER =
34-
createTextAttributesKey("OPENFGA_CONDITION_PARAM_IDENTIFIER", DefaultLanguageHighlighterColors.INSTANCE_METHOD);
33+
public static final TextAttributesKey CONDITION_PARAM_IDENTIFIER = createTextAttributesKey(
34+
"OPENFGA_CONDITION_PARAM_IDENTIFIER", DefaultLanguageHighlighterColors.INSTANCE_METHOD);
3535
public static final TextAttributesKey CONDITION_PARAM_TYPE =
3636
createTextAttributesKey("OPENFGA_CONDITION_PARAM_TYPE", DefaultLanguageHighlighterColors.PARAMETER);
3737
public static final TextAttributesKey COMMENT =
3838
createTextAttributesKey("OPENFGA_COMMENTS", DefaultLanguageHighlighterColors.LINE_COMMENT);
3939

40-
private static final TextAttributesKey[] KEYWORD_KEYS = new TextAttributesKey[]{KEYWORD};
41-
private static final TextAttributesKey[] MODULE_NAME_KEY = new TextAttributesKey[]{MODULE_NAME};
42-
private static final TextAttributesKey[] SCHEMA_VERSIONS_KEYS = new TextAttributesKey[]{SCHEMA_VERSIONS};
43-
private static final TextAttributesKey[] RELATION_NAME_KEYS = new TextAttributesKey[]{RELATION_NAME};
44-
private static final TextAttributesKey[] RELATION_REFERENCE_KEYS = new TextAttributesKey[]{RELATION_REFERENCE};
45-
private static final TextAttributesKey[] TYPE_IDENTIFIER_KEYS = new TextAttributesKey[]{TYPE_IDENTIFIER};
46-
private static final TextAttributesKey[] TYPE_REFERENCE_KEYS = new TextAttributesKey[]{TYPE_REFERENCE};
47-
private static final TextAttributesKey[] CONDITION_IDENTIFIER_KEYS = new TextAttributesKey[]{CONDITION_IDENTIFIER};
48-
private static final TextAttributesKey[] CONDITION_REFERENCE_KEYS = new TextAttributesKey[]{CONDITION_REFERENCE};
49-
private static final TextAttributesKey[] CONDITION_PARAM_KEYS = new TextAttributesKey[]{CONDITION_PARAM_IDENTIFIER};
50-
private static final TextAttributesKey[] CONDITION_PARAM_TYPES = new TextAttributesKey[]{CONDITION_PARAM_TYPE};
51-
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
40+
private static final TextAttributesKey[] KEYWORD_KEYS = new TextAttributesKey[] {KEYWORD};
41+
private static final TextAttributesKey[] MODULE_NAME_KEY = new TextAttributesKey[] {MODULE_NAME};
42+
private static final TextAttributesKey[] SCHEMA_VERSIONS_KEYS = new TextAttributesKey[] {SCHEMA_VERSIONS};
43+
private static final TextAttributesKey[] RELATION_NAME_KEYS = new TextAttributesKey[] {RELATION_NAME};
44+
private static final TextAttributesKey[] RELATION_REFERENCE_KEYS = new TextAttributesKey[] {RELATION_REFERENCE};
45+
private static final TextAttributesKey[] TYPE_IDENTIFIER_KEYS = new TextAttributesKey[] {TYPE_IDENTIFIER};
46+
private static final TextAttributesKey[] TYPE_REFERENCE_KEYS = new TextAttributesKey[] {TYPE_REFERENCE};
47+
private static final TextAttributesKey[] CONDITION_IDENTIFIER_KEYS = new TextAttributesKey[] {CONDITION_IDENTIFIER};
48+
private static final TextAttributesKey[] CONDITION_REFERENCE_KEYS = new TextAttributesKey[] {CONDITION_REFERENCE};
49+
private static final TextAttributesKey[] CONDITION_PARAM_KEYS =
50+
new TextAttributesKey[] {CONDITION_PARAM_IDENTIFIER};
51+
private static final TextAttributesKey[] CONDITION_PARAM_TYPES = new TextAttributesKey[] {CONDITION_PARAM_TYPE};
52+
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[] {COMMENT};
5253
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
5354

5455
@NotNull
@@ -110,5 +111,4 @@ public Lexer getHighlightingLexer() {
110111

111112
return EMPTY_KEYS;
112113
}
113-
114-
}
114+
}

src/main/java/dev/openfga/intellijplugin/OpenFGASyntaxHighlighterFactory.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ public class OpenFGASyntaxHighlighterFactory extends SyntaxHighlighterFactory {
1313
public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) {
1414
return new OpenFGASyntaxHighlighter();
1515
}
16-
17-
}
16+
}

src/main/java/dev/openfga/intellijplugin/actions/DslToJsonAction.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package dev.openfga.intellijplugin.actions;
22

3-
import dev.openfga.intellijplugin.cli.tasks.DslToJsonTask;
4-
import dev.openfga.intellijplugin.OpenFGALanguage;
5-
import dev.openfga.intellijplugin.settings.OpenFGASettingsState;
63
import com.intellij.openapi.actionSystem.ActionUpdateThread;
74
import com.intellij.openapi.actionSystem.AnAction;
85
import com.intellij.openapi.actionSystem.AnActionEvent;
96
import com.intellij.openapi.actionSystem.CommonDataKeys;
107
import com.intellij.openapi.progress.ProgressManager;
8+
import dev.openfga.intellijplugin.OpenFGALanguage;
9+
import dev.openfga.intellijplugin.cli.tasks.DslToJsonTask;
10+
import dev.openfga.intellijplugin.settings.OpenFGASettingsState;
1111
import org.jetbrains.annotations.NotNull;
1212

1313
public class DslToJsonAction extends AnAction {
@@ -41,12 +41,11 @@ public void actionPerformed(@NotNull AnActionEvent event) {
4141
if (virtualFile == null) {
4242
return;
4343
}
44-
DslToJsonTask.create(dslFile, virtualFile.toNioPath())
45-
.ifPresent(ProgressManager.getInstance()::run);
44+
DslToJsonTask.create(dslFile, virtualFile.toNioPath()).ifPresent(ProgressManager.getInstance()::run);
4645
}
4746

4847
@Override
4948
public @NotNull ActionUpdateThread getActionUpdateThread() {
5049
return ActionUpdateThread.BGT;
5150
}
52-
}
51+
}

0 commit comments

Comments
 (0)