mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migrate to DataKey#is API
GitOrigin-RevId: ffe2d4447882433f279754b590915e90a5cc311e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0d4c372a7d
commit
5beaaf1f5c
@@ -59,8 +59,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class MigrationPanel extends JPanel implements Disposable {
|
||||
@NonNls private static final String MIGRATION_USAGES = "migration.usages";
|
||||
private static final DataKey<TypeMigrationUsageInfo[]> MIGRATION_USAGES_KEYS = DataKey.create(MIGRATION_USAGES);
|
||||
private static final DataKey<TypeMigrationUsageInfo[]> MIGRATION_USAGES_KEY = DataKey.create("migration.usages");
|
||||
|
||||
private final PsiElement[] myInitialRoots;
|
||||
private final TypeMigrationLabeler myLabeler;
|
||||
@@ -283,7 +282,7 @@ public final class MigrationPanel extends JPanel implements Disposable {
|
||||
return selectedNodes.length == 1 && selectedNodes[0].getUserObject() instanceof MigrationNode
|
||||
? ((MigrationNode)selectedNodes[0].getUserObject()).getInfo().getElement() : null;
|
||||
}
|
||||
if (MIGRATION_USAGES.equals(dataId)) {
|
||||
if (MIGRATION_USAGES_KEY.is(dataId)) {
|
||||
DefaultMutableTreeNode[] selectedNodes = getSelectedNodes(DefaultMutableTreeNode.class, null);
|
||||
final Set<TypeMigrationUsageInfo> usageInfos = new HashSet<>();
|
||||
for (DefaultMutableTreeNode selectedNode : selectedNodes) {
|
||||
@@ -353,7 +352,7 @@ public final class MigrationPanel extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
private TypeMigrationUsageInfo @Nullable [] getUsages(AnActionEvent context) {
|
||||
return context.getData(MIGRATION_USAGES_KEYS);
|
||||
return context.getData(MIGRATION_USAGES_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -132,8 +132,8 @@ public abstract class UndoTestCase extends JavaCodeInsightTestCase {
|
||||
|
||||
private DataContext createDataContextFor(final Editor editor) {
|
||||
return dataId -> {
|
||||
if (dataId.equals(CommonDataKeys.EDITOR.getName())) return editor;
|
||||
if (dataId.equals(CommonDataKeys.PROJECT.getName())) return getProject();
|
||||
if (CommonDataKeys.EDITOR.is(dataId)) return editor;
|
||||
if (CommonDataKeys.PROJECT.is(dataId)) return getProject();
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -592,7 +592,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
|
||||
@Override
|
||||
public Object getData(@NotNull @NonNls String dataId) {
|
||||
if (DocumentationManager.SELECTED_QUICK_DOC_TEXT.getName().equals(dataId)) {
|
||||
if (DocumentationManager.SELECTED_QUICK_DOC_TEXT.is(dataId)) {
|
||||
// Javadocs often contain symbols (non-breakable white space). We don't want to copy them as is and replace
|
||||
// with raw white spaces. See IDEA-86633 for more details.
|
||||
String selectedText = myEditorPane.getSelectedText();
|
||||
|
||||
@@ -281,7 +281,7 @@ public class Notification {
|
||||
}
|
||||
|
||||
public static void setDataProvider(@NotNull Notification notification, @NotNull JComponent component) {
|
||||
DataManager.registerDataProvider(component, dataId -> KEY.getName().equals(dataId) ? notification : null);
|
||||
DataManager.registerDataProvider(component, dataId -> KEY.is(dataId) ? notification : null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -2781,7 +2781,7 @@ public class JBTabsImpl extends JComponent
|
||||
if (value != null) return value;
|
||||
}
|
||||
|
||||
if (QuickActionProvider.KEY.getName().equals(dataId)) {
|
||||
if (QuickActionProvider.KEY.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
if (MorePopupAware.KEY.is(dataId)) {
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public final class SimpleDataContext implements DataContext {
|
||||
public Object getData(@NotNull String dataId) {
|
||||
Object result = getDataFromSelfOrParent(dataId);
|
||||
|
||||
if (result == null && PlatformDataKeys.CONTEXT_COMPONENT.getName().equals(dataId)) {
|
||||
if (result == null && PlatformDataKeys.CONTEXT_COMPONENT.is(dataId)) {
|
||||
result = IdeFocusManager.getGlobalInstance().getFocusOwner();
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ public class ProjectFrameHelper implements IdeFrameEx, AccessibleContextAccessor
|
||||
}
|
||||
}
|
||||
|
||||
if (IdeFrame.KEY.getName().equals(dataId)) {
|
||||
if (IdeFrame.KEY.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public class BookmarkManagerTest extends AbstractEditorTest {
|
||||
|
||||
@Override
|
||||
public Object getData(@NotNull String dataId) {
|
||||
if (dataId.equals(OpenFileDescriptor.NAVIGATE_IN_EDITOR.getName())) {
|
||||
if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
|
||||
return getEditor();
|
||||
}
|
||||
return super.getData(dataId);
|
||||
|
||||
+2
-2
@@ -412,8 +412,8 @@ public class NonProjectFileAccessTest extends HeavyFileEditorManagerTestCase {
|
||||
|
||||
private DataContext createDataContextFor(final Editor editor) {
|
||||
return dataId -> {
|
||||
if (dataId.equals(CommonDataKeys.EDITOR.getName())) return editor;
|
||||
if (dataId.equals(CommonDataKeys.PROJECT.getName())) return getProject();
|
||||
if (CommonDataKeys.EDITOR.is(dataId)) return editor;
|
||||
if (CommonDataKeys.PROJECT.is(dataId)) return getProject();
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -813,7 +813,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
@Override
|
||||
public void renameElementAtCaretUsingHandler(@NotNull final String newName) {
|
||||
final DataContext editorContext = ((EditorEx)myEditor).getDataContext();
|
||||
final DataContext context = dataId -> PsiElementRenameHandler.DEFAULT_NAME.getName().equals(dataId)
|
||||
final DataContext context = dataId -> PsiElementRenameHandler.DEFAULT_NAME.is(dataId)
|
||||
? newName
|
||||
: editorContext.getData(dataId);
|
||||
final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
|
||||
|
||||
+2
-2
@@ -23,10 +23,10 @@ class XDebuggerPinToTopAction : XDebuggerTreeActionBase() {
|
||||
Presentation(),
|
||||
object : DataContext {
|
||||
override fun getData(dataId: String): Any? {
|
||||
if (dataId == XDebuggerTree.XDEBUGGER_TREE_KEY.name) {
|
||||
if (XDebuggerTree.XDEBUGGER_TREE_KEY.`is`(dataId)) {
|
||||
return node.tree
|
||||
}
|
||||
if (dataId == CommonDataKeys.PROJECT.name) {
|
||||
if (CommonDataKeys.PROJECT.`is`(dataId)) {
|
||||
return node.tree.project
|
||||
}
|
||||
return null
|
||||
|
||||
+10
-10
@@ -233,43 +233,43 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
|
||||
|
||||
@Override
|
||||
public Object getData(@NotNull String dataId) {
|
||||
if (CommonDataKeys.PSI_ELEMENT.getName().equals(dataId)) {
|
||||
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
|
||||
final PsiElement[] elements = getSelectedPSIElements();
|
||||
return elements.length == 1 ? elements[0] : null;
|
||||
}
|
||||
if (LangDataKeys.PSI_ELEMENT_ARRAY.getName().equals(dataId)) {
|
||||
if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
|
||||
return getSelectedPSIElements();
|
||||
}
|
||||
if (LangDataKeys.MODULE_CONTEXT.getName().equals(dataId)) {
|
||||
if (LangDataKeys.MODULE_CONTEXT.is(dataId)) {
|
||||
final Object element = getSelectedElement();
|
||||
if (element instanceof Module) {
|
||||
return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (LangDataKeys.MODULE_CONTEXT_ARRAY.getName().equals(dataId)) {
|
||||
if (LangDataKeys.MODULE_CONTEXT_ARRAY.is(dataId)) {
|
||||
final List<Module> moduleList = ContainerUtil.findAll(getSelectedElements(), Module.class);
|
||||
if (!moduleList.isEmpty()) {
|
||||
return moduleList.toArray(Module.EMPTY_ARRAY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (dataId.equals(LangDataKeys.IDE_VIEW.getName())) {
|
||||
if (LangDataKeys.IDE_VIEW.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
if (dataId.equals(PlatformDataKeys.HELP_ID.getName())) {
|
||||
if (PlatformDataKeys.HELP_ID.is(dataId)) {
|
||||
return "reference.toolwindows." + StringUtil.toLowerCase(myId);
|
||||
}
|
||||
if (PlatformDataKeys.CUT_PROVIDER.getName().equals(dataId)) {
|
||||
if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
|
||||
return myCopyPasteDelegator.getCutProvider();
|
||||
}
|
||||
if (PlatformDataKeys.COPY_PROVIDER.getName().equals(dataId)) {
|
||||
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
|
||||
return myCopyPasteDelegator.getCopyProvider();
|
||||
}
|
||||
if (PlatformDataKeys.PASTE_PROVIDER.getName().equals(dataId)) {
|
||||
if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
|
||||
return myCopyPasteDelegator.getPasteProvider();
|
||||
}
|
||||
if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.getName().equals(dataId)) {
|
||||
if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
|
||||
for (final Object element : getSelectedElements()) {
|
||||
if (element instanceof Module) {
|
||||
return myDeleteModuleProvider;
|
||||
|
||||
Reference in New Issue
Block a user