mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: 0224f56ffac4f02dce70706561e9b4bf481c630a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7bf24ac4f3
commit
e892a152bc
+19
-11
@@ -24,21 +24,25 @@ import com.intellij.psi.PsiMethod
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
import groovy.transform.CompileStatic
|
||||
import org.intellij.lang.annotations.Language
|
||||
|
||||
@CompileStatic
|
||||
class NonSourceInspectionTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
void "test inspection outside source root"() {
|
||||
PsiTestUtil.removeAllRoots(module, ModuleRootManager.getInstance(module).sdk)
|
||||
PsiTestUtil.addSourceRoot(module, myFixture.tempDirFixture.findOrCreateDir("src"))
|
||||
|
||||
myFixture.addFileToProject("src/foo/GenericQuery.java", """
|
||||
|
||||
@Language("JAVA")
|
||||
def generic = """
|
||||
package foo;
|
||||
public interface GenericQuery<T> {
|
||||
public T execute();
|
||||
}
|
||||
""")
|
||||
def file = myFixture.addFileToProject("SomeClass.java", """
|
||||
"""
|
||||
myFixture.addFileToProject("src/foo/GenericQuery.java", generic)
|
||||
|
||||
@Language("JAVA")
|
||||
def some = """
|
||||
import foo.GenericQuery;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -50,7 +54,8 @@ class SomeClass {
|
||||
}
|
||||
|
||||
|
||||
""")
|
||||
"""
|
||||
def file = myFixture.addFileToProject("SomeClass.java", some)
|
||||
|
||||
def wrapper = new LocalInspectionToolWrapper(new UncheckedWarningLocalInspection())
|
||||
def context = InspectionManager.getInstance(project).createNewGlobalContext()
|
||||
@@ -61,14 +66,17 @@ class SomeClass {
|
||||
PsiTestUtil.removeAllRoots(module, ModuleRootManager.getInstance(module).sdk)
|
||||
PsiTestUtil.addSourceRoot(module, myFixture.tempDirFixture.findOrCreateDir("src"))
|
||||
|
||||
myFixture.addFileToProject("src/Foo.java", """
|
||||
@Language("JAVA")
|
||||
def foo = """
|
||||
class Foo<T> {
|
||||
public Foo(T x) {
|
||||
}
|
||||
}
|
||||
""")
|
||||
"""
|
||||
myFixture.addFileToProject("src/Foo.java", foo)
|
||||
|
||||
myFixture.configureByText("Foo.java", """
|
||||
@Language("JAVA")
|
||||
def foo2 = """
|
||||
class Foo<T> {
|
||||
public Foo(T x) {
|
||||
}
|
||||
@@ -79,10 +87,10 @@ class Bar extends Foo<String> {
|
||||
sup<caret>er("a");
|
||||
}
|
||||
}
|
||||
""")
|
||||
"""
|
||||
myFixture.configureByText("Foo.java", foo2)
|
||||
|
||||
assert myFixture.file.physical
|
||||
assert assertInstanceOf(myFixture.elementAtCaret, PsiMethod).name == 'Foo'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import java.util.function.BiFunction;
|
||||
import static com.intellij.openapi.util.NlsContexts.DetailedDescription;
|
||||
import static com.intellij.openapi.util.NlsContexts.Tooltip;
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
public class HighlightInfo implements Segment {
|
||||
private static final Logger LOG = Logger.getInstance(HighlightInfo.class);
|
||||
|
||||
|
||||
+1
-3
@@ -25,7 +25,6 @@ class DaemonTooltipActionProvider : TooltipActionProvider {
|
||||
val intention = extractMostPriorityFixFromHighlightInfo(info, editor, psiFile) ?: return null
|
||||
return wrapIntentionToTooltipAction(intention, info, editor)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,8 +32,7 @@ class DaemonTooltipActionProvider : TooltipActionProvider {
|
||||
* @param myFixText is a text to show in tooltip
|
||||
* @param myActionText is a text to search for in intentions' actions
|
||||
*/
|
||||
class DaemonTooltipAction(@NlsActions.ActionText private val myFixText: String, @NlsContexts.Command private val myActionText: String, private val myActualOffset: Int) : TooltipAction {
|
||||
|
||||
private class DaemonTooltipAction(@NlsActions.ActionText private val myFixText: String, @NlsContexts.Command private val myActionText: String, private val myActualOffset: Int) : TooltipAction {
|
||||
override fun getText(): String {
|
||||
return myFixText
|
||||
}
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.ex.TooltipAction;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -61,7 +62,7 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP
|
||||
ContainerUtil.quickSort(infos, (o1, o2) -> {
|
||||
int i = SeverityRegistrar.getSeverityRegistrar(myProject).compare(o2.getSeverity(), o1.getSeverity());
|
||||
if (i != 0) return i;
|
||||
return o1.getToolTip().compareTo(o2.getToolTip());
|
||||
return StringUtil.compare(o1.getToolTip(), o2.getToolTip(), false);
|
||||
});
|
||||
HighlightInfoComposite composite = HighlightInfoComposite.create(infos);
|
||||
String toolTip = composite.getToolTip();
|
||||
|
||||
+10
-17
@@ -154,17 +154,14 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
|
||||
val topInset = 5
|
||||
val bottomInset = (if (highlightActions) 4 else 10)
|
||||
buttons.add(createActionLabel(tooltipAction.text, runFixAction, hintHint.textBackground),
|
||||
gridBag.next().insets(topInset, 10, bottomInset, 4))
|
||||
buttons.add(createKeymapHint(shortcutRunActionText),
|
||||
gridBag.next().insets(topInset, 4, bottomInset, 12))
|
||||
buttons.add(createActionLabel(tooltipAction.text, hintHint.textBackground, runFixAction), gridBag.next().insets(topInset, 10, bottomInset, 4))
|
||||
buttons.add(createKeymapHint(shortcutRunActionText), gridBag.next().insets(topInset, 4, bottomInset, 12))
|
||||
|
||||
val showAllFixes = { _: InputEvent? ->
|
||||
val actionLabel = createActionLabel(DaemonBundle.message("daemon.tooltip.more.actions.link.label"), hintHint.textBackground) {
|
||||
hint.hide()
|
||||
tooltipAction.showAllActions(editor)
|
||||
}
|
||||
|
||||
buttons.add(createActionLabel(DaemonBundle.message("daemon.tooltip.more.actions.link.label"), showAllFixes, hintHint.textBackground),
|
||||
buttons.add(actionLabel,
|
||||
gridBag.next().insets(topInset, 12, bottomInset, 4))
|
||||
buttons.add(createKeymapHint(shortcutShowAllActionsText),
|
||||
gridBag.next().fillCellHorizontally().insets(topInset, 4, bottomInset, 20))
|
||||
@@ -173,7 +170,6 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
runFixAction(e.inputEvent)
|
||||
}
|
||||
|
||||
init {
|
||||
registerCustomShortcutSet(runActionCustomShortcutSet, editor.contentComponent)
|
||||
}
|
||||
@@ -181,9 +177,9 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
|
||||
actions.add(object : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
showAllFixes(e.inputEvent)
|
||||
hint.hide()
|
||||
tooltipAction.showAllActions(editor)
|
||||
}
|
||||
|
||||
init {
|
||||
registerCustomShortcutSet(getActiveKeymapShortcuts(IdeActions.ACTION_SHOW_INTENTION_ACTIONS), editor.contentComponent)
|
||||
}
|
||||
@@ -191,7 +187,6 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
|
||||
val buttonsConstraints = GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
|
||||
JBUI.insetsTop(0), 0, 0)
|
||||
|
||||
grid.add(wrapper, buttonsConstraints)
|
||||
}
|
||||
|
||||
@@ -270,7 +265,7 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
return super.canAutoHideOn(event)
|
||||
}
|
||||
|
||||
private fun isOwnAction(action: AnAction?) = action is ShowDocAction || action is ShowActionsAction || action is SettingsActionGroup
|
||||
private fun isOwnAction(action: AnAction?): Boolean = action is ShowDocAction || action is ShowActionsAction || action is SettingsActionGroup
|
||||
|
||||
private class SettingsActionGroup(actions: List<AnAction>) : DefaultActionGroup(actions), HintManagerImpl.ActionToIgnore, DumbAware {
|
||||
init {
|
||||
@@ -307,9 +302,8 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
return wrapper
|
||||
}
|
||||
|
||||
private inner class ShowActionsAction(
|
||||
val reloader: TooltipReloader, val isEnabled: Boolean
|
||||
) : ToggleAction(DaemonBundle.message("daemon.tooltip.show.quick.fixes.action.text")),
|
||||
private inner class ShowActionsAction(val reloader: TooltipReloader, val isEnabled: Boolean)
|
||||
: ToggleAction(DaemonBundle.message("daemon.tooltip.show.quick.fixes.action.text")),
|
||||
HintManagerImpl.ActionToIgnore {
|
||||
|
||||
override fun isSelected(e: AnActionEvent): Boolean {
|
||||
@@ -360,8 +354,7 @@ internal class DaemonTooltipWithActionRenderer(@NlsContexts.Tooltip text: String
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun createActionLabel(@NlsContexts.LinkLabel text: String, action: (InputEvent?) -> Unit, background: Color): HyperlinkLabel {
|
||||
private fun createActionLabel(@NlsContexts.LinkLabel text: String, background: Color, action: (InputEvent?) -> Unit): HyperlinkLabel {
|
||||
val label = object : HyperlinkLabel(text, background) {
|
||||
override fun getTextOffset(): Int {
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user