package mobi.hsz.idea.gitignore.actions;

import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import mobi.hsz.idea.gitignore.GitignoreBundle;
import mobi.hsz.idea.gitignore.psi.GitignoreEntry;
import org.jetbrains.annotations.NotNull;

public class GitignoreRemoveEntryFix extends LocalQuickFixOnPsiElement {
    public GitignoreRemoveEntryFix(@NotNull GitignoreEntry entry) {
        super(entry);
    }

    @NotNull
    @Override
    public String getText() {
        return GitignoreBundle.message("quick.fix.remove.entry");
    }

    @Override
    public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
        if (startElement instanceof GitignoreEntry) {
            startElement.delete();
        }
    }

    @NotNull
    @Override
    public String getFamilyName() {
        return GitignoreBundle.message("codeInspection.group");
    }
}

@@ -207,24 +207,81 @@
 si.PsiFile;%0A
+import com.intellij.psi.impl.source.tree.LeafPsiElement;%0A
 import mobi.
@@ -367,16 +367,67 @@
 eEntry;%0A
+import mobi.hsz.idea.gitignore.psi.GitignoreTypes;%0A
 import o
@@ -964,32 +964,228 @@
 tignoreEntry) %7B%0A
+            LeafPsiElement next = (LeafPsiElement) startElement.getNextSibling();%0A            if (next.getElementType().equals(GitignoreTypes.CRLF)) %7B%0A                next.delete();%0A            %7D%0A
             star

remove entry with CRLF if following