├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── bug_report_zh.yml │ ├── feature_request.yml │ └── feature_request_zh.yml ├── dependabot.yml └── workflows │ ├── build.yml │ ├── release.yml │ ├── run-ui-tests.yml │ └── sync_gitee.yml ├── .gitignore ├── .run ├── Run IDE for UI Tests.run.xml ├── Run IDE with Plugin.run.xml ├── Run Plugin Tests.run.xml ├── Run Plugin Verification.run.xml └── Run Qodana.run.xml ├── ANNOUNCEMENTS ├── CHANGELOG.md ├── DESCRIPTION.md ├── LICENSE ├── NOTICE ├── README.md ├── README_zh.md ├── build.gradle.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── qodana.yml ├── settings.gradle.kts └── src ├── main ├── java │ ├── cn │ │ └── memoryzy │ │ │ └── json │ │ │ ├── action │ │ │ ├── JavaBeanToJson5Action.java │ │ │ ├── JavaBeanToJsonAction.java │ │ │ ├── JavaConstantToJsonAction.java │ │ │ ├── JsonAssistantAction.java │ │ │ ├── JsonBeautifyAction.java │ │ │ ├── JsonEscapeAction.java │ │ │ ├── JsonMinifyAction.java │ │ │ ├── JsonStructureAction.java │ │ │ ├── JsonTextDiffAction.java │ │ │ ├── JsonToJavaBeanAction.java │ │ │ ├── JsonToKotlinClassAction.java │ │ │ ├── KotlinClassToJsonAction.java │ │ │ ├── OnlineDocAction.java │ │ │ ├── OtherFormatsToJsonAction.java │ │ │ ├── ShortcutAction.java │ │ │ ├── debug │ │ │ │ ├── RuntimeObjectToJson5Action.java │ │ │ │ └── RuntimeObjectToJsonAction.java │ │ │ ├── deserializer │ │ │ │ ├── FastJson2ToggleAction.java │ │ │ │ ├── FastJsonToggleAction.java │ │ │ │ ├── JacksonToggleAction.java │ │ │ │ ├── KeepCamelToggleAction.java │ │ │ │ ├── comment │ │ │ │ │ ├── SwaggerToggleAction.java │ │ │ │ │ └── SwaggerV3ToggleAction.java │ │ │ │ └── lombok │ │ │ │ │ ├── AccessorsToggleAction.java │ │ │ │ │ ├── DataToggleAction.java │ │ │ │ │ ├── GetterToggleAction.java │ │ │ │ │ ├── LombokGroup.java │ │ │ │ │ └── SetterToggleAction.java │ │ │ ├── extend │ │ │ │ ├── ConvertAllReadableTimeAction.java │ │ │ │ ├── ConvertAllTimestampAction.java │ │ │ │ └── ExpandAllNestedJsonAction.java │ │ │ ├── group │ │ │ │ ├── ConvertOtherFormatsGroup.java │ │ │ │ ├── ExtendGroup.java │ │ │ │ ├── JsonAssistantPopupGroup.java │ │ │ │ └── OptionsGroup.java │ │ │ ├── notification │ │ │ │ ├── DonateAction.java │ │ │ │ └── QuickStartAction.java │ │ │ ├── query │ │ │ │ ├── JmesPathToggleAction.java │ │ │ │ ├── JsonPathToggleAction.java │ │ │ │ ├── ShowHistoryAction.java │ │ │ │ ├── ShowOriginalTextAction.java │ │ │ │ └── SwitchAction.java │ │ │ ├── structure │ │ │ │ ├── CollapseAllAction.java │ │ │ │ ├── CollapseMultiAction.java │ │ │ │ ├── CopyKeyAction.java │ │ │ │ ├── CopyKeyValueAction.java │ │ │ │ ├── CopyNodeCommentAction.java │ │ │ │ ├── CopyNodePathAction.java │ │ │ │ ├── CopyValueAction.java │ │ │ │ ├── DisplayNodePathAction.java │ │ │ │ ├── ExpandAllAction.java │ │ │ │ ├── ExpandMultiAction.java │ │ │ │ ├── OptimizeSortAction.java │ │ │ │ ├── RefreshStructureAction.java │ │ │ │ ├── RemoveTreeNodeAction.java │ │ │ │ ├── RenameDiffTitleAction.java │ │ │ │ └── StructureComparisonAction.java │ │ │ ├── toolwindow │ │ │ │ ├── BackToEditorViewAction.java │ │ │ │ ├── ClearEditorAction.java │ │ │ │ ├── EditInNewWindowAction.java │ │ │ │ ├── FloatingWindowAction.java │ │ │ │ ├── JsonBeautifyToolWindowAction.java │ │ │ │ ├── JsonHistoryAction.java │ │ │ │ ├── JsonMinifyToolWindowAction.java │ │ │ │ ├── JsonQueryAction.java │ │ │ │ ├── JsonStructureToolWindowAction.java │ │ │ │ ├── ManageClipboardDataBlacklistAction.java │ │ │ │ ├── MoveToEditorAction.java │ │ │ │ ├── NewTabAction.java │ │ │ │ ├── OpenSettingsAction.java │ │ │ │ ├── RenameTabAction.java │ │ │ │ ├── SaveToDiskAction.java │ │ │ │ ├── ScrollToTheEndAction.java │ │ │ │ └── ToggleUseSoftWrapsAction.java │ │ │ └── transform │ │ │ │ ├── ToJson5Action.java │ │ │ │ ├── ToJsonAction.java │ │ │ │ ├── ToPropertiesAction.java │ │ │ │ ├── ToTomlAction.java │ │ │ │ ├── ToUrlParamAction.java │ │ │ │ ├── ToXmlAction.java │ │ │ │ └── ToYamlAction.java │ │ │ ├── bundle │ │ │ └── JsonAssistantBundle.java │ │ │ ├── constant │ │ │ ├── ActionHolder.java │ │ │ ├── ColorHolder.java │ │ │ ├── DataTypeConstant.java │ │ │ ├── DependencyConstant.java │ │ │ ├── FileTypeHolder.java │ │ │ ├── HtmlConstant.java │ │ │ ├── JsonAssistantPlugin.java │ │ │ ├── LanguageHolder.java │ │ │ ├── PluginConstant.java │ │ │ └── Urls.java │ │ │ ├── enums │ │ │ ├── ColorScheme.java │ │ │ ├── FileTypes.java │ │ │ ├── HistoryTreeNodeType.java │ │ │ ├── HistoryViewType.java │ │ │ ├── JsonAnnotations.java │ │ │ ├── JsonConversionTarget.java │ │ │ ├── JsonQuerySchema.java │ │ │ ├── JsonTreeNodeType.java │ │ │ ├── JsonValueHandleType.java │ │ │ ├── LombokAnnotations.java │ │ │ ├── StructureActionSource.java │ │ │ ├── SwaggerAnnotations.java │ │ │ ├── TextResolveStatus.java │ │ │ ├── TreeDisplayMode.java │ │ │ └── UrlType.java │ │ │ ├── extension │ │ │ ├── ProxyInjector.java │ │ │ ├── configurable │ │ │ │ └── JsonAssistantMainConfigurable.java │ │ │ ├── editor │ │ │ │ └── JsonTreeFileEditor.java │ │ │ ├── error │ │ │ │ └── ErrorReporter.java │ │ │ ├── provider │ │ │ │ ├── HelpProvider.java │ │ │ │ └── JsonTreeFileEditorProvider.java │ │ │ └── template │ │ │ │ └── JsonAssistantFileTemplateDescriptorFactory.java │ │ │ ├── inspection │ │ │ ├── ConvertTimestampInspection.java │ │ │ └── ExpandNestedJsonInspection.java │ │ │ ├── intention │ │ │ └── ConvertReadableTimeIntention.java │ │ │ ├── model │ │ │ ├── BlacklistEntry.java │ │ │ ├── EditorInitData.java │ │ │ ├── HistoryLimitedList.java │ │ │ ├── JsonEntry.java │ │ │ ├── StructureConfig.java │ │ │ ├── Version.java │ │ │ ├── YamlDocEntry.java │ │ │ ├── jackson │ │ │ │ ├── ColorDeserializer.java │ │ │ │ └── ColorSerializer.java │ │ │ ├── jsonpath │ │ │ │ ├── EvaluateResult.java │ │ │ │ ├── IncorrectDocument.java │ │ │ │ ├── IncorrectExpression.java │ │ │ │ ├── ResultNotFound.java │ │ │ │ └── ResultString.java │ │ │ ├── serializer │ │ │ │ └── LocalDateTimeTypeHandler.java │ │ │ ├── strategy │ │ │ │ ├── ClipboardTextConverter.java │ │ │ │ ├── GlobalJsonConverter.java │ │ │ │ ├── GlobalTextConverter.java │ │ │ │ ├── clipboard │ │ │ │ │ ├── Json5ConversionStrategy.java │ │ │ │ │ ├── JsonConversionStrategy.java │ │ │ │ │ ├── TomlConversionStrategy.java │ │ │ │ │ ├── UrlParamConversionStrategy.java │ │ │ │ │ ├── XmlConversionStrategy.java │ │ │ │ │ ├── YamlConversionStrategy.java │ │ │ │ │ └── context │ │ │ │ │ │ ├── ClipboardTextConversionContext.java │ │ │ │ │ │ └── ClipboardTextConversionStrategy.java │ │ │ │ └── formats │ │ │ │ │ ├── context │ │ │ │ │ ├── AbstractGlobalTextConversionProcessor.java │ │ │ │ │ ├── GlobalTextConversionProcessor.java │ │ │ │ │ └── GlobalTextConversionProcessorContext.java │ │ │ │ │ ├── data │ │ │ │ │ ├── ActionData.java │ │ │ │ │ ├── DocTextData.java │ │ │ │ │ ├── EditorData.java │ │ │ │ │ ├── FileTypeData.java │ │ │ │ │ ├── MessageData.java │ │ │ │ │ └── SelectionData.java │ │ │ │ │ └── processor │ │ │ │ │ ├── PropertiesConversionProcessor.java │ │ │ │ │ ├── TomlConversionProcessor.java │ │ │ │ │ ├── UrlParamConversionProcessor.java │ │ │ │ │ ├── XmlConversionProcessor.java │ │ │ │ │ ├── YamlConversionProcessor.java │ │ │ │ │ └── json │ │ │ │ │ ├── Json5BeautifyConversionProcessor.java │ │ │ │ │ ├── Json5ConversionProcessor.java │ │ │ │ │ ├── Json5MinifyConversionProcessor.java │ │ │ │ │ ├── JsonBeautifyConversionProcessor.java │ │ │ │ │ ├── JsonConversionProcessor.java │ │ │ │ │ └── JsonMinifyConversionProcessor.java │ │ │ ├── template │ │ │ │ ├── AnnotationModel.java │ │ │ │ ├── ClassModel.java │ │ │ │ ├── FieldModel.java │ │ │ │ ├── MapKey.java │ │ │ │ ├── ModelToMapConverter.java │ │ │ │ └── TemplateModel.java │ │ │ └── wrapper │ │ │ │ ├── ArrayWrapper.java │ │ │ │ ├── JsonWrapper.java │ │ │ │ └── ObjectWrapper.java │ │ │ ├── service │ │ │ ├── PluginActivityManager.java │ │ │ └── persistent │ │ │ │ ├── ClipboardDataBlacklistPersistentState.java │ │ │ │ ├── JsonAssistantPersistentState.java │ │ │ │ ├── JsonHistoryPersistentState.java │ │ │ │ ├── converter │ │ │ │ ├── AttributeSerializationStateConverter.java │ │ │ │ ├── BlacklistConverter.java │ │ │ │ ├── DeserializerStateConverter.java │ │ │ │ ├── EditorAppearanceStateConverter.java │ │ │ │ ├── EditorBehaviorStateConverter.java │ │ │ │ ├── GeneralStateConverter.java │ │ │ │ ├── HistoryLimitedListConverter.java │ │ │ │ ├── HistoryStateConverter.java │ │ │ │ ├── QueryStateConverter.java │ │ │ │ └── StructureStateConverter.java │ │ │ │ └── state │ │ │ │ ├── AttributeSerializationState.java │ │ │ │ ├── DeserializerState.java │ │ │ │ ├── EditorAppearanceState.java │ │ │ │ ├── EditorBehaviorState.java │ │ │ │ ├── GeneralState.java │ │ │ │ ├── HistoryState.java │ │ │ │ ├── QueryState.java │ │ │ │ └── StructureState.java │ │ │ ├── toolwindow │ │ │ ├── AuxiliaryTreeToolWindowManager.java │ │ │ └── JsonAssistantToolWindowFactory.java │ │ │ ├── ui │ │ │ ├── AuxiliaryTreeToolWindowComponentProvider.java │ │ │ ├── JsonAssistantMainConfigurableComponentProvider.form │ │ │ ├── JsonAssistantMainConfigurableComponentProvider.java │ │ │ ├── JsonAssistantToolWindowComponentProvider.java │ │ │ ├── JsonQueryComponentProvider.java │ │ │ ├── JsonStructureComponentProvider.java │ │ │ ├── JsonTreeEditorComponentProvider.java │ │ │ ├── color │ │ │ │ └── EditorBackgroundScheme.java │ │ │ ├── component │ │ │ │ ├── ActionGroupPopupButton.java │ │ │ │ └── SearchHistoryButton.java │ │ │ ├── decorator │ │ │ │ └── TextEditorErrorPopupDecorator.java │ │ │ ├── dialog │ │ │ │ ├── DiffNameDialog.form │ │ │ │ ├── DiffNameDialog.java │ │ │ │ ├── JsonBlacklistDialog.java │ │ │ │ ├── JsonHistoryListChooser.java │ │ │ │ ├── JsonHistoryTreeChooser.java │ │ │ │ ├── JsonStructureDialog.java │ │ │ │ ├── JsonToJavaBeanDialog.java │ │ │ │ ├── ManuallySaveHistoryDialog.java │ │ │ │ ├── MultiYamlDocumentChooser.java │ │ │ │ ├── PreviewClipboardDataDialog.java │ │ │ │ ├── SupportDialog.form │ │ │ │ └── SupportDialog.java │ │ │ ├── editor │ │ │ │ ├── CustomizedLanguageTextEditor.java │ │ │ │ ├── SearchTextField.java │ │ │ │ ├── SearchTextField2.java │ │ │ │ ├── ViewerModeLanguageTextEditor.java │ │ │ │ └── extension │ │ │ │ │ └── SearchExtension.java │ │ │ ├── icon │ │ │ │ ├── CircleIcon.java │ │ │ │ └── ToggleIcon.java │ │ │ ├── listener │ │ │ │ ├── HyperLinkListenerImpl.java │ │ │ │ ├── ListRightClickPopupMenuMouseAdapter.java │ │ │ │ └── TreeRightClickPopupMenuMouseAdapter.java │ │ │ ├── node │ │ │ │ ├── HistoryTreeNode.java │ │ │ │ └── JsonTreeNode.java │ │ │ └── panel │ │ │ │ ├── AuxiliaryTreeToolWindowPanel.java │ │ │ │ ├── CombineCardLayout.java │ │ │ │ ├── HyperLinkJBLabel.java │ │ │ │ ├── JsonAssistantToolWindowPanel.java │ │ │ │ └── SearchWrapper.java │ │ │ └── util │ │ │ ├── DataConverter.java │ │ │ ├── HintUtil.java │ │ │ ├── JavaDebugUtil.java │ │ │ ├── JavaUtil.java │ │ │ ├── JmesPathEvaluator.java │ │ │ ├── Json5Util.java │ │ │ ├── JsonAssistantUtil.java │ │ │ ├── JsonPathEvaluator.java │ │ │ ├── JsonUtil.java │ │ │ ├── JsonValueHandler.java │ │ │ ├── KotlinUtil.java │ │ │ ├── Notifications.java │ │ │ ├── PlatformUtil.java │ │ │ ├── PsiUtil.java │ │ │ ├── TextTransformUtil.java │ │ │ ├── TomlUtil.java │ │ │ ├── ToolWindowUtil.java │ │ │ ├── UIManager.java │ │ │ ├── XmlUtil.java │ │ │ └── YamlUtil.java │ ├── icons │ │ └── JsonAssistantIcons.java │ └── thirdparty │ │ └── a2u │ │ └── tn │ │ └── utils │ │ └── json │ │ ├── IGetCollection.java │ │ ├── JsonParser.java │ │ ├── JsonSerializer.java │ │ ├── MapNavigator.java │ │ ├── ParseException.java │ │ ├── SerializeException.java │ │ ├── TnJson.java │ │ └── TnJsonBuilder.java └── resources │ ├── JsonAssistantIconMappings.json │ ├── META-INF │ ├── optional │ │ ├── plugin-java.xml │ │ ├── plugin-json.xml │ │ ├── plugin-kotlin.xml │ │ ├── plugin-properties.xml │ │ ├── plugin-toml.xml │ │ ├── plugin-xdebugger.xml │ │ ├── plugin-xml.xml │ │ └── plugin-yaml.xml │ ├── plugin.xml │ ├── pluginIcon.svg │ └── pluginIcon_dark.svg │ ├── fileTemplates │ └── j2ee │ │ ├── New Class.java.ft │ │ ├── New Class.java.html │ │ ├── New Kotlin Class.kt.ft │ │ └── New Kotlin Class.kt.html │ ├── html │ └── Timeout.html │ ├── icons │ ├── beta.svg │ ├── book_reader.svg │ ├── book_reader_dark.svg │ ├── box.svg │ ├── checkmark.svg │ ├── checkmark_dark.svg │ ├── conversion.svg │ ├── diff.svg │ ├── dizzy_star.svg │ ├── donate.svg │ ├── donate_dark.svg │ ├── esc.svg │ ├── esc_dark.svg │ ├── escape.svg │ ├── expui │ │ ├── book_reader.svg │ │ ├── book_reader_dark.svg │ │ ├── donate.svg │ │ ├── donate_dark.svg │ │ ├── esc.svg │ │ ├── esc_dark.svg │ │ ├── fileTypes │ │ │ ├── kv.svg │ │ │ ├── kv_dark.svg │ │ │ ├── toml.svg │ │ │ ├── toml_dark.svg │ │ │ ├── url.svg │ │ │ └── url_dark.svg │ │ ├── group.svg │ │ ├── groupByClass.svg │ │ ├── groupByClass_dark.svg │ │ ├── group_dark.svg │ │ ├── json.svg │ │ ├── json_dark.svg │ │ ├── rotate.svg │ │ ├── rotate_dark.svg │ │ ├── structure │ │ │ ├── compare_structure.svg │ │ │ └── compare_structure_dark.svg │ │ ├── toolWindowJsonPath.svg │ │ ├── toolWindowJsonPath_dark.svg │ │ └── toolwindow │ │ │ ├── delete.svg │ │ │ ├── delete_dark.svg │ │ │ ├── logo.svg │ │ │ ├── logo@20x20.svg │ │ │ ├── logo@20x20_dark.svg │ │ │ ├── logo_dark.svg │ │ │ ├── magic.svg │ │ │ ├── magic_dark.svg │ │ │ ├── minify.svg │ │ │ ├── minify_dark.svg │ │ │ ├── save.svg │ │ │ ├── save_dark.svg │ │ │ ├── scrollDown.svg │ │ │ ├── scrollDown_dark.svg │ │ │ ├── search.svg │ │ │ ├── search_dark.svg │ │ │ ├── softWrap.svg │ │ │ ├── softWrap_dark.svg │ │ │ ├── structure.svg │ │ │ ├── structure_dark.svg │ │ │ ├── structure_logo.svg │ │ │ ├── structure_logo@20x20.svg │ │ │ ├── structure_logo@20x20_dark.svg │ │ │ ├── structure_logo_dark.svg │ │ │ ├── switch.svg │ │ │ ├── switch_dark.svg │ │ │ ├── text.svg │ │ │ └── text_dark.svg │ ├── fileTypes │ │ ├── kv.svg │ │ ├── kv_dark.svg │ │ ├── toml-file.svg │ │ ├── toml-file_dark.svg │ │ ├── url.svg │ │ └── url_dark.svg │ ├── function.svg │ ├── group.svg │ ├── groupByClass.svg │ ├── groupByClass_dark.svg │ ├── group_dark.svg │ ├── heart.svg │ ├── json.svg │ ├── json_dark.svg │ ├── label.svg │ ├── open.svg │ ├── shortcuts.svg │ ├── star_fall_mini.svg │ ├── star_fall_mini_dark.svg │ ├── structure.svg │ ├── structure │ │ ├── compare_structure.svg │ │ ├── compare_structure_dark.svg │ │ ├── intellij_collapseAll.svg │ │ ├── intellij_collapseAll_dark.svg │ │ ├── intellij_expandAll.svg │ │ ├── intellij_expandAll_dark.svg │ │ ├── json_array.svg │ │ ├── json_array_dark.svg │ │ ├── json_item.svg │ │ ├── json_item_dark.svg │ │ ├── json_key.svg │ │ ├── json_key_dark.svg │ │ ├── json_object.svg │ │ ├── json_object_dark.svg │ │ ├── json_object_item.svg │ │ ├── json_object_item_dark.svg │ │ ├── path.svg │ │ ├── path_dark.svg │ │ ├── refresh.svg │ │ └── refresh_dark.svg │ ├── sun.svg │ ├── switch_display.svg │ └── toolwindow │ │ ├── delete.svg │ │ ├── delete_dark.svg │ │ ├── eye_off.svg │ │ ├── eye_off_dark.svg │ │ ├── history.svg │ │ ├── history_dark.svg │ │ ├── import_history.svg │ │ ├── import_history_dark.svg │ │ ├── logo.svg │ │ ├── logo_dark.svg │ │ ├── magic.svg │ │ ├── magic_dark.svg │ │ ├── minify.svg │ │ ├── minify_dark.svg │ │ ├── pencil.svg │ │ ├── pencil_dark.svg │ │ ├── pencil_star.svg │ │ ├── pencil_star_dark.svg │ │ ├── save.svg │ │ ├── save_dark.svg │ │ ├── scrollDown.svg │ │ ├── scrollDown_dark.svg │ │ ├── search.svg │ │ ├── search_dark.svg │ │ ├── settings.svg │ │ ├── settings_dark.svg │ │ ├── softWrap.svg │ │ ├── softWrap_dark.svg │ │ ├── structure.svg │ │ ├── structure_dark.svg │ │ ├── structure_logo.svg │ │ ├── structure_logo_dark.svg │ │ ├── switch.svg │ │ ├── switch_dark.svg │ │ ├── text.svg │ │ └── text_dark.svg │ ├── images │ ├── alipay.png │ └── wechat_pay.png │ ├── inspectionDescriptions │ ├── ConvertTimestamp.html │ └── ExpandNestedJson.html │ ├── intentionDescriptions │ └── ConvertReadableTimeIntention │ │ ├── after.json.template │ │ ├── before.json.template │ │ └── description.html │ └── messages │ ├── JsonAssistantBundle.properties │ └── JsonAssistantBundle_zh.properties └── test ├── kotlin └── org │ └── jetbrains │ └── plugins │ └── template │ └── MyPluginTest.kt └── testData └── rename ├── foo.xml └── foo_after.xml /.github/ISSUE_TEMPLATE/bug_report_zh.yml: -------------------------------------------------------------------------------- 1 | name: "🐛 Bug报告" 2 | description: 报告错误或异常行为。 3 | labels: ["bug"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | 感谢您花时间填写这份Bug报告!请确保在提交新报告之前[搜索现有问题](https://github.com/MemoryZy/Json-Assistant/issues)。 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: 📝 问题描述 13 | description: 请清晰简洁地描述是什么样的问题,重现问题的步骤,发生了什么事,以及您期望的行为应该是什么。如果可以,请添加屏幕截图以帮助解释您的问题。 14 | placeholder: | 15 | 例如: 16 | 1. 打开工具窗口 17 | 2. 工具窗口无法加载 18 | 3. 期望的行为是正常加载工具窗口 19 | validations: 20 | required: true 21 | - type: input 22 | id: version 23 | attributes: 24 | label: 🏷 插件版本 25 | description: 您正在运行的是哪个版本的插件? 26 | placeholder: 例如:1.6.0 27 | validations: 28 | required: true 29 | - type: textarea 30 | id: runtime_env 31 | attributes: 32 | label: 💻 IDE及运行环境 33 | description: 请提供您正在使用的 IDE 的详细信息,以及您的运行环境信息(操作系统、JRE版本等)。快速获取所有信息:IDE 主菜单 > Help > About > 点击 “Copy” 按钮拷贝到剪贴板。 34 | placeholder: | 35 | IntelliJ IDEA 2023.2.4 (Ultimate Edition) 36 | Build #IU-232.10203.10, built on October 25, 2023 37 | Licensed to gurgles tumbles 38 | You have a perpetual fallback license for this version. 39 | Subscription is active until September 14, 2026. 40 | Runtime version: 17.0.8.1+7-b1000.32 amd64 41 | VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. 42 | Windows 11.0 43 | ... 44 | render: plain text 45 | validations: 46 | required: true 47 | - type: textarea 48 | id: stacktrace 49 | attributes: 50 | label: 📋 堆栈跟踪 51 | description: 如果插件崩溃,且您能获取堆栈跟踪信息,请将其粘贴到此处。如果您不知道如何获取堆栈跟踪信息,请忽略此项。 52 | render: plain text 53 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: "💡 Feature/enhancement request" 2 | description: Propose something new. 3 | labels: ["feature request"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Please limit one request per issue. 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: Feature/Enhancement Description 13 | placeholder: | 14 | What is the expected behavior of the proposed feature? 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: solution 19 | attributes: 20 | label: Proposed Solution 21 | placeholder: | 22 | Describe the solution you'd like in a clear and concise manner. 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: additional 27 | attributes: 28 | label: Additional Information 29 | placeholder: | 30 | Add any other context about the problem here. 31 | validations: 32 | required: false 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request_zh.yml: -------------------------------------------------------------------------------- 1 | name: "💡 功能需求/建议" 2 | description: 提出新的功能需求或建议. 3 | labels: ["feature request"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | 请限制每个议题只包含一个需求或建议。 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: 需求/建议描述 13 | placeholder: | 14 | 新功能/建议的预期行为是什么? 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: solution 19 | attributes: 20 | label: 建议的解决方案 21 | placeholder: | 22 | 请以清晰简洁的方式描述您建议的解决方案。 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: additional 27 | attributes: 28 | label: 附加信息 29 | placeholder: | 30 | 请在此处添加有关该功能需求的其他信息。 31 | validations: 32 | required: false 33 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Dependabot configuration: 2 | # https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates 3 | 4 | version: 2 5 | updates: 6 | # Maintain dependencies for Gradle dependencies 7 | - package-ecosystem: "gradle" 8 | directory: "/" 9 | target-branch: "next" # 将其改为main,可自动升级组件 10 | schedule: 11 | interval: "daily" 12 | # Maintain dependencies for GitHub Actions 13 | - package-ecosystem: "github-actions" 14 | directory: "/" 15 | target-branch: "next" 16 | schedule: 17 | interval: "daily" 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | .qodana 4 | build 5 | -------------------------------------------------------------------------------- /.run/Run IDE for UI Tests.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 15 | 17 | true 18 | true 19 | false 20 | 21 | 22 | -------------------------------------------------------------------------------- /.run/Run IDE with Plugin.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 17 | 19 | true 20 | true 21 | false 22 | false 23 | 24 | 25 | -------------------------------------------------------------------------------- /.run/Run Plugin Tests.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 17 | 19 | true 20 | true 21 | false 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.run/Run Plugin Verification.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 17 | 19 | true 20 | true 21 | false 22 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /.run/Run Qodana.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 16 | 19 | 21 | true 22 | true 23 | false 24 | 25 | 26 | -------------------------------------------------------------------------------- /DESCRIPTION.md: -------------------------------------------------------------------------------- 1 | **JSON Tool Plugin based on IntelliJ IDEs.It makes JSON processing a breeze!** 2 | 3 |
4 | 5 | **[Getting Started](https://json.memoryzy.cn/overview) | 6 | [Github](https://github.com/MemoryZy/Json-Assistant) | 7 | [Donate](https://json.memoryzy.cn/support)** 8 | 9 |
10 | 11 | ## Key Features 12 | - Full [JSON5](https://json5.org/) Support 13 | - JSON Window 14 | - History 15 | - JSONPath/JMESPath Query 16 | - JSON Processing 17 | - Beautify 18 | - Minify 19 | - Tree View 20 | - Compare 21 | - Escape 22 | - Serialization 23 | - JavaBean to JSON Conversion 24 | - JavaBean to JSON5 Conversion (Including Comments) 25 | - Runtime Object to JSON Conversion 26 | - JSON to JavaBean Conversion 27 | - JSON5 to JavaBean Conversion (Including Comments) 28 | - Kotlin Properties to JSON 29 | - Extract Java Constants to JSON 30 | - Format Conversion 31 | - XML 32 | - YAML 33 | - Toml 34 | - Properties 35 | - URL Params 36 | - Extensions 37 | - Convert between Timestamp and Standard Date Format 38 | - Parse nested JSON strings into objects/arrays 39 | 40 |
41 | 42 | ## Getting Started 43 | When the editor contains only valid JSON text or when valid JSON is selected, you can use the `Alt+K` shortcut or right-click and choose `Json Assistant` to bring up the action menu. 44 | 45 | For more operations, please refer to the [plugin documentation](https://json.memoryzy.cn/overview). 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Memory 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | This project includes code modified from the following projects: 2 | - tnjson (licensed under the Unlicense), original source: https://github.com/anymaker/tnjson -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MemoryZy/Json-Assistant/fa572bd5748c9d91f426af7924ffac32dee47210/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /qodana.yml: -------------------------------------------------------------------------------- 1 | # Qodana configuration: 2 | # https://www.jetbrains.com/help/qodana/qodana-yaml.html 3 | 4 | version: 1.0 5 | linter: jetbrains/qodana-jvm-community:latest 6 | projectJDK: "11" 7 | profile: 8 | name: qodana.recommended 9 | exclude: 10 | - name: All 11 | paths: 12 | - .qodana 13 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "Json Assistant" 2 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/JsonBeautifyAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.model.strategy.GlobalJsonConverter; 5 | import cn.memoryzy.json.util.PlatformUtil; 6 | import com.intellij.openapi.actionSystem.AnActionEvent; 7 | import com.intellij.openapi.actionSystem.DataContext; 8 | import com.intellij.openapi.actionSystem.Presentation; 9 | import com.intellij.openapi.actionSystem.UpdateInBackground; 10 | import com.intellij.openapi.project.DumbAwareAction; 11 | import icons.JsonAssistantIcons; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | /** 15 | * @author Memory 16 | * @since 2024/6/21 17 | */ 18 | public class JsonBeautifyAction extends DumbAwareAction implements UpdateInBackground { 19 | 20 | public JsonBeautifyAction() { 21 | super(); 22 | setEnabledInModalContext(true); 23 | Presentation presentation = getTemplatePresentation(); 24 | presentation.setText(JsonAssistantBundle.message("action.beautify.text")); 25 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.beautify.description")); 26 | presentation.setIcon(JsonAssistantIcons.DIZZY_STAR); 27 | } 28 | 29 | @Override 30 | public void actionPerformed(@NotNull AnActionEvent event) { 31 | DataContext dataContext = event.getDataContext(); 32 | GlobalJsonConverter.parseAndProcessJson( 33 | dataContext, PlatformUtil.getEditor(dataContext), true, 34 | JsonAssistantBundle.messageOnSystem("hint.selection.beautify"), 35 | JsonAssistantBundle.messageOnSystem("hint.global.beautify")); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/JsonMinifyAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.model.strategy.GlobalJsonConverter; 5 | import cn.memoryzy.json.util.PlatformUtil; 6 | import com.intellij.openapi.actionSystem.AnActionEvent; 7 | import com.intellij.openapi.actionSystem.DataContext; 8 | import com.intellij.openapi.actionSystem.Presentation; 9 | import com.intellij.openapi.actionSystem.UpdateInBackground; 10 | import com.intellij.openapi.project.DumbAwareAction; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | /** 14 | * @author Memory 15 | * @since 2024/6/21 16 | */ 17 | public class JsonMinifyAction extends DumbAwareAction implements UpdateInBackground { 18 | 19 | public JsonMinifyAction() { 20 | super(); 21 | setEnabledInModalContext(true); 22 | Presentation presentation = getTemplatePresentation(); 23 | presentation.setText(JsonAssistantBundle.message("action.minify.text")); 24 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.minify.description")); 25 | } 26 | 27 | @Override 28 | public void actionPerformed(@NotNull AnActionEvent event) { 29 | DataContext dataContext = event.getDataContext(); 30 | GlobalJsonConverter.parseAndProcessJson( 31 | dataContext, PlatformUtil.getEditor(dataContext), false, 32 | JsonAssistantBundle.messageOnSystem("hint.selection.minify"), 33 | JsonAssistantBundle.messageOnSystem("hint.global.minify")); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/JsonToKotlinClassAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import com.intellij.openapi.actionSystem.AnAction; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.Presentation; 7 | import com.intellij.openapi.actionSystem.UpdateInBackground; 8 | import icons.JsonAssistantIcons; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2025/4/7 14 | */ 15 | public class JsonToKotlinClassAction extends AnAction implements UpdateInBackground { 16 | 17 | public JsonToKotlinClassAction() { 18 | super(); 19 | setEnabledInModalContext(true); 20 | Presentation presentation = getTemplatePresentation(); 21 | presentation.setText(JsonAssistantBundle.message("action.kotlin.deserialize.text")); 22 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.kotlin.deserialize.description")); 23 | // TODO 图标更换 24 | presentation.setIcon(JsonAssistantIcons.GROUP_BY_CLASS); 25 | } 26 | 27 | @Override 28 | public void actionPerformed(@NotNull AnActionEvent e) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/OnlineDocAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.util.PlatformUtil; 5 | import com.intellij.icons.AllIcons; 6 | import com.intellij.openapi.actionSystem.AnActionEvent; 7 | import com.intellij.openapi.actionSystem.Presentation; 8 | import com.intellij.openapi.actionSystem.UpdateInBackground; 9 | import com.intellij.openapi.project.DumbAwareAction; 10 | import icons.JsonAssistantIcons; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | /** 14 | * @author Memory 15 | * @since 2024/8/6 16 | */ 17 | public class OnlineDocAction extends DumbAwareAction implements UpdateInBackground { 18 | private final boolean popupAction; 19 | 20 | public OnlineDocAction() { 21 | this(false); 22 | } 23 | 24 | public OnlineDocAction(boolean popupAction) { 25 | super(); 26 | this.popupAction = popupAction; 27 | setEnabledInModalContext(true); 28 | Presentation presentation = getTemplatePresentation(); 29 | presentation.setText(popupAction ? JsonAssistantBundle.message("action.online.doc.override.text") : JsonAssistantBundle.message("action.online.doc.text")); 30 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.online.doc.description")); 31 | presentation.setIcon(popupAction ? AllIcons.Actions.Help : JsonAssistantIcons.BOOK_READER); 32 | } 33 | 34 | @Override 35 | public void actionPerformed(@NotNull AnActionEvent event) { 36 | PlatformUtil.openOnlineDoc(event.getProject(), popupAction); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/ShortcutAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.constant.ActionHolder; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.Presentation; 7 | import com.intellij.openapi.actionSystem.UpdateInBackground; 8 | import com.intellij.openapi.application.ApplicationManager; 9 | import com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog; 10 | import com.intellij.openapi.project.DumbAwareAction; 11 | import icons.JsonAssistantIcons; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | /** 15 | * @author Memory 16 | * @since 2024/8/3 17 | */ 18 | public class ShortcutAction extends DumbAwareAction implements UpdateInBackground { 19 | 20 | public ShortcutAction() { 21 | super(); 22 | setEnabledInModalContext(true); 23 | Presentation presentation = getTemplatePresentation(); 24 | presentation.setText(JsonAssistantBundle.message("action.shortcut.text")); 25 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.shortcut.description")); 26 | presentation.setIcon(JsonAssistantIcons.SHORTCUTS); 27 | } 28 | 29 | @Override 30 | public void actionPerformed(@NotNull AnActionEvent event) { 31 | EditKeymapsDialog dialog = new EditKeymapsDialog(null, ActionHolder.MAIN_ACTION_ID); 32 | ApplicationManager.getApplication().invokeLater(dialog::show); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/FastJson2ToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/1/21 12 | */ 13 | public class FastJson2ToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public FastJson2ToggleAction(DeserializerState deserializerState) { 18 | super("@JSONField (FastJSON2)", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.fastJson2Annotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.fastJson2Annotation = state; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/FastJsonToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/12/26 12 | */ 13 | public class FastJsonToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public FastJsonToggleAction(DeserializerState deserializerState) { 18 | super("@JSONField (FastJSON)", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.fastJsonAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.fastJsonAnnotation = state; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/JacksonToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/12/26 12 | */ 13 | public class JacksonToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public JacksonToggleAction(DeserializerState deserializerState) { 18 | super("@JsonProperty (Jackson)", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.jacksonAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.jacksonAnnotation = state; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/KeepCamelToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.ToggleAction; 7 | import com.intellij.openapi.actionSystem.UpdateInBackground; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * @author Memory 12 | * @since 2024/12/26 13 | */ 14 | public class KeepCamelToggleAction extends ToggleAction implements UpdateInBackground { 15 | 16 | private final DeserializerState deserializerState; 17 | 18 | public KeepCamelToggleAction(DeserializerState deserializerState) { 19 | super(JsonAssistantBundle.messageOnSystem("popup.deserializer.keepCamel.text"), null, null); 20 | this.deserializerState = deserializerState; 21 | } 22 | 23 | @Override 24 | public boolean isSelected(@NotNull AnActionEvent e) { 25 | return deserializerState.keepCamelCase; 26 | } 27 | 28 | @Override 29 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 30 | deserializerState.keepCamelCase = state; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/comment/SwaggerToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.comment; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/4/1 12 | */ 13 | public class SwaggerToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public SwaggerToggleAction(DeserializerState deserializerState) { 18 | super("@ApiModelProperty (Swagger)", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.swaggerAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.swaggerAnnotation = state; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/comment/SwaggerV3ToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.comment; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/4/1 12 | */ 13 | public class SwaggerV3ToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public SwaggerV3ToggleAction(DeserializerState deserializerState) { 18 | super("@Schema (Swagger V3)", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.swaggerV3Annotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.swaggerV3Annotation = state; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/lombok/AccessorsToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.lombok; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/1/21 12 | */ 13 | public class AccessorsToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public AccessorsToggleAction(DeserializerState deserializerState) { 18 | super("@Accessors", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.accessorsChainLombokAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.accessorsChainLombokAnnotation = state; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/lombok/DataToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.lombok; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/1/21 12 | */ 13 | public class DataToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public DataToggleAction(DeserializerState deserializerState) { 18 | super("@Data", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.dataLombokAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.dataLombokAnnotation = state; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/lombok/GetterToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.lombok; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/1/21 12 | */ 13 | public class GetterToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public GetterToggleAction(DeserializerState deserializerState) { 18 | super("@Getter", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.getterLombokAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.getterLombokAnnotation = state; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/lombok/LombokGroup.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.lombok; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnAction; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.DefaultActionGroup; 7 | import com.intellij.openapi.actionSystem.UpdateInBackground; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * @author Memory 16 | * @since 2025/1/21 17 | */ 18 | public class LombokGroup extends DefaultActionGroup implements UpdateInBackground { 19 | 20 | private final DeserializerState deserializerState; 21 | 22 | public LombokGroup(DeserializerState deserializerState) { 23 | super("Lombok Annotations", true); 24 | this.deserializerState = deserializerState; 25 | } 26 | 27 | @Override 28 | public AnAction @NotNull [] getChildren(@Nullable AnActionEvent e) { 29 | List actions = new ArrayList<>(); 30 | actions.add(new DataToggleAction(deserializerState)); 31 | actions.add(new AccessorsToggleAction(deserializerState)); 32 | actions.add(new GetterToggleAction(deserializerState)); 33 | actions.add(new SetterToggleAction(deserializerState)); 34 | return actions.toArray(new AnAction[0]); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/deserializer/lombok/SetterToggleAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.deserializer.lombok; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.actionSystem.ToggleAction; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/1/21 12 | */ 13 | public class SetterToggleAction extends ToggleAction implements UpdateInBackground { 14 | 15 | private final DeserializerState deserializerState; 16 | 17 | public SetterToggleAction(DeserializerState deserializerState) { 18 | super("@Setter", null, null); 19 | this.deserializerState = deserializerState; 20 | } 21 | 22 | @Override 23 | public boolean isSelected(@NotNull AnActionEvent e) { 24 | return deserializerState.setterLombokAnnotation; 25 | } 26 | 27 | @Override 28 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 29 | deserializerState.setterLombokAnnotation = state; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/group/ConvertOtherFormatsGroup.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.group; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.constant.ActionHolder; 5 | import com.intellij.openapi.actionSystem.*; 6 | import com.intellij.openapi.project.DumbAware; 7 | import icons.JsonAssistantIcons; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2024/8/3 14 | */ 15 | public class ConvertOtherFormatsGroup extends DefaultActionGroup implements DumbAware, UpdateInBackground { 16 | 17 | public ConvertOtherFormatsGroup() { 18 | super(); 19 | setPopup(true); 20 | setEnabledInModalContext(true); 21 | Presentation templatePresentation = getTemplatePresentation(); 22 | templatePresentation.setText(JsonAssistantBundle.message("group.convert.other.formats.text")); 23 | templatePresentation.setDescription(JsonAssistantBundle.messageOnSystem("group.convert.other.formats.description")); 24 | templatePresentation.setIcon(JsonAssistantIcons.FUNCTION); 25 | } 26 | 27 | @Override 28 | public AnAction @NotNull [] getChildren(@Nullable AnActionEvent event) { 29 | return new AnAction[]{ 30 | ActionHolder.TO_XML_ACTION, 31 | ActionHolder.TO_YAML_ACTION, 32 | ActionHolder.TO_TOML_ACTION, 33 | ActionHolder.TO_JSON5_ACTION, 34 | ActionHolder.TO_JSON_ACTION, 35 | ActionHolder.TO_PROPERTIES_ACTION, 36 | ActionHolder.TO_URL_PARAM_ACTION 37 | }; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/notification/DonateAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.notification; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.ui.dialog.SupportDialog; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import com.intellij.openapi.project.DumbAwareAction; 8 | import icons.JsonAssistantIcons; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2024/7/5 14 | */ 15 | public class DonateAction extends DumbAwareAction implements UpdateInBackground { 16 | 17 | public DonateAction(String text) { 18 | super(text, JsonAssistantBundle.messageOnSystem("action.donate.description"), JsonAssistantIcons.DONATE); 19 | } 20 | 21 | @Override 22 | public void actionPerformed(@NotNull AnActionEvent event) { 23 | new SupportDialog().show(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/notification/QuickStartAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.notification; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.util.PlatformUtil; 5 | import com.intellij.icons.AllIcons; 6 | import com.intellij.openapi.actionSystem.AnActionEvent; 7 | import com.intellij.openapi.actionSystem.UpdateInBackground; 8 | import com.intellij.openapi.project.DumbAwareAction; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2024/7/26 14 | */ 15 | public class QuickStartAction extends DumbAwareAction implements UpdateInBackground { 16 | 17 | public QuickStartAction() { 18 | super(JsonAssistantBundle.messageOnSystem("action.quick.start.text"), 19 | JsonAssistantBundle.messageOnSystem("action.quick.start.description"), 20 | AllIcons.General.Web); 21 | } 22 | 23 | @Override 24 | public void actionPerformed(@NotNull AnActionEvent event) { 25 | PlatformUtil.openOnlineDoc(event.getProject(), true); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/structure/CollapseMultiAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.structure; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.util.UIManager; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.UpdateInBackground; 7 | import com.intellij.openapi.project.DumbAwareAction; 8 | import com.intellij.ui.treeStructure.Tree; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import javax.swing.tree.TreePath; 12 | 13 | public class CollapseMultiAction extends DumbAwareAction implements UpdateInBackground { 14 | private final Tree tree; 15 | 16 | public CollapseMultiAction(Tree tree) { 17 | super(JsonAssistantBundle.message("action.structure.collapse.multi.text"), 18 | JsonAssistantBundle.messageOnSystem("action.structure.collapse.multi.description"), 19 | null); 20 | this.tree = tree; 21 | } 22 | 23 | @Override 24 | public void actionPerformed(@NotNull AnActionEvent event) { 25 | TreePath[] paths = tree.getSelectionPaths(); 26 | if (paths != null) { 27 | for (TreePath path : paths) { 28 | UIManager.collapseAll(tree, path); 29 | } 30 | } 31 | } 32 | 33 | 34 | @Override 35 | @SuppressWarnings("DuplicatedCode") 36 | public void update(@NotNull AnActionEvent event) { 37 | event.getPresentation().setEnabledAndVisible(ExpandMultiAction.isEnabled(tree)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/structure/DisplayNodePathAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.structure; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.service.persistent.state.StructureState; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.CheckedActionGroup; 7 | import com.intellij.openapi.actionSystem.ToggleAction; 8 | import com.intellij.openapi.project.DumbAware; 9 | import icons.JsonAssistantIcons; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | /** 13 | * @author Memory 14 | * @since 2025/4/7 15 | */ 16 | public class DisplayNodePathAction extends ToggleAction implements CheckedActionGroup, DumbAware { 17 | 18 | private final StructureState structureState; 19 | 20 | public DisplayNodePathAction(StructureState structureState) { 21 | super(JsonAssistantBundle.messageOnSystem("action.displayNodePath.text"), JsonAssistantBundle.messageOnSystem("action.displayNodePath.description"), JsonAssistantIcons.Structure.PATH); 22 | this.structureState = structureState; 23 | } 24 | 25 | @Override 26 | public boolean isSelected(@NotNull AnActionEvent e) { 27 | return structureState.displayNodePath; 28 | } 29 | 30 | @Override 31 | public void setSelected(@NotNull AnActionEvent e, boolean state) { 32 | structureState.displayNodePath = state; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/toolwindow/FloatingWindowAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.toolwindow; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import com.intellij.openapi.actionSystem.*; 5 | import com.intellij.openapi.project.DumbAware; 6 | import com.intellij.openapi.wm.ToolWindow; 7 | import com.intellij.openapi.wm.ToolWindowType; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.Objects; 11 | 12 | public class FloatingWindowAction extends ToggleAction implements DumbAware, UpdateInBackground { 13 | 14 | private final ToolWindow toolWindow; 15 | 16 | public FloatingWindowAction(ToolWindow toolWindow) { 17 | super(); 18 | this.toolWindow = toolWindow; 19 | setEnabledInModalContext(true); 20 | Presentation presentation = getTemplatePresentation(); 21 | presentation.setText(JsonAssistantBundle.message("action.floating.window.text")); 22 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.floating.window.description")); 23 | registerCustomShortcutSet(CustomShortcutSet.fromString("ctrl alt F"), toolWindow.getComponent()); 24 | } 25 | 26 | @Override 27 | public boolean isSelected(@NotNull AnActionEvent event) { 28 | return Objects.equals(ToolWindowType.FLOATING, toolWindow.getType()); 29 | } 30 | 31 | @Override 32 | public void setSelected(@NotNull AnActionEvent event, boolean state) { 33 | if (state) { 34 | toolWindow.setType(ToolWindowType.FLOATING, null); 35 | } else { 36 | toolWindow.setType(ToolWindowType.DOCKED, null); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/action/toolwindow/ManageClipboardDataBlacklistAction.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.action.toolwindow; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import cn.memoryzy.json.ui.dialog.JsonBlacklistDialog; 5 | import com.intellij.openapi.actionSystem.AnActionEvent; 6 | import com.intellij.openapi.actionSystem.CustomShortcutSet; 7 | import com.intellij.openapi.actionSystem.Presentation; 8 | import com.intellij.openapi.actionSystem.UpdateInBackground; 9 | import com.intellij.openapi.project.DumbAwareAction; 10 | import com.intellij.openapi.wm.ex.ToolWindowEx; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | /** 14 | * @author Memory 15 | * @since 2025/3/3 16 | */ 17 | public class ManageClipboardDataBlacklistAction extends DumbAwareAction implements UpdateInBackground { 18 | 19 | public ManageClipboardDataBlacklistAction(ToolWindowEx toolWindowEx) { 20 | super(); 21 | setEnabledInModalContext(true); 22 | Presentation presentation = getTemplatePresentation(); 23 | presentation.setText(JsonAssistantBundle.message("action.manage.clipboard.data.blacklist.text")); 24 | presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.manage.clipboard.data.blacklist.description")); 25 | 26 | registerCustomShortcutSet(CustomShortcutSet.fromString("alt L"), toolWindowEx.getComponent()); 27 | } 28 | 29 | @Override 30 | public void actionPerformed(@NotNull AnActionEvent e) { 31 | new JsonBlacklistDialog(getEventProject(e)).show(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/constant/ColorHolder.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.constant; 2 | 3 | import com.intellij.ui.JBColor; 4 | import com.intellij.util.ui.JBUI; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.awt.*; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/10 12 | */ 13 | public interface ColorHolder { 14 | 15 | interface Foreground { 16 | @NotNull 17 | Color DISABLED = JBColor.namedColor("Link.disabledForeground", JBUI.CurrentTheme.Label.disabledForeground()); 18 | @NotNull 19 | Color ENABLED = JBColor.namedColor("Link.activeForeground", JBColor.namedColor("link.foreground", 0x589DF6)); 20 | @NotNull 21 | Color HOVERED = JBColor.namedColor("Link.hoverForeground", JBColor.namedColor("link.hover.foreground", ENABLED)); 22 | @NotNull 23 | Color PRESSED = JBColor.namedColor("Link.pressedForeground", JBColor.namedColor("link.pressed.foreground", 0xF00000, 0xBA6F25)); 24 | @NotNull 25 | Color VISITED = JBColor.namedColor("Link.visitedForeground", JBColor.namedColor("link.visited.foreground", 0x800080, 0x9776A9)); 26 | @NotNull 27 | Color SECONDARY = JBColor.namedColor("Link.secondaryForeground", 0x779DBD, 0x5676A0); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/constant/DataTypeConstant.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.constant; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2025/2/28 6 | */ 7 | public interface DataTypeConstant { 8 | 9 | String JSON = "JSON"; 10 | 11 | String JSON5 = "JSON5"; 12 | 13 | String YAML = "YAML"; 14 | 15 | String XML = "XML"; 16 | 17 | String TOML = "TOML"; 18 | 19 | String URL_PARAM = "URL Param"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/constant/DependencyConstant.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.constant; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2024/12/24 6 | */ 7 | public interface DependencyConstant { 8 | 9 | String LOMBOK_LIB = "org.projectlombok:lombok"; 10 | 11 | String FASTJSON_LIB = "com.alibaba:fastjson"; 12 | 13 | String FASTJSON2_LIB = "com.alibaba.fastjson2:fastjson2"; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/constant/FileTypeHolder.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.constant; 2 | 3 | import cn.memoryzy.json.enums.FileTypes; 4 | import cn.memoryzy.json.util.PlatformUtil; 5 | import com.intellij.openapi.fileTypes.FileType; 6 | 7 | /** 8 | * 以常量方式存储,防止经常反射影响效率 9 | * 10 | * @author Memory 11 | * @since 2024/9/21 12 | */ 13 | public interface FileTypeHolder { 14 | 15 | FileType JSON = PlatformUtil.getFileType(FileTypes.JSON); 16 | 17 | FileType JSON5 = PlatformUtil.getFileType(FileTypes.JSON5); 18 | 19 | FileType XML = PlatformUtil.getFileType(FileTypes.XML); 20 | 21 | FileType YAML = PlatformUtil.getFileType(FileTypes.YAML); 22 | 23 | FileType TOML = PlatformUtil.getFileType(FileTypes.TOML); 24 | 25 | FileType PROPERTIES = PlatformUtil.getFileType(FileTypes.PROPERTIES); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/constant/HtmlConstant.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.constant; 2 | 3 | import com.intellij.openapi.util.text.HtmlChunk; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/10/25 8 | */ 9 | public interface HtmlConstant { 10 | 11 | static String wrapHtml(String text) { 12 | return HtmlChunk.raw(text) 13 | .wrapWith(HtmlChunk.html()) 14 | .toString(); 15 | } 16 | 17 | static String wrapBody(String text) { 18 | return HtmlChunk.raw(text) 19 | .wrapWith(HtmlChunk.body()) 20 | .wrapWith(HtmlChunk.html()) 21 | .toString(); 22 | } 23 | 24 | static String wrapBoldHtml(String text) { 25 | return HtmlChunk.raw(text) 26 | .bold() 27 | .wrapWith(HtmlChunk.body()) 28 | .wrapWith(HtmlChunk.html()) 29 | .toString(); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/constant/LanguageHolder.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.constant; 2 | 3 | import cn.memoryzy.json.enums.FileTypes; 4 | import cn.memoryzy.json.util.PlatformUtil; 5 | import com.intellij.lang.Language; 6 | 7 | /** 8 | * @author Memory 9 | * @since 2024/9/21 10 | */ 11 | public interface LanguageHolder { 12 | 13 | Language JSON = PlatformUtil.getLanguage(FileTypes.JSON); 14 | 15 | Language JSON5 = PlatformUtil.getLanguage(FileTypes.JSON5); 16 | 17 | Language XML = PlatformUtil.getLanguage(FileTypes.XML); 18 | 19 | Language YAML = PlatformUtil.getLanguage(FileTypes.YAML); 20 | 21 | Language TOML = PlatformUtil.getLanguage(FileTypes.TOML); 22 | 23 | Language PROPERTIES = PlatformUtil.getLanguage(FileTypes.PROPERTIES); 24 | 25 | Language JAVA = PlatformUtil.getLanguage(FileTypes.JAVA); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/HistoryTreeNodeType.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2024/11/22 6 | */ 7 | public enum HistoryTreeNodeType { 8 | 9 | /** 10 | * 组节点 11 | */ 12 | GROUP, 13 | 14 | /** 15 | * 数据节点 16 | */ 17 | NODE; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/HistoryViewType.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/29 8 | */ 9 | public enum HistoryViewType { 10 | 11 | /** 12 | * 树形视图 13 | */ 14 | TREE("setting.component.history.tree.text"), 15 | 16 | /** 17 | * 列表视图 18 | */ 19 | LIST("setting.component.history.list.text"); 20 | 21 | private final String key; 22 | 23 | HistoryViewType(String key) { 24 | this.key = key; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return JsonAssistantBundle.messageOnSystem(key); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/JsonAnnotations.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * Json注解 5 | * 6 | * @author Memory 7 | * @since 2023/11/27 8 | */ 9 | public enum JsonAnnotations { 10 | 11 | FAST_JSON_JSON_FIELD("com.alibaba.fastjson.annotation.JSONField", "JSONField"), 12 | FAST_JSON2_JSON_FIELD("com.alibaba.fastjson2.annotation.JSONField", "JSONField"), 13 | JACKSON_JSON_PROPERTY("com.fasterxml.jackson.annotation.JsonProperty", "JsonProperty"), 14 | JACKSON_JSON_IGNORE("com.fasterxml.jackson.annotation.JsonIgnore", "JsonIgnore"), 15 | JACKSON_JSON_FORMAT("com.fasterxml.jackson.annotation.JsonFormat", "JsonFormat"); 16 | 17 | private final String value; 18 | private final String simpleName; 19 | 20 | JsonAnnotations(String value, String simpleName) { 21 | this.value = value; 22 | this.simpleName = simpleName; 23 | } 24 | 25 | public String getValue() { 26 | return value; 27 | } 28 | 29 | public String getSimpleName() { 30 | return simpleName; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/JsonQuerySchema.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2024/12/19 6 | */ 7 | public enum JsonQuerySchema { 8 | 9 | JSONPath, 10 | 11 | JMESPath 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/JsonTreeNodeType.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2024/2/28 6 | */ 7 | public enum JsonTreeNodeType { 8 | 9 | /** 10 | * 对象类型 11 | */ 12 | JSONObject, 13 | 14 | /** 15 | * 数组类型 16 | */ 17 | JSONArray, 18 | 19 | /** 20 | * 数组下的对象类型 21 | */ 22 | JSONObjectElement, 23 | 24 | /** 25 | * 数组下的数组类型 26 | */ 27 | JSONArrayElementArray, 28 | 29 | /** 30 | * 数组下的基本类型 31 | */ 32 | JSONArrayElement, 33 | 34 | /** 35 | * 普通对象下的普通类型 36 | */ 37 | JSONObjectProperty 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/JsonValueHandleType.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2025/2/26 8 | */ 9 | public enum JsonValueHandleType { 10 | 11 | NESTED_JSON("hint.selection.ExpandAllNestedJson", "hint.global.ExpandAllNestedJson"), 12 | 13 | TIMESTAMP("hint.selection.convertAllTimestamp", "hint.global.convertAllTimestamp"), 14 | 15 | READABLE_TIME("hint.selection.convertAllReadableTime", "hint.global.convertAllReadableTime"), 16 | 17 | 18 | ; 19 | 20 | private final String selectionConvertSuccessMessageKey; 21 | private final String globalConvertSuccessMessageKey; 22 | 23 | JsonValueHandleType(String selectionConvertSuccessMessageKey, String globalConvertSuccessMessageKey) { 24 | this.selectionConvertSuccessMessageKey = selectionConvertSuccessMessageKey; 25 | this.globalConvertSuccessMessageKey = globalConvertSuccessMessageKey; 26 | } 27 | 28 | public String getSelectionConvertSuccessMessage() { 29 | return JsonAssistantBundle.messageOnSystem(selectionConvertSuccessMessageKey); 30 | } 31 | 32 | public String getGlobalConvertSuccessMessage() { 33 | return JsonAssistantBundle.messageOnSystem(globalConvertSuccessMessageKey); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/LombokAnnotations.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2023/12/4 6 | */ 7 | public enum LombokAnnotations { 8 | 9 | DATA("lombok.Data", "Data"), 10 | 11 | ACCESSORS("lombok.experimental.Accessors", "Accessors"), 12 | 13 | GETTER("lombok.Getter", "Getter"), 14 | 15 | SETTER("lombok.Setter", "Setter"), 16 | ; 17 | 18 | private final String value; 19 | private final String simpleName; 20 | 21 | LombokAnnotations(String value, String simpleName) { 22 | this.value = value; 23 | this.simpleName = simpleName; 24 | } 25 | 26 | public String getValue() { 27 | return value; 28 | } 29 | 30 | public String getSimpleName() { 31 | return simpleName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/StructureActionSource.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2024/12/13 6 | */ 7 | public enum StructureActionSource { 8 | 9 | /** 10 | * 外面其他地方执行的结构化 11 | */ 12 | OUTSIDE, 13 | 14 | /** 15 | * 工具窗口工具栏执行的结构化 16 | */ 17 | TOOLWINDOW_TOOLBAR, 18 | 19 | /** 20 | * 工具窗口编辑器执行的结构化 21 | */ 22 | TOOLWINDOW_EDITOR 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/SwaggerAnnotations.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2025/3/28 6 | */ 7 | public enum SwaggerAnnotations { 8 | 9 | API_MODEL_PROPERTY("io.swagger.annotations.ApiModelProperty", "ApiModelProperty"), 10 | 11 | /** 12 | * Swagger v3 13 | */ 14 | SCHEMA("io.swagger.v3.oas.annotations.media.Schema", "Schema"); 15 | 16 | 17 | private final String value; 18 | private final String simpleName; 19 | 20 | SwaggerAnnotations(String value, String simpleName) { 21 | this.value = value; 22 | this.simpleName = simpleName; 23 | } 24 | 25 | public String getValue() { 26 | return value; 27 | } 28 | 29 | public String getSimpleName() { 30 | return simpleName; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/TextResolveStatus.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | /** 4 | * 解析编辑器文本的成功与否状态 5 | * 6 | * @author Memory 7 | * @since 2024/11/3 8 | */ 9 | public enum TextResolveStatus { 10 | 11 | /** 12 | * 选中了特定文本,并且解析成功 13 | */ 14 | SELECTED_SUCCESS, 15 | 16 | /** 17 | * 没有选中文本,解析默认的全部文本成功 18 | */ 19 | GLOBAL_SUCCESS, 20 | 21 | /** 22 | * 解析失败 23 | */ 24 | RESOLVE_FAILED 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/enums/TreeDisplayMode.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.enums; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/12/11 8 | */ 9 | public enum TreeDisplayMode { 10 | 11 | /** 12 | * 弹出窗口 13 | */ 14 | POPUP("setting.component.tree.display.popup.mode.text"), 15 | 16 | /** 17 | * 原本的工具窗口窗口(Json Assistant) 18 | */ 19 | ORIGINAL_TOOLWINDOW("setting.component.tree.display.original.toolwindow.mode.text"), 20 | 21 | /** 22 | * 辅助侧边栏窗口(动态注册的窗口) 23 | */ 24 | AUXILIARY_TOOLWINDOW("setting.component.tree.display.new.toolwindow.mode.text"); 25 | 26 | 27 | private final String key; 28 | 29 | TreeDisplayMode(String key) { 30 | this.key = key; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return JsonAssistantBundle.messageOnSystem(key); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/extension/provider/HelpProvider.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.extension.provider; 2 | 3 | import cn.memoryzy.json.enums.UrlType; 4 | import com.intellij.openapi.help.WebHelpProvider; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2024/10/25 11 | */ 12 | public class HelpProvider extends WebHelpProvider { 13 | @Override 14 | public @Nullable String getHelpPageUrl(@NotNull String helpTopicId) { 15 | return UrlType.of(helpTopicId).getUrl(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/extension/provider/JsonTreeFileEditorProvider.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.extension.provider; 2 | 3 | import cn.memoryzy.json.constant.JsonAssistantPlugin; 4 | import cn.memoryzy.json.extension.editor.JsonTreeFileEditor; 5 | import cn.memoryzy.json.util.PlatformUtil; 6 | import com.intellij.openapi.fileEditor.FileEditor; 7 | import com.intellij.openapi.fileEditor.FileEditorPolicy; 8 | import com.intellij.openapi.fileEditor.FileEditorProvider; 9 | import com.intellij.openapi.project.Project; 10 | import com.intellij.openapi.vfs.VirtualFile; 11 | import org.jetbrains.annotations.NonNls; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | /** 15 | * @author Memory 16 | * @since 2024/12/16 17 | */ 18 | public class JsonTreeFileEditorProvider implements FileEditorProvider { 19 | 20 | // 切换标签页 21 | // FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); 22 | // fileEditorManager.setSelectedEditor(openFile, JsonAssistantPlugin.PLUGIN_ID_NAME + ".JsonTreeFileEditor"); 23 | 24 | @Override 25 | public boolean accept(@NotNull Project project, @NotNull VirtualFile file) { 26 | return PlatformUtil.isJsonFileType(file.getFileType()); 27 | } 28 | 29 | @Override 30 | public @NotNull FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) { 31 | return new JsonTreeFileEditor(project, file); 32 | } 33 | 34 | @Override 35 | public @NotNull @NonNls String getEditorTypeId() { 36 | return JsonAssistantPlugin.PLUGIN_ID_NAME + ".JsonTreeFileEditor"; 37 | } 38 | 39 | @Override 40 | public @NotNull FileEditorPolicy getPolicy() { 41 | return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/extension/template/JsonAssistantFileTemplateDescriptorFactory.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.extension.template; 2 | 3 | import cn.memoryzy.json.constant.JsonAssistantPlugin; 4 | import cn.memoryzy.json.constant.PluginConstant; 5 | import com.intellij.icons.AllIcons; 6 | import com.intellij.ide.fileTemplates.FileTemplateDescriptor; 7 | import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptor; 8 | import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptorFactory; 9 | 10 | /** 11 | * @author Memory 12 | * @since 2025/4/2 13 | */ 14 | public class JsonAssistantFileTemplateDescriptorFactory implements FileTemplateGroupDescriptorFactory { 15 | 16 | @Override 17 | public FileTemplateGroupDescriptor getFileTemplatesDescriptor() { 18 | FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor(JsonAssistantPlugin.PLUGIN_NAME, AllIcons.FileTypes.Custom); 19 | group.addTemplate(new FileTemplateDescriptor(PluginConstant.NEW_CLASS_TEMPLATE_NAME, AllIcons.FileTypes.Java)); 20 | return group; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/EditorInitData.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model; 2 | 3 | /** 4 | * 工具窗口编辑器初次打开时的默认信息 5 | * 6 | * @author Memory 7 | * @since 2024/11/26 8 | */ 9 | public class EditorInitData { 10 | 11 | /** 12 | * 是否存在有效文本 13 | */ 14 | private final boolean hasText; 15 | 16 | /** 17 | * 有效Json文本 18 | */ 19 | private final String jsonString; 20 | 21 | /** 22 | * 解析类型 23 | */ 24 | private final String parseType; 25 | 26 | /** 27 | * 原文 28 | */ 29 | private final String originalText; 30 | 31 | // region 构造器与Getter 32 | public EditorInitData(boolean hasText, String jsonString, String parseType, String originalText) { 33 | this.hasText = hasText; 34 | this.jsonString = jsonString; 35 | this.parseType = parseType; 36 | this.originalText = originalText; 37 | } 38 | 39 | public boolean isHasText() { 40 | return hasText; 41 | } 42 | 43 | public String getJsonString() { 44 | return jsonString; 45 | } 46 | 47 | public String getParseType() { 48 | return parseType; 49 | } 50 | 51 | public String getOriginalText() { 52 | return originalText; 53 | } 54 | 55 | // endregion 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/Version.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2025/2/24 6 | */ 7 | public class Version { 8 | 9 | int major; 10 | int minor; 11 | int patch; 12 | String suffix; 13 | 14 | public Version(int major, int minor, int patch, String suffix) { 15 | this.major = major; 16 | this.minor = minor; 17 | this.patch = patch; 18 | this.suffix = suffix; 19 | } 20 | 21 | public int getMajor() { 22 | return major; 23 | } 24 | 25 | public void setMajor(int major) { 26 | this.major = major; 27 | } 28 | 29 | public int getMinor() { 30 | return minor; 31 | } 32 | 33 | public void setMinor(int minor) { 34 | this.minor = minor; 35 | } 36 | 37 | public int getPatch() { 38 | return patch; 39 | } 40 | 41 | public void setPatch(int patch) { 42 | this.patch = patch; 43 | } 44 | 45 | public String getSuffix() { 46 | return suffix; 47 | } 48 | 49 | public void setSuffix(String suffix) { 50 | this.suffix = suffix; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/YamlDocEntry.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model; 2 | 3 | import cn.memoryzy.json.util.JsonAssistantUtil; 4 | import cn.memoryzy.json.util.YamlUtil; 5 | import com.intellij.openapi.editor.actions.ContentChooser; 6 | import com.intellij.openapi.util.text.StringUtil; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2024/9/25 14 | */ 15 | public class YamlDocEntry { 16 | 17 | private final String shortText; 18 | private final String longText; 19 | private final Object value; 20 | 21 | public YamlDocEntry(String shortText, String longText, Object value) { 22 | this.shortText = shortText; 23 | this.longText = longText; 24 | this.value = value; 25 | } 26 | 27 | public static List of(List values) { 28 | List models = new ArrayList<>(); 29 | for (Object value : values) { 30 | String yaml = YamlUtil.toYaml(value); 31 | String truncatedText = JsonAssistantUtil.truncateText(yaml, 70, "..."); 32 | truncatedText = StringUtil.convertLineSeparators(truncatedText, ContentChooser.RETURN_SYMBOL); 33 | models.add(new YamlDocEntry(truncatedText, yaml, value)); 34 | } 35 | 36 | return models; 37 | } 38 | 39 | public String getShortText() { 40 | return shortText; 41 | } 42 | 43 | 44 | public String getLongText() { 45 | return longText; 46 | } 47 | 48 | 49 | public Object getValue() { 50 | return value; 51 | } 52 | 53 | 54 | @Override 55 | public String toString() { 56 | return shortText; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jackson/ColorDeserializer.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jackson; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import com.fasterxml.jackson.core.JsonParser; 5 | import com.fasterxml.jackson.databind.DeserializationContext; 6 | import com.fasterxml.jackson.databind.JsonDeserializer; 7 | import com.intellij.ui.ColorUtil; 8 | 9 | import java.awt.*; 10 | import java.io.IOException; 11 | 12 | /** 13 | * @author Memory 14 | * @since 2024/11/19 15 | */ 16 | public class ColorDeserializer extends JsonDeserializer { 17 | @Override 18 | public Color deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { 19 | String text = StrUtil.trim(jsonParser.getText()); 20 | return StrUtil.isBlank(text) ? null : ColorUtil.fromHex(text); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jackson/ColorSerializer.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jackson; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.intellij.ui.ColorUtil; 7 | 8 | import java.awt.*; 9 | import java.io.IOException; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2024/11/19 14 | */ 15 | public class ColorSerializer extends JsonSerializer { 16 | @Override 17 | public void serialize(Color color, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { 18 | if (color == null) { 19 | jsonGenerator.writeNull(); 20 | } else { 21 | jsonGenerator.writeString(ColorUtil.toHex(color)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jsonpath/EvaluateResult.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jsonpath; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2024/12/18 6 | */ 7 | public abstract class EvaluateResult { 8 | 9 | private final String message; 10 | 11 | protected EvaluateResult(String message) { 12 | this.message = message; 13 | } 14 | 15 | public String getMessage() { 16 | return message; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jsonpath/IncorrectDocument.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jsonpath; 2 | 3 | /** 4 | * 非法文档 5 | * 6 | * @author Memory 7 | * @since 2024/12/18 8 | */ 9 | public class IncorrectDocument extends EvaluateResult { 10 | 11 | public IncorrectDocument(String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jsonpath/IncorrectExpression.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jsonpath; 2 | 3 | /** 4 | * 非法表达式 5 | * 6 | * @author Memory 7 | * @since 2024/12/18 8 | */ 9 | public class IncorrectExpression extends EvaluateResult { 10 | 11 | public IncorrectExpression(String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jsonpath/ResultNotFound.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jsonpath; 2 | 3 | /** 4 | * 无结果 5 | * 6 | * @author Memory 7 | * @since 2024/12/18 8 | */ 9 | public class ResultNotFound extends EvaluateResult { 10 | 11 | public ResultNotFound(String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/jsonpath/ResultString.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.jsonpath; 2 | 3 | /** 4 | * 正确的文档解析结果 5 | * 6 | * @author Memory 7 | * @since 2024/12/18 8 | */ 9 | public class ResultString extends EvaluateResult { 10 | 11 | public ResultString(String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/serializer/LocalDateTimeTypeHandler.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.serializer; 2 | 3 | import cn.hutool.core.date.DatePattern; 4 | import cn.hutool.core.date.LocalDateTimeUtil; 5 | import thirdparty.a2u.tn.utils.json.TnJsonBuilder; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | /** 10 | * Json5 序列化时对 LocalDateTime 类型做处理 11 | * 12 | * @author Memory 13 | * @since 2024/11/25 14 | */ 15 | public class LocalDateTimeTypeHandler implements TnJsonBuilder.ITypeHandler { 16 | @Override 17 | public Object handleType(Object value) { 18 | return value instanceof LocalDateTime 19 | ? LocalDateTimeUtil.format((LocalDateTime) value, DatePattern.NORM_DATETIME_PATTERN) 20 | : value; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/ClipboardTextConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionContext; 5 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/4 12 | */ 13 | public class ClipboardTextConverter { 14 | 15 | public static String applyConversionStrategies(ClipboardTextConversionContext context, String text) { 16 | // 依次尝试不同的转换策略 17 | return applyConversionStrategies(context, ClipboardTextConversionContext.getProcessors(), text); 18 | } 19 | 20 | private static String applyConversionStrategies(ClipboardTextConversionContext context, List strategies, String text) { 21 | for (ClipboardTextConversionStrategy strategy : strategies) { 22 | context.setStrategy(strategy); 23 | String result = context.convert(text); 24 | if (StrUtil.isNotBlank(result)) { 25 | return result; 26 | } 27 | } 28 | 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/Json5ConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard; 2 | 3 | import cn.memoryzy.json.constant.DataTypeConstant; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 5 | import cn.memoryzy.json.util.Json5Util; 6 | 7 | /** 8 | * @author Memory 9 | * @since 2024/11/12 10 | */ 11 | public class Json5ConversionStrategy implements ClipboardTextConversionStrategy { 12 | 13 | @Override 14 | public String type() { 15 | return DataTypeConstant.JSON5; 16 | } 17 | 18 | @Override 19 | public boolean canConvert(String text) { 20 | return Json5Util.isJson5(text); 21 | } 22 | 23 | @Override 24 | public String convertToJson(String text) { 25 | return Json5Util.formatJson5(text); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/JsonConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard; 2 | 3 | import cn.memoryzy.json.constant.DataTypeConstant; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 5 | import cn.memoryzy.json.util.JsonUtil; 6 | 7 | /** 8 | * JSON 转 JSON 处理 9 | * 10 | * @author Memory 11 | * @since 2024/10/31 12 | */ 13 | public class JsonConversionStrategy implements ClipboardTextConversionStrategy { 14 | 15 | @Override 16 | public String type() { 17 | return DataTypeConstant.JSON; 18 | } 19 | 20 | @Override 21 | public boolean canConvert(String text) { 22 | return JsonUtil.canResolveToJson(text); 23 | } 24 | 25 | @Override 26 | public String convertToJson(String text) { 27 | return JsonUtil.ensureJson(text); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/TomlConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard; 2 | 3 | import cn.memoryzy.json.constant.DataTypeConstant; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 5 | import cn.memoryzy.json.util.TomlUtil; 6 | 7 | /** 8 | * @author Memory 9 | * @since 2024/10/31 10 | */ 11 | public class TomlConversionStrategy implements ClipboardTextConversionStrategy { 12 | 13 | @Override 14 | public String type() { 15 | return DataTypeConstant.TOML; 16 | } 17 | 18 | @Override 19 | public boolean canConvert(String text) { 20 | return TomlUtil.isToml(text); 21 | } 22 | 23 | @Override 24 | public String convertToJson(String text) { 25 | return TomlUtil.toJson(text); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/UrlParamConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard; 2 | 3 | import cn.memoryzy.json.constant.DataTypeConstant; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 5 | import cn.memoryzy.json.util.DataConverter; 6 | 7 | /** 8 | * @author Memory 9 | * @since 2024/10/31 10 | */ 11 | public class UrlParamConversionStrategy implements ClipboardTextConversionStrategy { 12 | 13 | @Override 14 | public String type() { 15 | return DataTypeConstant.URL_PARAM; 16 | } 17 | @Override 18 | public boolean canConvert(String text) { 19 | return null != DataConverter.urlParamsToJson(text); 20 | } 21 | 22 | @Override 23 | public String convertToJson(String text) { 24 | return DataConverter.urlParamsToJson(text); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/XmlConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard; 2 | 3 | import cn.memoryzy.json.constant.DataTypeConstant; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 5 | import cn.memoryzy.json.util.XmlUtil; 6 | 7 | /** 8 | * @author Memory 9 | * @since 2024/10/31 10 | */ 11 | public class XmlConversionStrategy implements ClipboardTextConversionStrategy { 12 | 13 | @Override 14 | public String type() { 15 | return DataTypeConstant.XML; 16 | } 17 | 18 | @Override 19 | public boolean canConvert(String text) { 20 | return XmlUtil.isXML(text); 21 | } 22 | 23 | @Override 24 | public String convertToJson(String text) { 25 | return XmlUtil.toJson(text); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/YamlConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard; 2 | 3 | import cn.memoryzy.json.constant.DataTypeConstant; 4 | import cn.memoryzy.json.model.strategy.clipboard.context.ClipboardTextConversionStrategy; 5 | import cn.memoryzy.json.util.YamlUtil; 6 | 7 | /** 8 | * @author Memory 9 | * @since 2024/10/31 10 | */ 11 | public class YamlConversionStrategy implements ClipboardTextConversionStrategy { 12 | 13 | @Override 14 | public String type() { 15 | return DataTypeConstant.YAML; 16 | } 17 | @Override 18 | public boolean canConvert(String text) { 19 | // 不处理多文档 20 | return YamlUtil.isSingleYamlDocument(text); 21 | } 22 | 23 | @Override 24 | public String convertToJson(String text) { 25 | return YamlUtil.toJson(text); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/clipboard/context/ClipboardTextConversionStrategy.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.clipboard.context; 2 | 3 | /** 4 | * 剪贴板的文本转为 JSON 的处理 5 | * 6 | * @author Memory 7 | * @since 2024/10/31 8 | */ 9 | public interface ClipboardTextConversionStrategy { 10 | 11 | String type(); 12 | 13 | boolean canConvert(String text) throws Exception; 14 | 15 | String convertToJson(String text) throws Exception; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/context/GlobalTextConversionProcessor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.context; 2 | 3 | /** 4 | * 全局的文本转为 JSON 的处理 5 | * 6 | * @author Memory 7 | * @since 2024/11/2 8 | */ 9 | public interface GlobalTextConversionProcessor { 10 | 11 | /** 12 | * 提供的文本是否符合转换为 JSON 格式的要求 13 | * 14 | * @param text 文本 15 | * @return 符合为 true;反之为 false 16 | * @throws Exception 异常 17 | */ 18 | boolean canConvert(String text) throws Exception; 19 | 20 | /** 21 | * 转换为 JSON 格式 22 | * 23 | * @return JSON 文本 24 | * @throws Exception 异常 25 | */ 26 | String convertToJson() throws Exception; 27 | 28 | /** 29 | * 执行转换方法前所执行的操作 30 | * 31 | * @throws Exception 异常 32 | */ 33 | void preprocessing() throws Exception; 34 | 35 | /** 36 | * 执行转换方法后所执行的操作 37 | * 38 | * @throws Exception 异常 39 | */ 40 | String postprocessing(String text) throws Exception; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/data/ActionData.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.data; 2 | 3 | import javax.swing.*; 4 | 5 | /** 6 | * 操作(Action)相关信息 7 | * 8 | * @author Memory 9 | * @since 2024/11/2 10 | */ 11 | public class ActionData { 12 | 13 | /** 14 | * 当文本匹配成功,用于替换的操作名称 15 | */ 16 | private String actionName; 17 | 18 | /** 19 | * 当文本匹配成功,用于替换的操作详情 20 | */ 21 | private String actionDescription; 22 | 23 | /** 24 | * 当文本匹配成功,用于替换的操作图标 25 | */ 26 | private Icon actionIcon; 27 | 28 | 29 | 30 | 31 | // ----------------------- GETTER/SETTER ----------------------- 32 | 33 | public String getActionName() { 34 | return actionName; 35 | } 36 | 37 | public ActionData setActionName(String actionName) { 38 | this.actionName = actionName; 39 | return this; 40 | } 41 | 42 | public String getActionDescription() { 43 | return actionDescription; 44 | } 45 | 46 | public ActionData setActionDescription(String actionDescription) { 47 | this.actionDescription = actionDescription; 48 | return this; 49 | } 50 | 51 | public Icon getActionIcon() { 52 | return actionIcon; 53 | } 54 | 55 | public ActionData setActionIcon(Icon actionIcon) { 56 | this.actionIcon = actionIcon; 57 | return this; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/data/DocTextData.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.data; 2 | 3 | /** 4 | * 文档内文本信息 5 | * 6 | * @author Memory 7 | * @since 2024/11/2 8 | */ 9 | public class DocTextData { 10 | 11 | /** 12 | * 文档内的全部文本 13 | */ 14 | private String documentText; 15 | 16 | /** 17 | * 当前选中的文本 18 | */ 19 | private String selectedText; 20 | 21 | 22 | 23 | // ----------------------- GETTER/SETTER ----------------------- 24 | 25 | public String getDocumentText() { 26 | return documentText; 27 | } 28 | 29 | public DocTextData setDocumentText(String documentText) { 30 | this.documentText = documentText; 31 | return this; 32 | } 33 | 34 | public String getSelectedText() { 35 | return selectedText; 36 | } 37 | 38 | public DocTextData setSelectedText(String selectedText) { 39 | this.selectedText = selectedText; 40 | return this; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/data/FileTypeData.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.data; 2 | 3 | import com.intellij.openapi.fileTypes.FileType; 4 | 5 | /** 6 | * 文件类型所代表的类型信息 7 | * 8 | * @author Memory 9 | * @since 2024/11/3 10 | */ 11 | public class FileTypeData { 12 | 13 | /** 14 | * 转换完成后的文本代表的文件类型 15 | */ 16 | private FileType processedFileType; 17 | 18 | /** 19 | * 支持写入的文件类型,类全限定名(通常只是 JSON 类型赋此值,其他类型可置为 null) 20 | * 21 | *

解析出文本后,要写入到文档中,若文档类型符合在此指定的类型,则直接写入,反之做其他处理

22 | */ 23 | private String[] allowedFileTypeQualifiedNames; 24 | 25 | 26 | // ----------------------- GETTER/SETTER ----------------------- 27 | 28 | public FileType getProcessedFileType() { 29 | return processedFileType; 30 | } 31 | 32 | public FileTypeData setProcessedFileType(FileType processedFileType) { 33 | this.processedFileType = processedFileType; 34 | return this; 35 | } 36 | 37 | public String[] getAllowedFileTypeQualifiedNames() { 38 | return allowedFileTypeQualifiedNames; 39 | } 40 | 41 | public FileTypeData setAllowedFileTypeQualifiedNames(String[] allowedFileTypeQualifiedNames) { 42 | this.allowedFileTypeQualifiedNames = allowedFileTypeQualifiedNames; 43 | return this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/data/MessageData.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.data; 2 | 3 | /** 4 | * 文本转换后的提示信息 5 | * 6 | * @author Memory 7 | * @since 2024/11/2 8 | */ 9 | public class MessageData { 10 | 11 | /** 12 | * 选中内容转换成功后的提示信息 13 | */ 14 | private String selectionConvertSuccessMessage; 15 | 16 | /** 17 | * 全局内容转换成功后的提示信息 18 | */ 19 | private String globalConvertSuccessMessage; 20 | 21 | 22 | 23 | 24 | // ----------------------- GETTER/SETTER ----------------------- 25 | 26 | public String getSelectionConvertSuccessMessage() { 27 | return selectionConvertSuccessMessage; 28 | } 29 | 30 | public MessageData setSelectionConvertSuccessMessage(String selectionConvertSuccessMessage) { 31 | this.selectionConvertSuccessMessage = selectionConvertSuccessMessage; 32 | return this; 33 | } 34 | 35 | public String getGlobalConvertSuccessMessage() { 36 | return globalConvertSuccessMessage; 37 | } 38 | 39 | public MessageData setGlobalConvertSuccessMessage(String globalConvertSuccessMessage) { 40 | this.globalConvertSuccessMessage = globalConvertSuccessMessage; 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/data/SelectionData.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.data; 2 | 3 | /** 4 | * 文本选择相关信息 5 | * 6 | * @author Memory 7 | * @since 2024/11/2 8 | */ 9 | public class SelectionData { 10 | 11 | /** 12 | * 检查当前是否选择了文本范围 13 | */ 14 | private boolean hasSelection; 15 | 16 | /** 17 | * 所选文本范围在文档中的起始偏移量 18 | */ 19 | private int startOffset; 20 | 21 | /** 22 | * 所选文本范围在文档中的结束偏移量 23 | */ 24 | private int endOffset; 25 | 26 | 27 | 28 | // ----------------------- GETTER/SETTER ----------------------- 29 | 30 | public boolean isHasSelection() { 31 | return hasSelection; 32 | } 33 | 34 | public SelectionData setHasSelection(boolean hasSelection) { 35 | this.hasSelection = hasSelection; 36 | return this; 37 | } 38 | 39 | public int getStartOffset() { 40 | return startOffset; 41 | } 42 | 43 | public SelectionData setStartOffset(int startOffset) { 44 | this.startOffset = startOffset; 45 | return this; 46 | } 47 | 48 | public int getEndOffset() { 49 | return endOffset; 50 | } 51 | 52 | public SelectionData setEndOffset(int endOffset) { 53 | this.endOffset = endOffset; 54 | return this; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/processor/json/Json5BeautifyConversionProcessor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.processor.json; 2 | 3 | import cn.memoryzy.json.model.strategy.formats.data.EditorData; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/8 8 | */ 9 | public class Json5BeautifyConversionProcessor extends Json5ConversionProcessor { 10 | private Json5BeautifyConversionProcessor(EditorData editorData) { 11 | super(editorData, true); 12 | } 13 | 14 | public static Json5BeautifyConversionProcessor newProcessor(EditorData editorData) { 15 | return new Json5BeautifyConversionProcessor(editorData); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/processor/json/Json5ConversionProcessor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.processor.json; 2 | 3 | import cn.memoryzy.json.model.strategy.formats.data.EditorData; 4 | import cn.memoryzy.json.util.Json5Util; 5 | 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2024/11/4 11 | */ 12 | public class Json5ConversionProcessor extends JsonConversionProcessor { 13 | 14 | public Json5ConversionProcessor(EditorData editorData, Boolean needBeautify) { 15 | super(editorData, needBeautify); 16 | } 17 | 18 | @Override 19 | public boolean canConvert(String text) { 20 | return Json5Util.isJson5(text); 21 | } 22 | 23 | @Override 24 | public String convertToJson() { 25 | return getContent(); 26 | } 27 | 28 | @Override 29 | public String postprocessing(String text) { 30 | Boolean needBeautify = isNeedBeautify(); 31 | if (Objects.nonNull(needBeautify)) { 32 | boolean parseComment = editorData.isParseComment(); 33 | if (needBeautify) { 34 | text = parseComment ? Json5Util.formatJson5WithComment(text) : Json5Util.formatJson5(text); 35 | } else { 36 | // 压缩后就不存在注释了 37 | text = Json5Util.compressJson5(text); 38 | } 39 | } 40 | 41 | return text; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/processor/json/Json5MinifyConversionProcessor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.processor.json; 2 | 3 | import cn.memoryzy.json.model.strategy.formats.data.EditorData; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/8 8 | */ 9 | public class Json5MinifyConversionProcessor extends Json5ConversionProcessor { 10 | private Json5MinifyConversionProcessor(EditorData editorData) { 11 | super(editorData, false); 12 | } 13 | 14 | public static Json5MinifyConversionProcessor newProcessor(EditorData editorData) { 15 | return new Json5MinifyConversionProcessor(editorData); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/processor/json/JsonBeautifyConversionProcessor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.processor.json; 2 | 3 | import cn.memoryzy.json.model.strategy.formats.data.EditorData; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/8 8 | */ 9 | public class JsonBeautifyConversionProcessor extends JsonConversionProcessor { 10 | private JsonBeautifyConversionProcessor(EditorData editorData) { 11 | super(editorData, true); 12 | } 13 | 14 | public static JsonBeautifyConversionProcessor newProcessor(EditorData editorData) { 15 | return new JsonBeautifyConversionProcessor(editorData); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/strategy/formats/processor/json/JsonMinifyConversionProcessor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.strategy.formats.processor.json; 2 | 3 | import cn.memoryzy.json.model.strategy.formats.data.EditorData; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/8 8 | */ 9 | public class JsonMinifyConversionProcessor extends JsonConversionProcessor { 10 | private JsonMinifyConversionProcessor(EditorData editorData) { 11 | super(editorData, false); 12 | } 13 | 14 | public static JsonMinifyConversionProcessor newProcessor(EditorData editorData) { 15 | return new JsonMinifyConversionProcessor(editorData); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/template/FieldModel.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.template; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Memory 8 | * @since 2025/4/2 9 | */ 10 | public class FieldModel implements TemplateModel { 11 | 12 | @MapKey("NAME") 13 | private String name; 14 | 15 | @MapKey("TYPE") 16 | private String type; 17 | 18 | @MapKey("COMMENT") 19 | private String comment; 20 | 21 | @MapKey("ANNOTATIONS") 22 | private List annotations = new ArrayList<>(); 23 | 24 | // -------------------------- 25 | 26 | public FieldModel addAnnotation(AnnotationModel annotation) { 27 | this.annotations.add(annotation); 28 | return this; 29 | } 30 | 31 | // -------------------------- 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public FieldModel setName(String name) { 38 | this.name = name; 39 | return this; 40 | } 41 | 42 | public String getType() { 43 | return type; 44 | } 45 | 46 | public FieldModel setType(String type) { 47 | this.type = type; 48 | return this; 49 | } 50 | 51 | public String getComment() { 52 | return comment; 53 | } 54 | 55 | public FieldModel setComment(String comment) { 56 | this.comment = comment; 57 | return this; 58 | } 59 | 60 | public List getAnnotations() { 61 | return annotations; 62 | } 63 | 64 | public FieldModel setAnnotations(List annotations) { 65 | this.annotations = annotations; 66 | return this; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/template/MapKey.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.template; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2025/4/2 11 | */ 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target({ElementType.FIELD}) 14 | public @interface MapKey { 15 | 16 | String value() default ""; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/template/TemplateModel.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.template; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2025/4/2 6 | */ 7 | public interface TemplateModel { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/model/wrapper/JsonWrapper.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.model.wrapper; 2 | 3 | import cn.memoryzy.json.util.JsonUtil; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/11 8 | */ 9 | public interface JsonWrapper { 10 | 11 | boolean isObject(); 12 | 13 | boolean isArray(); 14 | 15 | boolean noItems(); 16 | 17 | JsonWrapper cloneAndRemoveCommentKey(); 18 | 19 | default String toJsonString() { 20 | return JsonUtil.formatJson(this); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/ClipboardDataBlacklistPersistentState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent; 2 | 3 | import cn.memoryzy.json.model.BlacklistEntry; 4 | import cn.memoryzy.json.service.persistent.converter.BlacklistConverter; 5 | import com.intellij.openapi.application.ApplicationManager; 6 | import com.intellij.openapi.components.PersistentStateComponent; 7 | import com.intellij.openapi.components.State; 8 | import com.intellij.openapi.components.Storage; 9 | import com.intellij.util.xmlb.annotations.Attribute; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.LinkedList; 14 | 15 | /** 16 | * @author Memory 17 | * @since 2025/3/3 18 | */ 19 | @State(name = "Json Assistant Clipboard Data Blacklist", storages = {@Storage(value = "ClipboardDataBlacklistPersistentState.xml")}) 20 | public class ClipboardDataBlacklistPersistentState implements PersistentStateComponent { 21 | 22 | public static ClipboardDataBlacklistPersistentState getInstance() { 23 | return ApplicationManager.getApplication().getService(ClipboardDataBlacklistPersistentState.class); 24 | } 25 | 26 | @Attribute(converter = BlacklistConverter.class) 27 | public LinkedList blacklist = new LinkedList<>(); 28 | 29 | @Override 30 | public @Nullable ClipboardDataBlacklistPersistentState getState() { 31 | return this; 32 | } 33 | 34 | @Override 35 | public void loadState(@NotNull ClipboardDataBlacklistPersistentState state) { 36 | this.blacklist = state.blacklist; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/AttributeSerializationStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.AttributeSerializationState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/18 12 | */ 13 | public class AttributeSerializationStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable AttributeSerializationState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, AttributeSerializationState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull AttributeSerializationState value) { 22 | return JsonUtil.compressJson(value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/BlacklistConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.hutool.core.codec.Base64; 4 | import cn.hutool.core.util.StrUtil; 5 | import cn.memoryzy.json.model.BlacklistEntry; 6 | import cn.memoryzy.json.model.wrapper.ArrayWrapper; 7 | import cn.memoryzy.json.model.wrapper.ObjectWrapper; 8 | import cn.memoryzy.json.util.Json5Util; 9 | import com.intellij.util.xmlb.Converter; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.nio.charset.StandardCharsets; 14 | import java.util.LinkedList; 15 | 16 | /** 17 | * @author Memory 18 | * @since 2025/3/3 19 | */ 20 | public class BlacklistConverter extends Converter> { 21 | 22 | @Override 23 | public @Nullable LinkedList fromString(@NotNull String value) { 24 | LinkedList jsonEntries = new LinkedList<>(); 25 | value = StrUtil.str(Base64.decode(value), StandardCharsets.UTF_8); 26 | ArrayWrapper jsonArray = Json5Util.parseArray(value); 27 | for (Object data : jsonArray) { 28 | ObjectWrapper element = (ObjectWrapper) data; 29 | BlacklistEntry entry = BlacklistEntry.fromMap(element); 30 | jsonEntries.add(entry); 31 | } 32 | 33 | return jsonEntries; 34 | } 35 | 36 | @Override 37 | public @Nullable String toString(@NotNull LinkedList value) { 38 | return Base64.encode(Json5Util.compressJson5(value)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/DeserializerStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.DeserializerState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/12/23 12 | */ 13 | public class DeserializerStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable DeserializerState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, DeserializerState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull DeserializerState value) { 22 | return JsonUtil.compressJson(value); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/EditorAppearanceStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.EditorAppearanceState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/18 12 | */ 13 | public class EditorAppearanceStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable EditorAppearanceState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, EditorAppearanceState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull EditorAppearanceState value) { 22 | // Jackson无法序列化Color类,需手动转换 23 | return JsonUtil.compressJson(value); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/EditorBehaviorStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.EditorBehaviorState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/18 12 | */ 13 | public class EditorBehaviorStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable EditorBehaviorState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, EditorBehaviorState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull EditorBehaviorState value) { 22 | return JsonUtil.compressJson(value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/GeneralStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.GeneralState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/12/11 12 | */ 13 | public class GeneralStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable GeneralState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, GeneralState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull GeneralState value) { 22 | return JsonUtil.compressJson(value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/HistoryStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.HistoryState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/29 12 | */ 13 | public class HistoryStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable HistoryState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, HistoryState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull HistoryState value) { 22 | return JsonUtil.compressJson(value); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/QueryStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.QueryState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/12/27 12 | */ 13 | public class QueryStateConverter extends Converter { 14 | @Override 15 | public @Nullable QueryState fromString(@NotNull String value) { 16 | return JsonUtil.toObject(value, QueryState.class); 17 | } 18 | 19 | @Override 20 | public @Nullable String toString(@NotNull QueryState value) { 21 | return JsonUtil.compressJson(value); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/converter/StructureStateConverter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.converter; 2 | 3 | import cn.memoryzy.json.service.persistent.state.StructureState; 4 | import cn.memoryzy.json.util.JsonUtil; 5 | import com.intellij.util.xmlb.Converter; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2025/4/7 12 | */ 13 | public class StructureStateConverter extends Converter { 14 | 15 | @Override 16 | public @Nullable StructureState fromString(@NotNull String value) { 17 | return JsonUtil.toObject(value, StructureState.class); 18 | } 19 | 20 | @Override 21 | public @Nullable String toString(@NotNull StructureState value) { 22 | return JsonUtil.compressJson(value); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/AttributeSerializationState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | /** 4 | * 属性序列化 5 | * 6 | * @author Memory 7 | * @since 2024/11/18 8 | */ 9 | public class AttributeSerializationState { 10 | 11 | /** 12 | * 是否包含随机值(属性序列化为 JSON 时) 13 | */ 14 | public boolean includeRandomValues = false; 15 | 16 | /** 17 | * 识别 FastJson 注解 18 | */ 19 | public boolean recognitionFastJsonAnnotation = true; 20 | 21 | /** 22 | * 识别 Jackson 注解 23 | */ 24 | public boolean recognitionJacksonAnnotation = true; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/DeserializerState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | /** 4 | * 反序列化设置项 5 | * 6 | * @author Memory 7 | * @since 2024/12/23 8 | */ 9 | public class DeserializerState { 10 | 11 | /** 12 | * 添加 FastJson 注解 13 | */ 14 | public boolean fastJsonAnnotation = false; 15 | 16 | /** 17 | * 添加 FastJson2 注解 18 | */ 19 | public boolean fastJson2Annotation = false; 20 | 21 | /** 22 | * 添加 Jackson 注解 23 | */ 24 | public boolean jacksonAnnotation = false; 25 | 26 | /** 27 | * 类属性保持驼峰命名 28 | */ 29 | public boolean keepCamelCase = true; 30 | 31 | /** 32 | * 添加 Lombok @Data 注解 33 | */ 34 | public boolean dataLombokAnnotation = true; 35 | 36 | /** 37 | * 添加 Lombok @Accessors(chain = true) 注解 38 | */ 39 | public boolean accessorsChainLombokAnnotation = true; 40 | 41 | /** 42 | * 添加 Lombok @Getter 注解 43 | */ 44 | public boolean getterLombokAnnotation = false; 45 | 46 | /** 47 | * 添加 Lombok @Setter 注解 48 | */ 49 | public boolean setterLombokAnnotation = false; 50 | 51 | /** 52 | * 添加 Swagger 字段描述注解 53 | */ 54 | public boolean swaggerAnnotation = false; 55 | 56 | /** 57 | * 添加 Swagger v3 字段描述注解 58 | */ 59 | public boolean swaggerV3Annotation = false; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/EditorAppearanceState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | import cn.memoryzy.json.enums.ColorScheme; 4 | import cn.memoryzy.json.model.jackson.ColorDeserializer; 5 | import cn.memoryzy.json.model.jackson.ColorSerializer; 6 | import cn.memoryzy.json.util.PlatformUtil; 7 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 8 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 9 | 10 | import java.awt.*; 11 | 12 | /** 13 | * 编辑器外观 14 | * 15 | * @author Memory 16 | * @since 2024/11/18 17 | */ 18 | public class EditorAppearanceState { 19 | 20 | /** 21 | * 展示编辑器行号 22 | */ 23 | public boolean displayLineNumbers = false; 24 | 25 | /** 26 | * 显示折叠轮廓 27 | */ 28 | public boolean foldingOutline = PlatformUtil.isNewUi(); 29 | 30 | 31 | // ---------------------------------------------------- 32 | 33 | /** 34 | * 编辑器背景配色名称(指定颜色或自定义) 35 | */ 36 | public ColorScheme colorScheme = ColorScheme.Default; 37 | 38 | /** 39 | * 当选中自定义项时,用户指定的颜色(亮色) 40 | */ 41 | @JsonSerialize(using = ColorSerializer.class) 42 | @JsonDeserialize(using = ColorDeserializer.class) 43 | public Color customLightColor; 44 | 45 | /** 46 | * 当选中自定义项时,用户指定的颜色(暗色) 47 | */ 48 | @JsonSerialize(using = ColorSerializer.class) 49 | @JsonDeserialize(using = ColorDeserializer.class) 50 | public Color customDarkcolor; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/EditorBehaviorState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | /** 4 | * 编辑器外观 5 | * 6 | * @author Memory 7 | * @since 2024/11/18 8 | */ 9 | public class EditorBehaviorState { 10 | 11 | /** 12 | * 自动识别并转换其他格式数据(总开关) 13 | */ 14 | public boolean recognizeOtherFormats = true; 15 | 16 | /** 17 | * 自动识别并转换 XML 格式为 JSON 数据 18 | */ 19 | public boolean recognizeXmlFormat = true; 20 | 21 | /** 22 | * 自动识别并转换 YAML 格式为 JSON 数据 23 | */ 24 | public boolean recognizeYamlFormat = true; 25 | 26 | /** 27 | * 自动识别并转换 TOML 格式为 JSON 数据 28 | */ 29 | public boolean recognizeTomlFormat = true; 30 | 31 | /** 32 | * 自动识别并转换 URL Param 格式为 JSON 数据 33 | */ 34 | public boolean recognizeUrlParamFormat = true; 35 | 36 | /** 37 | * 自动导入剪贴板数据前提示 38 | */ 39 | public boolean promptBeforeImport = false; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/GeneralState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | import cn.memoryzy.json.enums.TreeDisplayMode; 4 | 5 | /** 6 | * 常规设置项 7 | * 8 | * @author Memory 9 | * @since 2024/12/11 10 | */ 11 | public class GeneralState { 12 | 13 | /** 14 | * JSON 树结构展示形式 15 | */ 16 | public TreeDisplayMode treeDisplayMode = TreeDisplayMode.POPUP; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/HistoryState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | import cn.memoryzy.json.enums.HistoryViewType; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/11/29 8 | */ 9 | public class HistoryState { 10 | 11 | /** 12 | * 历史记录开关 13 | */ 14 | public boolean switchHistory = true; 15 | 16 | /** 17 | * 历史记录显示类型 18 | */ 19 | public HistoryViewType historyViewType = HistoryViewType.TREE; 20 | 21 | /** 22 | * 是否自动记录 23 | */ 24 | public boolean autoStore = false; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/QueryState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | import cn.memoryzy.json.enums.JsonQuerySchema; 4 | 5 | /** 6 | * @author Memory 7 | * @since 2024/12/27 8 | */ 9 | public class QueryState { 10 | 11 | /** 12 | * 当前查询语言 13 | */ 14 | public JsonQuerySchema querySchema = JsonQuerySchema.JSONPath; 15 | 16 | /** 17 | * 显示原始文本 18 | */ 19 | public boolean showOriginalText = true; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/service/persistent/state/StructureState.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.service.persistent.state; 2 | 3 | /** 4 | * @author Memory 5 | * @since 2025/4/7 6 | */ 7 | public class StructureState { 8 | 9 | /** 10 | * 显示节点路径 11 | */ 12 | public boolean displayNodePath = true; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/color/EditorBackgroundScheme.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.color; 2 | 3 | import com.intellij.ide.ui.UISettings; 4 | import com.intellij.openapi.editor.colors.EditorColorsScheme; 5 | import com.intellij.openapi.editor.colors.impl.DelegateColorScheme; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.awt.*; 9 | 10 | /** 11 | * @author Memory 12 | * @since 2024/11/18 13 | */ 14 | public class EditorBackgroundScheme extends DelegateColorScheme { 15 | 16 | private final Color background; 17 | 18 | public EditorBackgroundScheme(@NotNull EditorColorsScheme delegate, final Color background) { 19 | super(delegate); 20 | this.background = background; 21 | // 如果开启了演示模式 22 | if (UISettings.getInstance().getPresentationMode()) { 23 | // 设置为演示模式的字体大小 24 | delegate.setEditorFontSize(UISettings.getInstance().getPresentationModeFontSize()); 25 | } 26 | } 27 | 28 | @Override 29 | public @NotNull Color getDefaultBackground() { 30 | return background; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/component/ActionGroupPopupButton.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.component; 2 | 3 | import cn.hutool.core.util.ReflectUtil; 4 | import com.intellij.ide.HelpTooltip; 5 | import com.intellij.openapi.actionSystem.ActionGroup; 6 | import com.intellij.openapi.actionSystem.AnAction; 7 | import com.intellij.openapi.actionSystem.AnActionEvent; 8 | import com.intellij.openapi.actionSystem.Presentation; 9 | import com.intellij.openapi.actionSystem.impl.ActionButton; 10 | import com.intellij.openapi.diagnostic.Logger; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.awt.*; 14 | 15 | /** 16 | * @author Memory 17 | * @since 2025/4/4 18 | */ 19 | public class ActionGroupPopupButton extends ActionButton { 20 | 21 | private static final Logger LOG = Logger.getInstance(ActionGroupPopupButton.class); 22 | 23 | public ActionGroupPopupButton(@NotNull AnAction action, Presentation presentation, String place, @NotNull Dimension minimumSize) { 24 | super(action, presentation, place, minimumSize); 25 | } 26 | 27 | @Override 28 | protected void showActionGroupPopup(@NotNull ActionGroup actionGroup, @NotNull AnActionEvent event) { 29 | HelpTooltip.hide(this); 30 | ReflectUtil.invoke(actionGroup, "actionPerformed", event); 31 | } 32 | 33 | @Override 34 | protected boolean shallPaintDownArrow() { 35 | return true; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/component/SearchHistoryButton.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.component; 2 | 3 | import com.intellij.ide.DataManager; 4 | import com.intellij.openapi.actionSystem.*; 5 | import com.intellij.openapi.actionSystem.ex.ActionButtonLook; 6 | import com.intellij.openapi.actionSystem.impl.ActionButton; 7 | 8 | import javax.swing.*; 9 | 10 | /** 11 | * @author Memory 12 | * @since 2024/12/29 13 | */ 14 | public class SearchHistoryButton extends ActionButton { 15 | 16 | public SearchHistoryButton(AnAction action, boolean focusable) { 17 | super(action, action.getTemplatePresentation().clone(), ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); 18 | setLook(ActionButtonLook.INPLACE_LOOK); 19 | setFocusable(focusable); 20 | updateIcon(); 21 | } 22 | 23 | @Override 24 | protected DataContext getDataContext() { 25 | return DataManager.getInstance().getDataContext(this); 26 | } 27 | 28 | @Override 29 | public int getPopState() { 30 | return isSelected() ? ActionButtonComponent.SELECTED : super.getPopState(); 31 | } 32 | 33 | @Override 34 | public Icon getIcon() { 35 | if (isEnabled() && isSelected()) { 36 | Icon selectedIcon = myPresentation.getSelectedIcon(); 37 | if (selectedIcon != null) return selectedIcon; 38 | } 39 | return super.getIcon(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/editor/SearchTextField.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.editor; 2 | 3 | import org.jetbrains.annotations.NonNls; 4 | 5 | import java.awt.event.KeyAdapter; 6 | import java.awt.event.KeyEvent; 7 | 8 | /** 9 | * 另一个实现可以看 {@link com.intellij.jsonpath.ui.JsonPathEvaluateView} 类 10 | * 11 | * @author Memory 12 | * @since 2024/12/17 13 | */ 14 | public class SearchTextField extends com.intellij.ui.SearchTextField { 15 | 16 | public SearchTextField(@NonNls String historyPropertyName, int historySize, Runnable action) { 17 | super(historyPropertyName); 18 | setHistorySize(historySize); 19 | addKeyboardListener(new KeyAdapter() { 20 | @Override 21 | public void keyPressed(KeyEvent e) { 22 | // 检查是否按下了Enter键 23 | if (e.getKeyCode() == KeyEvent.VK_ENTER) { 24 | action.run(); 25 | } 26 | } 27 | }); 28 | } 29 | 30 | @Override 31 | protected void onFieldCleared() { 32 | 33 | } 34 | 35 | 36 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/editor/ViewerModeLanguageTextEditor.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.editor; 2 | 3 | import com.intellij.lang.Language; 4 | import com.intellij.openapi.editor.EditorSettings; 5 | import com.intellij.openapi.editor.ex.EditorEx; 6 | import com.intellij.openapi.project.Project; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * @author Memory 12 | * @since 2024/8/22 13 | */ 14 | public class ViewerModeLanguageTextEditor extends CustomizedLanguageTextEditor { 15 | 16 | public ViewerModeLanguageTextEditor(Language language, @Nullable Project project, @NotNull String value, boolean needBorder) { 17 | super(language, project, value, needBorder); 18 | } 19 | 20 | @Override 21 | protected @NotNull EditorEx createEditor() { 22 | EditorEx editor = super.createEditor(); 23 | EditorSettings settings = editor.getSettings(); 24 | // 显示设置插入符行(光标选中行会变黄) 25 | settings.setCaretRowShown(true); 26 | // 编辑器设为-只读 27 | editor.setViewer(true); 28 | return editor; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/editor/extension/SearchExtension.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.editor.extension; 2 | 3 | import cn.memoryzy.json.bundle.JsonAssistantBundle; 4 | import com.intellij.icons.AllIcons; 5 | import com.intellij.ui.components.fields.ExtendableTextComponent; 6 | import com.intellij.ui.scale.JBUIScale; 7 | 8 | import javax.swing.*; 9 | 10 | /** 11 | * @author Memory 12 | * @since 2024/8/9 13 | */ 14 | public class SearchExtension implements ExtendableTextComponent.Extension { 15 | private final Runnable runnable; 16 | 17 | public SearchExtension(Runnable runnable) { 18 | this.runnable = runnable; 19 | } 20 | 21 | @Override 22 | public Icon getIcon(boolean hovered) { 23 | return AllIcons.Actions.Search; 24 | } 25 | 26 | @Override 27 | public String getTooltip() { 28 | return JsonAssistantBundle.messageOnSystem("tooltip.search.extension"); 29 | } 30 | 31 | @Override 32 | public int getIconGap() { 33 | return JBUIScale.scale(2); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("deprecation") 38 | public Runnable getActionOnClick() { 39 | return runnable; 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/icon/CircleIcon.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.icon; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | /** 7 | * 自定义圆形图标 8 | * 9 | * @author Memory 10 | * @since 2024/11/18 11 | */ 12 | public class CircleIcon implements Icon { 13 | private final int diameter; 14 | private final Color backgroundColor; 15 | 16 | public CircleIcon(int diameter, Color backgroundColor) { 17 | this.diameter = diameter; 18 | this.backgroundColor = backgroundColor; 19 | } 20 | 21 | @Override 22 | public void paintIcon(Component c, Graphics g, int x, int y) { 23 | Graphics2D g2d = (Graphics2D) g.create(); 24 | g2d.translate(x, y); 25 | g2d.setColor(backgroundColor); 26 | g2d.fillOval(0, 0, diameter, diameter); 27 | g2d.dispose(); 28 | } 29 | 30 | @Override 31 | public int getIconWidth() { 32 | return diameter; 33 | } 34 | 35 | @Override 36 | public int getIconHeight() { 37 | return diameter; 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/icon/ToggleIcon.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.icon; 2 | 3 | import icons.JsonAssistantIcons; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2025/1/3 11 | */ 12 | public class ToggleIcon implements Icon { 13 | 14 | private boolean selected; 15 | private final Icon checkedIcon; 16 | 17 | public ToggleIcon(boolean selected) { 18 | this.selected = selected; 19 | // this.checkedIcon = LafIconLookup.getIcon("checkmark"); 20 | this.checkedIcon = JsonAssistantIcons.CHECKMARK; 21 | } 22 | 23 | @Override 24 | public void paintIcon(Component c, Graphics g, int x, int y) { 25 | if (selected) { 26 | checkedIcon.paintIcon(c, g, x, y); 27 | } 28 | } 29 | 30 | @Override 31 | public int getIconWidth() { 32 | return checkedIcon.getIconWidth(); 33 | } 34 | 35 | @Override 36 | public int getIconHeight() { 37 | return checkedIcon.getIconHeight(); 38 | } 39 | 40 | public void prepare(boolean selected) { 41 | this.selected = selected; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/listener/ListRightClickPopupMenuMouseAdapter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.listener; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | import java.awt.event.MouseAdapter; 6 | import java.awt.event.MouseEvent; 7 | import java.util.Objects; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/11/29 12 | */ 13 | public class ListRightClickPopupMenuMouseAdapter extends MouseAdapter { 14 | 15 | private final JList showList; 16 | private final JPopupMenu popupMenu; 17 | 18 | public ListRightClickPopupMenuMouseAdapter(JList showList, JPopupMenu popupMenu) { 19 | this.showList = showList; 20 | this.popupMenu = popupMenu; 21 | } 22 | 23 | @Override 24 | public void mouseClicked(MouseEvent e) { 25 | if (SwingUtilities.isRightMouseButton(e)) { 26 | int x = e.getX(); 27 | int y = e.getY(); 28 | 29 | Object selectedValue = showList.getSelectedValue(); 30 | if (Objects.isNull(selectedValue)) { 31 | int index = showList.locationToIndex(new Point(x, y)); 32 | if (index != -1) { 33 | showList.setSelectedIndex(index); 34 | popupMenu.show(showList, x, y); 35 | } 36 | } else { 37 | popupMenu.show(showList, x, y); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/listener/TreeRightClickPopupMenuMouseAdapter.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.listener; 2 | 3 | import cn.hutool.core.util.ArrayUtil; 4 | import com.intellij.ui.treeStructure.Tree; 5 | 6 | import javax.swing.*; 7 | import javax.swing.tree.TreePath; 8 | import java.awt.event.MouseAdapter; 9 | import java.awt.event.MouseEvent; 10 | 11 | /** 12 | * @author Memory 13 | * @since 2024/11/23 14 | */ 15 | public class TreeRightClickPopupMenuMouseAdapter extends MouseAdapter { 16 | 17 | private final Tree tree; 18 | private final JPopupMenu popupMenu; 19 | 20 | public TreeRightClickPopupMenuMouseAdapter(Tree tree, JPopupMenu popupMenu) { 21 | this.tree = tree; 22 | this.popupMenu = popupMenu; 23 | } 24 | 25 | @Override 26 | public void mouseClicked(MouseEvent e) { 27 | if (SwingUtilities.isRightMouseButton(e)) { 28 | // 获取选中的节点 29 | TreePath[] paths = tree.getSelectionPaths(); 30 | if (ArrayUtil.isEmpty(paths)) { 31 | int row = tree.getRowForLocation(e.getX(), e.getY()); 32 | if (row != -1) { 33 | tree.setSelectionRow(row); 34 | popupMenu.show(tree, e.getX(), e.getY()); 35 | } 36 | } else { 37 | popupMenu.show(tree, e.getX(), e.getY()); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/panel/AuxiliaryTreeToolWindowPanel.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.panel; 2 | 3 | import com.intellij.ui.treeStructure.Tree; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2024/12/12 11 | */ 12 | public class AuxiliaryTreeToolWindowPanel extends JPanel { 13 | private Tree tree; 14 | private JPanel treeComponent; 15 | 16 | public AuxiliaryTreeToolWindowPanel(LayoutManager layout) { 17 | super(layout); 18 | } 19 | 20 | public void setTree(Tree tree) { 21 | this.tree = tree; 22 | } 23 | 24 | public void setTreeComponent(JPanel treeComponent) { 25 | this.treeComponent = treeComponent; 26 | } 27 | 28 | public Tree getTree() { 29 | return tree; 30 | } 31 | 32 | public JPanel getTreeComponent() { 33 | return treeComponent; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/panel/CombineCardLayout.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.panel; 2 | 3 | import cn.memoryzy.json.constant.PluginConstant; 4 | import com.intellij.ui.JBCardLayout; 5 | 6 | import java.awt.*; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2024/12/13 11 | */ 12 | public class CombineCardLayout extends JBCardLayout { 13 | 14 | private Container parent; 15 | private String currentCardName; 16 | 17 | public CombineCardLayout() { 18 | super(); 19 | } 20 | 21 | @Override 22 | public void show(Container parent, String name) { 23 | super.show(parent, name); 24 | this.parent = parent; 25 | this.currentCardName = name; 26 | } 27 | 28 | public void show(String name) { 29 | super.show(parent, name); 30 | this.currentCardName = name; 31 | } 32 | 33 | /** 34 | * 切换卡片展示 35 | */ 36 | public void toggleCard(String cardName) { 37 | show(cardName); 38 | } 39 | 40 | public boolean isEditorCardDisplayed() { 41 | return PluginConstant.JSON_EDITOR_CARD_NAME.equals(currentCardName); 42 | } 43 | 44 | public boolean isTreeCardDisplayed() { 45 | return PluginConstant.JSON_TREE_CARD_NAME.equals(currentCardName); 46 | } 47 | 48 | public boolean isQueryCardDisplayed() { 49 | return PluginConstant.JSON_QUERY_CARD_NAME.equals(currentCardName); 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/ui/panel/HyperLinkJBLabel.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.ui.panel; 2 | 3 | import cn.memoryzy.json.ui.listener.HyperLinkListenerImpl; 4 | import com.intellij.ui.components.JBLabel; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import javax.swing.event.HyperlinkListener; 8 | 9 | /** 10 | * @author Memory 11 | * @since 2024/7/29 12 | */ 13 | public class HyperLinkJBLabel extends JBLabel { 14 | @Override 15 | protected @NotNull HyperlinkListener createHyperlinkListener() { 16 | return new HyperLinkListenerImpl(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/cn/memoryzy/json/util/TomlUtil.java: -------------------------------------------------------------------------------- 1 | package cn.memoryzy.json.util; 2 | 3 | import com.moandjiezana.toml.Toml; 4 | import com.moandjiezana.toml.TomlWriter; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * @author Memory 10 | * @since 2024/9/24 11 | */ 12 | public class TomlUtil { 13 | 14 | public static boolean isToml(String tomlStr) { 15 | try { 16 | new Toml().read(tomlStr); 17 | return true; 18 | } catch (Exception e) { 19 | return false; 20 | } 21 | } 22 | 23 | public static String toJson(String tomlStr) { 24 | Toml toml = new Toml().read(tomlStr); 25 | Map map = toml.toMap(); 26 | return JsonUtil.toJsonStr(map); 27 | } 28 | 29 | public static String toToml(String jsonStr, boolean isJson) { 30 | Object jsonObject = isJson ? JsonUtil.parseObject(jsonStr) : Json5Util.parseObject(jsonStr); 31 | // 单纯的 List 类型无法转换 32 | return new TomlWriter().write(jsonObject); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/thirdparty/a2u/tn/utils/json/MapNavigator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Original code modified from tnjson (Unlicense License). 3 | * Source: https://github.com/anymaker/tnjson 4 | * Original package: a2u.tn.utils.json 5 | */ 6 | package thirdparty.a2u.tn.utils.json; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | * Navigate by Map represented object.
14 | * Every value in the Map must be 15 | *
    16 | *
  • either a simple value: string, number, boolean, or other;
  • 17 | *
  • either by a Map such as Map<String, Object>;
  • 18 | *
  • either an array of values such as Collection<Object>.
  • 19 | *
20 | */ 21 | public class MapNavigator { 22 | 23 | private MapNavigator() { 24 | //hide this 25 | } 26 | 27 | 28 | /** 29 | * Find value from map by path. 30 | * @param map map with values 31 | * @param path path with string-keys and dot as separator 32 | * @return value 33 | */ 34 | public static Object fromPath(Map map, String path) { 35 | 36 | Object res = map; 37 | List pathList = Arrays.asList(path.split("\\.")); 38 | 39 | StringBuilder node = new StringBuilder(); 40 | 41 | for (String pat : pathList) { 42 | if (res == null) { 43 | return null; 44 | } 45 | if (res instanceof Map) { 46 | res = ((Map) res).get(pat); 47 | } 48 | else if (res instanceof List) { 49 | int ix = Integer.parseInt(pat); 50 | res = ((List) res).get(ix); 51 | } 52 | else { 53 | throw new RuntimeException("Incorrect path: node=" + node.toString() + " is not a Map or List."); 54 | } 55 | node.append(".").append(pat); 56 | } 57 | 58 | return res; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/thirdparty/a2u/tn/utils/json/ParseException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Original code modified from tnjson (Unlicense License). 3 | * Source: https://github.com/anymaker/tnjson 4 | * Original package: a2u.tn.utils.json 5 | */ 6 | package thirdparty.a2u.tn.utils.json; 7 | 8 | /** 9 | * Exception on parse error 10 | */ 11 | public class ParseException extends RuntimeException { 12 | 13 | private int position; 14 | private String path; 15 | 16 | public ParseException(String s, int position, String path) { 17 | super(s); 18 | this.position = position; 19 | this.path = path; 20 | } 21 | 22 | /** 23 | * Position in json where occur error. 24 | * @return position of invalid symbol 25 | */ 26 | public int getPosition() { 27 | return position; 28 | } 29 | /** 30 | * Path in json where occur error. 31 | * @return path where occur error 32 | */ 33 | public String getPath() { 34 | return path; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/thirdparty/a2u/tn/utils/json/SerializeException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Original code modified from tnjson (Unlicense License). 3 | * Source: https://github.com/anymaker/tnjson 4 | * Original package: a2u.tn.utils.json 5 | */ 6 | package thirdparty.a2u.tn.utils.json; 7 | 8 | /** 9 | * Exception on serialization error 10 | */ 11 | public class SerializeException extends RuntimeException { 12 | 13 | public SerializeException(String s) { 14 | super(s); 15 | } 16 | 17 | public SerializeException(String s, Throwable cause) { 18 | super(s, cause); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /src/main/resources/JsonAssistantIconMappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "icons": { 3 | "expui": { 4 | "groupByClass.svg": "icons/groupByClass.svg", 5 | "json.svg": "icons/json.svg", 6 | "extract.svg": "icons/extract.svg", 7 | "donate.svg": "icons/donate.svg", 8 | "esc.svg": "icons/esc.svg", 9 | "book_page.svg": "icons/book_page.svg", 10 | "book_reader.svg": "icons/book_reader.svg", 11 | "group.svg": "icons/group.svg", 12 | "fileTypes": { 13 | "toml.svg": "icons/fileTypes/toml-file.svg", 14 | "url.svg": "icons/fileTypes/url.svg", 15 | "kv.svg": "icons/fileTypes/kv.svg" 16 | }, 17 | "toolwindow": { 18 | "logo.svg": "icons/toolwindow/logo.svg", 19 | "structure_logo.svg": "icons/toolwindow/structure_logo.svg", 20 | "minify.svg": "icons/toolwindow/minify.svg", 21 | "save.svg": "icons/toolwindow/save.svg", 22 | "search.svg": "icons/toolwindow/search.svg", 23 | "structure.svg": "icons/toolwindow/structure.svg", 24 | "delete.svg": "icons/toolwindow/delete.svg", 25 | "magic.svg": "icons/toolwindow/magic.svg", 26 | "scrollDown.svg": "icons/toolwindow/scrollDown.svg", 27 | "softWrap.svg": "icons/toolwindow/softWrap.svg", 28 | "switch.svg": "icons/toolwindow/switch.svg", 29 | "text.svg": "icons/toolwindow/text.svg" 30 | }, 31 | "structure": { 32 | "compare_structure.svg": "icons/structure/compare_structure.svg" 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-java.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-json.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-kotlin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-toml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-xdebugger.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-xml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/optional/plugin-yaml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/resources/fileTemplates/j2ee/New Class.java.ft: -------------------------------------------------------------------------------- 1 | #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end 2 | 3 | #foreach($IMPORT in $IMPORTS) 4 | import ${IMPORT}; 5 | #end 6 | #if(${IS_STATIC} == false) 7 | #parse("File Header.java") 8 | #end 9 | #foreach($ANNO in $CLASS_ANNOTATIONS) 10 | ${ANNO.ANNOTATION_STRING} 11 | #end 12 | public ${CLASS_MODIFIER}class ${NAME} { 13 | 14 | #foreach($FIELD in $FIELDS) 15 | #if($!{FIELD.COMMENT} && "$!FIELD.COMMENT" != "") 16 | /** 17 | * ${FIELD.COMMENT} 18 | */ 19 | #end 20 | #foreach($ANNO in ${FIELD.ANNOTATIONS}) 21 | ${ANNO.ANNOTATION_STRING} 22 | #end 23 | private ${FIELD.TYPE} ${FIELD.NAME}; 24 | 25 | #end 26 | #foreach($snippet in $INNER_SNIPPETS) 27 | $snippet 28 | #end 29 | } -------------------------------------------------------------------------------- /src/main/resources/fileTemplates/j2ee/New Class.java.html: -------------------------------------------------------------------------------- 1 | This is a built-in file template for creating Java files with annotations and comments. 2 |

3 | 这是一个内置的文件模板,用于创建带有注解及注释的 Java 文件。 -------------------------------------------------------------------------------- /src/main/resources/fileTemplates/j2ee/New Kotlin Class.kt.ft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MemoryZy/Json-Assistant/fa572bd5748c9d91f426af7924ffac32dee47210/src/main/resources/fileTemplates/j2ee/New Kotlin Class.kt.ft -------------------------------------------------------------------------------- /src/main/resources/fileTemplates/j2ee/New Kotlin Class.kt.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MemoryZy/Json-Assistant/fa572bd5748c9d91f426af7924ffac32dee47210/src/main/resources/fileTemplates/j2ee/New Kotlin Class.kt.html -------------------------------------------------------------------------------- /src/main/resources/icons/book_reader.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/book_reader_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/box.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/checkmark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/icons/checkmark_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/main/resources/icons/conversion.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /src/main/resources/icons/diff.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/icons/dizzy_star.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/donate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/escape.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/book_reader.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/book_reader_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/fileTypes/toml.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/fileTypes/toml_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/fileTypes/url.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/fileTypes/url_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/toolwindow/minify.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/toolwindow/minify_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/toolwindow/save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/toolwindow/save_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/toolwindow/text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/expui/toolwindow/text_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/fileTypes/toml-file.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/icons/fileTypes/toml-file_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/icons/function.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/icons/groupByClass.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/groupByClass_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/heart.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/icons/shortcuts.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/star_fall_mini.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | -------------------------------------------------------------------------------- /src/main/resources/icons/star_fall_mini_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/intellij_collapseAll.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/intellij_collapseAll_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/intellij_expandAll.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/intellij_expandAll_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_item.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_item_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_key.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_key_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_object.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_object_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_object_item.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/structure/json_object_item_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/sun.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/eye_off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/eye_off_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/history.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/history_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/minify.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/minify_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/pencil.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/pencil_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/save_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/icons/toolwindow/text_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Pixso. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/images/alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MemoryZy/Json-Assistant/fa572bd5748c9d91f426af7924ffac32dee47210/src/main/resources/images/alipay.png -------------------------------------------------------------------------------- /src/main/resources/images/wechat_pay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MemoryZy/Json-Assistant/fa572bd5748c9d91f426af7924ffac32dee47210/src/main/resources/images/wechat_pay.png -------------------------------------------------------------------------------- /src/main/resources/inspectionDescriptions/ConvertTimestamp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This operation checks if the current value itself is a valid timestamp, and if so, converts the timestamp into a time format.

此操作会检测到当前值本身是有效时间戳的情况,并将该时间戳转换为时间格式。

4 | 5 |

Example:

6 |

 7 | {
 8 |   "confirmTime": 1739842291000
 9 | }
10 | 11 |

After the quick-fix is applied:

12 | 13 |

14 | {
15 |   "confirmTime": "2025-02-18 09:31:31"
16 | }
17 | 18 |
19 | 20 | Powered by: Json Assistant plugin 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/inspectionDescriptions/ExpandNestedJson.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This operation detects that the string values themselves are valid JSON and expands those string values into JSON objects/arrays.

此操作会检测到字符串值本身是有效 JSON 的情况,并将这些字符串值展开为 JSON 对象/数组。 4 | 5 |

Example:

6 |

 7 | {
 8 |   "content": "{\"hobbies\":[\"reading\"]}"
 9 | }
10 | 11 |

After the quick-fix is applied:

12 | 13 |

14 | {
15 |   "content": {
16 |     "hobbies": [
17 |       "reading"
18 |     ]
19 |   }
20 | }
21 | 22 |
23 | 24 | Powered by: Json Assistant plugin 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/resources/intentionDescriptions/ConvertReadableTimeIntention/after.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "confirmTime": 1743393600000 3 | } -------------------------------------------------------------------------------- /src/main/resources/intentionDescriptions/ConvertReadableTimeIntention/before.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "confirmTime": "2025-03-31 12:00:00" 3 | } -------------------------------------------------------------------------------- /src/main/resources/intentionDescriptions/ConvertReadableTimeIntention/description.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This action detects that the current value is itself in a valid time format and converts that time to a timestamp.

此操作会检测到当前值本身是有效时间格式的情况,并将该时间转换为时间戳。

4 | 5 | Powered by: Json Assistant plugin 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/test/kotlin/org/jetbrains/plugins/template/MyPluginTest.kt: -------------------------------------------------------------------------------- 1 | //package org.jetbrains.plugins.template 2 | // 3 | //import com.intellij.ide.highlighter.XmlFileType 4 | //import com.intellij.openapi.components.service 5 | //import com.intellij.psi.xml.XmlFile 6 | //import com.intellij.testFramework.TestDataPath 7 | //import com.intellij.testFramework.fixtures.BasePlatformTestCase 8 | //import com.intellij.util.PsiErrorElementUtil 9 | //import org.jetbrains.plugins.template.services.MyProjectService 10 | // 11 | //@TestDataPath("\$CONTENT_ROOT/src/test/testData") 12 | //class MyPluginTest : BasePlatformTestCase() { 13 | // 14 | // fun testXMLFile() { 15 | // val psiFile = myFixture.configureByText(XmlFileType.INSTANCE, "bar") 16 | // val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java) 17 | // 18 | // assertFalse(PsiErrorElementUtil.hasErrors(project, xmlFile.virtualFile)) 19 | // 20 | // assertNotNull(xmlFile.rootTag) 21 | // 22 | // xmlFile.rootTag?.let { 23 | // assertEquals("foo", it.name) 24 | // assertEquals("bar", it.value.text) 25 | // } 26 | // } 27 | // 28 | // fun testRename() { 29 | // myFixture.testRename("foo.xml", "foo_after.xml", "a2") 30 | // } 31 | // 32 | // fun testProjectService() { 33 | // val projectService = project.service() 34 | // 35 | // assertNotSame(projectService.getRandomNumber(), projectService.getRandomNumber()) 36 | // } 37 | // 38 | // override fun getTestDataPath() = "src/test/testData/rename" 39 | //} 40 | -------------------------------------------------------------------------------- /src/test/testData/rename/foo.xml: -------------------------------------------------------------------------------- 1 | 2 | 1>Foo 3 | 4 | -------------------------------------------------------------------------------- /src/test/testData/rename/foo_after.xml: -------------------------------------------------------------------------------- 1 | 2 | Foo 3 | 4 | --------------------------------------------------------------------------------