-
-
Notifications
You must be signed in to change notification settings - Fork 155
/
NoParenthesesStrict.java
69 lines (62 loc) · 2.37 KB
/
NoParenthesesStrict.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.elixir_lang.inspection;
import com.intellij.codeInspection.*;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
import org.elixir_lang.local_quick_fix.RemoveSpaceInFrontOfNoParenthesesStrict;
import org.elixir_lang.psi.ElixirNoParenthesesStrict;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
/**
* Created by luke.imhoff on 12/5/14.
*/
public class NoParenthesesStrict extends LocalInspectionTool {
@Nls
@NotNull
@Override
public String getDisplayName() {
return "Ambiguous parentheses";
}
@Nls
@NotNull
@Override
public String getGroupDisplayName() {
return "Elixir";
}
@NotNull
@Override
public String getShortName() {
return "NoParenthesesStrict";
}
public boolean isEnabledByDefault() {
return true;
}
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
checkFile(file, problemsHolder);
return problemsHolder.getResultsArray();
}
private static void checkFile(final PsiFile file, final ProblemsHolder problemsHolder) {
file.accept(
new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof ElixirNoParenthesesStrict) {
LocalQuickFix localQuickFix = new RemoveSpaceInFrontOfNoParenthesesStrict(
element.getParent()
);
problemsHolder.registerProblem(
element,
"unexpected parenthesis. If you are making a " +
"function call, do not insert spaces in between the function name and the " +
"opening parentheses.",
ProblemHighlightType.ERROR,
localQuickFix
);
}
super.visitElement(element);
}
}
);
}
}