From 745d96d05e50970869df3366a64bc2e6c08fb2eb Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 1 Mar 2023 16:09:49 +0100 Subject: [PATCH] introduce com.intellij.xml.tools plugin (part 1) GitOrigin-RevId: a6f8667d764581c81d8162f7282c1aacb7a39860 --- .../src/META-INF/XmlActions.xml | 19 ------------ .../com/intellij/keymap/KeymapsTestCase.java | 2 +- plugins/ant/resources/META-INF/plugin.xml | 8 ++--- xml/relaxng/src/META-INF/relaxng-plugin.xml | 2 +- xml/xmlbeans/intellij.xml.xmlbeans.iml | 1 + .../xmlbeans => tools}/FileUtils.java | 2 +- .../xml/tools}/GenerateDTDAction.java | 29 +++++------------ ...erateInstanceDocumentFromSchemaAction.java | 2 +- ...erateInstanceDocumentFromSchemaDialog.form | 4 +-- ...erateInstanceDocumentFromSchemaDialog.java | 2 +- ...erateSchemaFromInstanceDocumentAction.java | 2 +- ...erateSchemaFromInstanceDocumentDialog.form | 4 +-- ...erateSchemaFromInstanceDocumentDialog.java | 2 +- .../{actions/xmlbeans => tools}/UIUtils.java | 2 +- .../xml/tools}/ValidateXmlAction.java | 9 ++++-- .../xmlbeans => tools}/Xsd2InstanceUtils.java | 2 +- xml/xmlbeans/src/intellij.xml.xmlbeans.xml | 31 +++++++++++++------ .../GenerateXmlFromXsdTest.kt | 2 +- 18 files changed, 54 insertions(+), 71 deletions(-) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/FileUtils.java (96%) rename xml/{impl/src/com/intellij/codeInsight/actions => xmlbeans/src/com/intellij/xml/tools}/GenerateDTDAction.java (77%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/GenerateInstanceDocumentFromSchemaAction.java (99%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/GenerateInstanceDocumentFromSchemaDialog.form (97%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/GenerateInstanceDocumentFromSchemaDialog.java (99%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/GenerateSchemaFromInstanceDocumentAction.java (99%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/GenerateSchemaFromInstanceDocumentDialog.form (97%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/GenerateSchemaFromInstanceDocumentDialog.java (99%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/UIUtils.java (98%) rename xml/{impl/src/com/intellij/xml/actions/validate => xmlbeans/src/com/intellij/xml/tools}/ValidateXmlAction.java (89%) rename xml/xmlbeans/src/com/intellij/xml/{actions/xmlbeans => tools}/Xsd2InstanceUtils.java (99%) rename xml/xmlbeans/test/com/intellij/xml/{actions/xmlbeans => tools}/GenerateXmlFromXsdTest.kt (96%) diff --git a/platform/platform-resources/src/META-INF/XmlActions.xml b/platform/platform-resources/src/META-INF/XmlActions.xml index 100ed02d27e6..1819b659d700 100644 --- a/platform/platform-resources/src/META-INF/XmlActions.xml +++ b/platform/platform-resources/src/META-INF/XmlActions.xml @@ -1,27 +1,8 @@ - - - - - - - - - - - - - - - - - - - diff --git a/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java b/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java index 994e37be8844..fc39a25e130b 100644 --- a/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java +++ b/platform/testFramework/extensions/src/com/intellij/keymap/KeymapsTestCase.java @@ -546,7 +546,7 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase { "IDEtalk.SearchUserHistory", "IDEtalk.Rename", "CIDR.Lang.Cpp.GenerateDefinitions", "ActivateErrorsInSolutionToolWindow", "ActivateUnitTestsToolWindow", "ActivateDatabaseToolWindow", "ActivateBuildToolWindow", "ActivateNuGetToolWindow", "RiderBackendAction-EncapsulateField", "SwitchHeaderSource", "BuildProject", "RebuildProject", "BuildSolutionAction", "RebuildSolutionAction", - "ActivateInspectionResultsToolWindow", "" + "ActivateInspectionResultsToolWindow", "", "ValidateXml" ); private static final Set DEFAULT_BOUND_ACTIONS = Set.of( diff --git a/plugins/ant/resources/META-INF/plugin.xml b/plugins/ant/resources/META-INF/plugin.xml index 9e6cba8baa41..8e9908e63382 100644 --- a/plugins/ant/resources/META-INF/plugin.xml +++ b/plugins/ant/resources/META-INF/plugin.xml @@ -98,11 +98,11 @@ To use the Ant tool window, select View > Tool Windows > Ant. - + - - - + + + diff --git a/xml/relaxng/src/META-INF/relaxng-plugin.xml b/xml/relaxng/src/META-INF/relaxng-plugin.xml index 956ac12559a6..8231b9a35645 100644 --- a/xml/relaxng/src/META-INF/relaxng-plugin.xml +++ b/xml/relaxng/src/META-INF/relaxng-plugin.xml @@ -56,7 +56,7 @@ - + \ No newline at end of file diff --git a/xml/xmlbeans/intellij.xml.xmlbeans.iml b/xml/xmlbeans/intellij.xml.xmlbeans.iml index 6ecd78673d55..539995bde345 100644 --- a/xml/xmlbeans/intellij.xml.xmlbeans.iml +++ b/xml/xmlbeans/intellij.xml.xmlbeans.iml @@ -48,5 +48,6 @@ + \ No newline at end of file diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/FileUtils.java b/xml/xmlbeans/src/com/intellij/xml/tools/FileUtils.java similarity index 96% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/FileUtils.java rename to xml/xmlbeans/src/com/intellij/xml/tools/FileUtils.java index 3b1b222637fc..a39b0e79d6e1 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/FileUtils.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/FileUtils.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import java.io.*; diff --git a/xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateDTDAction.java similarity index 77% rename from xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateDTDAction.java index 4d35b0b67395..f865a4392eb3 100644 --- a/xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateDTDAction.java @@ -1,21 +1,8 @@ -/* - * Copyright 2000-2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInsight.actions; +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.xml.tools; import com.intellij.codeInsight.CodeInsightActionHandler; +import com.intellij.codeInsight.actions.BaseCodeInsightAction; import com.intellij.lang.xml.XMLLanguage; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -38,18 +25,17 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class GenerateDTDAction extends BaseCodeInsightAction{ +final class GenerateDTDAction extends BaseCodeInsightAction { private static final Logger LOG = Logger.getInstance(GenerateDTDAction.class); @Override - @NotNull - protected CodeInsightActionHandler getHandler(){ + protected @NotNull CodeInsightActionHandler getHandler(){ return new CodeInsightActionHandler(){ @Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final XmlDocument document = findSuitableXmlDocument(file); if (document != null) { final @NonNls StringBuilder buffer = new StringBuilder(); - buffer.append("\n"); XmlFile tempFile; @@ -75,8 +61,7 @@ public class GenerateDTDAction extends BaseCodeInsightAction{ }; } - @Nullable - private static XmlDocument findSuitableXmlDocument(@Nullable PsiFile psiFile) { + private static @Nullable XmlDocument findSuitableXmlDocument(@Nullable PsiFile psiFile) { if (psiFile instanceof XmlFile) { final XmlDocument document = ((XmlFile)psiFile).getDocument(); if (document != null && document.getRootTag() != null) { diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaAction.java similarity index 99% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaAction.java index 831c115ccc4a..1759a3970dfe 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaAction.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import com.intellij.javaee.ExternalResourceManager; import com.intellij.openapi.actionSystem.*; diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.form b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.form similarity index 97% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.form rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.form index d7bb3fdcc764..20ca66a4245e 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.form +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.form @@ -1,9 +1,9 @@ -
+ - + diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java similarity index 99% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java index a4ceca4854d6..5f4e6d34b436 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateInstanceDocumentFromSchemaDialog.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import com.intellij.codeInspection.util.InspectionMessage; diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentAction.java similarity index 99% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentAction.java index 7ade3d85c0fa..d9245d7ef53b 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentAction.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import com.intellij.javaee.ExternalResourceManager; import com.intellij.openapi.actionSystem.*; diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.form b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.form similarity index 97% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.form rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.form index 7fb3f21f416e..cc41e1b0d005 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.form +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.form @@ -1,9 +1,9 @@ - + - + diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java similarity index 99% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java rename to xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java index 59a21378da62..e99111a88105 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/GenerateSchemaFromInstanceDocumentDialog.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import com.intellij.codeInspection.util.InspectionMessage; import com.intellij.openapi.project.Project; diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/UIUtils.java b/xml/xmlbeans/src/com/intellij/xml/tools/UIUtils.java similarity index 98% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/UIUtils.java rename to xml/xmlbeans/src/com/intellij/xml/tools/UIUtils.java index 3ba9e3c38fd0..d91a3838e17c 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/UIUtils.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/UIUtils.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import com.intellij.javaee.ExternalResourceManager; import com.intellij.openapi.fileChooser.FileChooser; diff --git a/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java b/xml/xmlbeans/src/com/intellij/xml/tools/ValidateXmlAction.java similarity index 89% rename from xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java rename to xml/xmlbeans/src/com/intellij/xml/tools/ValidateXmlAction.java index 27deb6607583..604d677ffd97 100644 --- a/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/ValidateXmlAction.java @@ -1,5 +1,5 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.xml.actions.validate; +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.xml.tools; import com.intellij.ide.highlighter.XHtmlFileType; import com.intellij.ide.highlighter.XmlFileType; @@ -12,9 +12,12 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.xml.XmlFile; +import com.intellij.xml.actions.validate.StdErrorReporter; +import com.intellij.xml.actions.validate.ValidateXmlActionHandler; +import com.intellij.xml.actions.validate.ValidateXmlHandler; import org.jetbrains.annotations.NotNull; -public class ValidateXmlAction extends AnAction { +final class ValidateXmlAction extends AnAction { private static final Key runningValidationKey = Key.create("xml.running.validation.indicator"); public ValidateXmlAction() { diff --git a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java b/xml/xmlbeans/src/com/intellij/xml/tools/Xsd2InstanceUtils.java similarity index 99% rename from xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java rename to xml/xmlbeans/src/com/intellij/xml/tools/Xsd2InstanceUtils.java index 0ced215a4a5f..620535aa12af 100644 --- a/xml/xmlbeans/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java +++ b/xml/xmlbeans/src/com/intellij/xml/tools/Xsd2InstanceUtils.java @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans; +package com.intellij.xml.tools; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; diff --git a/xml/xmlbeans/src/intellij.xml.xmlbeans.xml b/xml/xmlbeans/src/intellij.xml.xmlbeans.xml index ababdc720e93..74ce6c51d534 100644 --- a/xml/xmlbeans/src/intellij.xml.xmlbeans.xml +++ b/xml/xmlbeans/src/intellij.xml.xmlbeans.xml @@ -1,16 +1,29 @@ - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xml/xmlbeans/test/com/intellij/xml/actions/xmlbeans/GenerateXmlFromXsdTest.kt b/xml/xmlbeans/test/com/intellij/xml/tools/GenerateXmlFromXsdTest.kt similarity index 96% rename from xml/xmlbeans/test/com/intellij/xml/actions/xmlbeans/GenerateXmlFromXsdTest.kt rename to xml/xmlbeans/test/com/intellij/xml/tools/GenerateXmlFromXsdTest.kt index 5147819cc428..19dceca5ed99 100644 --- a/xml/xmlbeans/test/com/intellij/xml/actions/xmlbeans/GenerateXmlFromXsdTest.kt +++ b/xml/xmlbeans/test/com/intellij/xml/tools/GenerateXmlFromXsdTest.kt @@ -1,5 +1,5 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.xml.actions.xmlbeans +package com.intellij.xml.tools import com.intellij.openapi.util.Disposer import com.intellij.openapi.vfs.LocalFileSystem