List<HighlightInfo> warns = doHighlighting(HighlightSeverity.WARNING);
assertOneElement(warns);
- List<HighlightInfo.IntentionActionDescriptor> actions = ShowIntentionsPass.getAvailableActions(getEditor(), getFile(), -1);
+ List<HighlightInfo.IntentionActionDescriptor> actions = ShowIntentionsPass.getAvailableFixes(getEditor(), getFile(), -1);
final HighlightInfo.IntentionActionDescriptor descriptor = assertOneElement(actions);
WriteCommandAction.runWriteCommandAction(getProject(), () -> descriptor.getAction().invoke(getProject(), getEditor(), getFile()));
highlightErrors();
- actions = ShowIntentionsPass.getAvailableActions(getEditor(), getFile(), -1);
+ actions = ShowIntentionsPass.getAvailableFixes(getEditor(), getFile(), -1);
assertEmpty(actions);
}
-
+
public void testApplyErrorInTheMiddle() throws Throwable {
String text = "class <caret>X { ";
for (int i = 0; i < 100; i++) {
assertEmpty(errors);
}
-
+
public void testErrorInTheEndOutsideVisibleArea() throws Throwable {
String text = "<xml> \n" + StringUtil.repeatSymbol('\n', 1000) + "</xml>\nxxxxx<caret>";
configureByText(StdFileTypes.XML, text);
assertEquals(4, infos.size());
}
-
+
public void testTypingNearEmptyErrorElement() throws Throwable {
String text = "class LQF {\n" +
" public void main() {\n" +
assertEmpty(infos);
}
-
+
public void testLIPGetAllParentsAfterCodeBlockModification() throws Throwable {
@Language("JAVA")
String text = "class LQF {\n" +
assertEquals(new HashSet<>(methodAndParents), new HashSet<>(visitedElements));
}
-
+
public void testCancelsItSelfOnTypingInAlienProject() throws Throwable {
String body = StringUtil.repeat("\"String field = null;\"\n", 1000);
configureByText(StdFileTypes.JAVA, "class X{ void f() {" + body + "<caret>\n} }");
return false;
}
- @NotNull
- protected ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
- return ActionHint.parse(file, contents);
- }
-
private static void doTestFor(@NotNull String testName, @NotNull QuickFixTestCase quickFixTestCase) {
final String relativePath = ObjectUtils.notNull(quickFixTestCase.getBasePath(), "") + "/" + BEFORE_PREFIX + testName;
final String testFullPath = quickFixTestCase.getTestDataPath().replace(File.separatorChar, '/') + relativePath;
@NotNull
@Override
public ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
- return LightQuickFixTestCase.this.parseActionHintImpl(file, contents);
+ return ActionHint.parse(file, contents);
}
@Override
private volatile boolean myHasToRecreate;
@NotNull
- public static List<HighlightInfo.IntentionActionDescriptor> getAvailableActions(@NotNull final Editor editor,
- @NotNull final PsiFile file,
- final int passId) {
+ public static List<HighlightInfo.IntentionActionDescriptor> getAvailableFixes(@NotNull final Editor editor,
+ @NotNull final PsiFile file,
+ final int passId) {
final int offset = ((EditorEx)editor).getExpectedCaretOffset();
final Project project = file.getProject();
DaemonCodeAnalyzerImpl.processHighlightsNearOffset(editor.getDocument(), project, HighlightSeverity.INFORMATION, offset, true,
new CommonProcessors.CollectProcessor<>(infos));
List<HighlightInfo.IntentionActionDescriptor> result = new ArrayList<>();
- infos.forEach(info->addAvailableActionsForGroups(info, editor, file, result, passId, offset));
+ infos.forEach(info-> addAvailableFixesForGroups(info, editor, file, result, passId, offset));
return result;
}
- private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
- @NotNull Editor editor,
- @NotNull PsiFile file,
- @NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
- int group,
- int offset) {
+ private static void addAvailableFixesForGroups(@NotNull HighlightInfo info,
+ @NotNull Editor editor,
+ @NotNull PsiFile file,
+ @NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
+ int group,
+ int offset) {
if (info.quickFixActionMarkers == null) return;
if (group != -1 && group != info.getGroup()) return;
boolean fixRangeIsNotEmpty = !info.getFixTextRange().isEmpty();
public final List<HighlightInfo.IntentionActionDescriptor> guttersToShow = ContainerUtil.createLockFreeCopyOnWriteList();
public final List<HighlightInfo.IntentionActionDescriptor> notificationActionsToShow = ContainerUtil.createLockFreeCopyOnWriteList();
- public void filterActions(@Nullable PsiFile psiFile) {
+ void filterActions(@Nullable PsiFile psiFile) {
IntentionActionFilter[] filters = IntentionActionFilter.EXTENSION_POINT_NAME.getExtensions();
filter(intentionsToShow, psiFile, filters);
filter(errorFixesToShow, psiFile, filters);
int offset = hostEditor.getCaretModel().getOffset();
final Project project = hostFile.getProject();
- List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableActions(hostEditor, hostFile, passIdToShowIntentionsFor);
+ List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableFixes(hostEditor, hostFile, passIdToShowIntentionsFor);
final DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
final Document hostDocument = hostEditor.getDocument();
HighlightInfo infoAtCursor = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(hostDocument, offset, true);
PsiElement el = psiElement;
while (el != null) {
elements.add(el);
+ if (el instanceof PsiFile) break;
el = el.getParent();
}
return false;
}
- // returns editor,file where the action is available or null if there are none
public static boolean availableFor(@NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull IntentionAction action) {
if (!psiFile.isValid()) return false;
* @deprecated {@link com.intellij.util.xmlb.XmlSerializer} should be used instead
* @author mike
*/
-@SuppressWarnings({"HardCodedStringLiteral"})
+@SuppressWarnings("HardCodedStringLiteral")
public class DefaultJDOMExternalizer {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.DefaultJDOMExternalizer");
}
@Nullable
- public static String filterXMLCharacters(String value) {
+ static String filterXMLCharacters(String value) {
if (value != null) {
StringBuilder builder = null;
for (int i=0; i<value.length();i++) {
import java.util.concurrent.TimeUnit;
/**
- * {@link java.util.concurrent.ExecutorService} implementation which delegates tasks for execution to the {@link javax.swing.SwingUtilities#invokeLater(Runnable)}
+ * An {@link ExecutorService} implementation which
+ * delegates tasks to the {@link javax.swing.SwingUtilities#invokeLater(Runnable)} for execution.
*/
public class EdtExecutorService extends AbstractExecutorService {
@NotNull
Project project = e.getData(LangDataKeys.PROJECT);
Editor editor = e.getData(LangDataKeys.EDITOR);
if (psiFile != null && project != null && editor != null) {
- List<HighlightInfo.IntentionActionDescriptor> quickFixes = ShowIntentionsPass.getAvailableActions(editor, psiFile, -1);
+ List<HighlightInfo.IntentionActionDescriptor> quickFixes = ShowIntentionsPass.getAvailableFixes(editor, psiFile, -1);
Map<Anchor, List<AnAction>> children = new HashMap<>();
ArrayList<AnAction> first = new ArrayList<>();
children.put(Anchor.FIRST, first);