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

Commit

Permalink
Fixed #37: Delombok of files included as library failes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Plushnikov committed Mar 12, 2014
1 parent 0651e45 commit b386966
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ protected boolean isValidForFile(@NotNull Project project, @NotNull Editor edito
if (file instanceof PsiCompiledElement) {
return false;
}
if (!file.isWritable()) {
return false;
}

PsiDocumentManager.getInstance(project).commitAllDocuments();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ protected BaseDelombokHandler(AbstractProcessor... lombokProcessors) {
this.lombokProcessors = new ArrayList<AbstractProcessor>(Arrays.asList(lombokProcessors));
}

public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiClass psiClass) {
if (psiFile.isWritable()) {
invoke(project, psiClass);
finish(project, psiFile);
}
}

public void invoke(@NotNull Project project, @NotNull PsiJavaFile psiFile) {
for (PsiClass psiClass : psiFile.getClasses()) {
invoke(project, psiClass);
Expand All @@ -51,11 +58,6 @@ public void invoke(@NotNull Project project, @NotNull PsiJavaFile psiFile) {
finish(project, psiFile);
}

public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiClass psiClass) {
invoke(project, psiClass);
finish(project, psiFile);
}

private void invoke(Project project, PsiClass psiClass) {
for (AbstractProcessor lombokProcessor : lombokProcessors) {
processClass(project, psiClass, lombokProcessor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.generation.actions.BaseGenerateAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;

public abstract class BaseLombokAction extends BaseGenerateAction {

protected BaseLombokAction(CodeInsightActionHandler handler) {
super(handler);
}


@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return file.isWritable() && super.isValidForFile(project, editor, file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ public boolean startInWriteAction() {
}

public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiClass psiClass = OverrideImplementUtil.getContextClass(project, editor, file, false);
if (null != psiClass) {
processClass(psiClass);
if (file.isWritable()) {
PsiClass psiClass = OverrideImplementUtil.getContextClass(project, editor, file, false);
if (null != psiClass) {
processClass(psiClass);

UndoUtil.markPsiFileForUndo(file);
UndoUtil.markPsiFileForUndo(file);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions lombok-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<li>Fixed #17: Cyclic parent child relation</li>
<li>Fixed #34: Lombok plugin crashes</li>
<li>Fixed #36: Possible class cast exception</li>
<li>Fixed #37: Delombok of files included as library failes</li>
</ol>
</li>
<li>0.8.2
Expand Down

0 comments on commit b386966

Please sign in to comment.