From 455fa4c9de57bf90585c942eda0e080dbf6bb8ed Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 2 Nov 2015 18:43:48 +0300 Subject: [PATCH] cleanup --- .../impl/ShowIntentionActionsHandler.java | 22 ++++++++----------- .../openapi/vfs/encoding/EncodingUtil.java | 4 ++-- .../com/intellij/util/NotNullFunction.java | 3 ++- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java index 687d7d6ecfac..278eda8656a8 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java @@ -104,16 +104,12 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler { } // returns editor,file where the action is available or null if there are none - public static boolean availableFor(@NotNull PsiFile file, @NotNull Editor editor, @NotNull IntentionAction action) { - if (!file.isValid()) return false; + public static boolean availableFor(@NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull IntentionAction action) { + if (!psiFile.isValid()) return false; int offset = editor.getCaretModel().getOffset(); - PsiElement element = file.findElementAt(offset); - boolean inProject = file.getManager().isInProject(file); - return isAvailableHere(editor, file, element, inProject, action); - } - - private static boolean isAvailableHere(Editor editor, PsiFile psiFile, PsiElement psiElement, boolean inProject, IntentionAction action) { + PsiElement psiElement = psiFile.findElementAt(offset); + boolean inProject = psiFile.getManager().isInProject(psiFile); try { Project project = psiFile.getProject(); if (action instanceof SuppressIntentionActionFromFix) { @@ -170,11 +166,11 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler { return chooseActionAndInvoke(hostFile, hostEditor, action, text, project); } - public static boolean chooseActionAndInvoke(@NotNull PsiFile hostFile, - @Nullable final Editor hostEditor, - @NotNull final IntentionAction action, - @NotNull String text, - @NotNull final Project project) { + static boolean chooseActionAndInvoke(@NotNull PsiFile hostFile, + @Nullable final Editor hostEditor, + @NotNull final IntentionAction action, + @NotNull String text, + @NotNull final Project project) { FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.quickFix"); ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats().registerInvocation(); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingUtil.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingUtil.java index c6ca91df6063..511bc485adff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -201,7 +201,7 @@ public class EncodingUtil { } @NotNull - // returns existing charset (null means N/A), failReason: null means enabled, notnull means disabled and contains error message + // returns pair (existing charset (null means N/A); failReason: null means enabled, notnull means disabled and contains error message) public static Pair checkCanReload(@NotNull VirtualFile virtualFile) { if (virtualFile.isDirectory()) { return Pair.create(null, "file is a directory"); diff --git a/platform/util-rt/src/com/intellij/util/NotNullFunction.java b/platform/util-rt/src/com/intellij/util/NotNullFunction.java index 802172e3e5c4..9fcc4246981b 100644 --- a/platform/util-rt/src/com/intellij/util/NotNullFunction.java +++ b/platform/util-rt/src/com/intellij/util/NotNullFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull; * @author Konstantin Bulenkov */ public interface NotNullFunction extends NullableFunction { + @Override @NotNull Result fun(final Param dom); }