Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'backport_intellij_2017.1' into backport_intellij_2016_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mplushnikov committed Mar 1, 2020
2 parents 10e0f44 + a36556c commit 1378c5a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private LombokConfigFileType() {
@NotNull
@Override
public String getName() {
return "LOMBOK_CONFIG";
return "Lombok config file";
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.plushnikov.intellij.plugin.language;

import com.intellij.openapi.fileTypes.ExactFileNameMatcher;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import org.jetbrains.annotations.NotNull;

public class LombokConfigFileTypeFactory extends FileTypeFactory {
@Override
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
fileTypeConsumer.consume(LombokConfigFileType.INSTANCE, new ExactFileNameMatcher("lombok.config"));
}
}
4 changes: 1 addition & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@

<daemon.highlightInfoFilter implementation="de.plushnikov.intellij.plugin.extension.LombokHighlightErrorFilter"/>

<fileType implementationClass="de.plushnikov.intellij.plugin.language.LombokConfigFileType" name="LOMBOK_CONFIG"
language="Lombok.Config"
fieldName="INSTANCE" extensions="config" fileNames="lombok.config"/>
<fileTypeFactory implementation="de.plushnikov.intellij.plugin.language.LombokConfigFileTypeFactory"/>
<lang.parserDefinition language="Lombok.Config"
implementationClass="de.plushnikov.intellij.plugin.language.LombokConfigParserDefinition"/>
<lang.syntaxHighlighterFactory language="Lombok.Config"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package de.plushnikov.intellij.plugin.inspection;

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
import de.plushnikov.intellij.plugin.AbstractLombokLightCodeInsightTestCase;

import java.util.List;
import java.util.Optional;

import static de.plushnikov.intellij.plugin.inspection.LombokInspectionTest.TEST_DATA_INSPECTION_DIRECTORY;

Expand All @@ -17,27 +15,25 @@ protected String getBasePath() {
return TEST_DATA_INSPECTION_DIRECTORY + "/redundantModifierInspection";
}

@Override
public void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new RedundantModifiersOnValueLombokAnnotationInspection());
}

public void testValueClassWithPrivateField() {
myFixture.configureByFile(getBasePath() + '/' + getTestName(false) + ".java");
final List<IntentionAction> allQuickFixes = myFixture.getAllQuickFixes(getBasePath() + '/' + getTestName(false) + ".java");
final Optional<String> removeModifierFix = allQuickFixes.stream().map(IntentionAction::getText)
.filter("Remove 'private' modifier"::equals).findFirst();

final List<IntentionAction> availableActions = getAvailableActions();
assertTrue("Redundant private field modifier",
availableActions.stream().anyMatch(action -> action.getText().contains("Change access modifier")));
assertTrue("Redundant private field modifier QuickFix not found", removeModifierFix.isPresent());
}

public void testValueClassWithFinalField() {
myFixture.configureByFile(getBasePath() + '/' + getTestName(false) + ".java");
final List<IntentionAction> allQuickFixes = myFixture.getAllQuickFixes(getBasePath() + '/' + getTestName(false) + ".java");
final Optional<String> removeModifierFix = allQuickFixes.stream().map(IntentionAction::getText)
.filter("Remove 'final' modifier"::equals).findFirst();

final List<IntentionAction> availableActions = getAvailableActions();
assertTrue("Redundant final field modifier",
availableActions.stream().anyMatch(action -> action.getText().contains("Change access modifier")));
assertTrue("Redundant final field modifier QuickFix not found", removeModifierFix.isPresent());
}

protected List<IntentionAction> getAvailableActions() {
final Editor editor = getEditor();
final PsiFile file = getFile();
CodeInsightTestFixtureImpl.instantiateAndRun(file, editor, new int[0], false);
return CodeInsightTestFixtureImpl.getAvailableIntentions(editor, file);
}

}

0 comments on commit 1378c5a

Please sign in to comment.