From e7c9867c8e318ac5e33612565dcd2460838a9d9b Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 29 Dec 2024 14:27:38 -0500 Subject: [PATCH 01/13] Chore: Create example localization files for zh_CN --- .../CsvValidation_zh_CN.html | 5 ++ .../QuoteAll/description_zh_CN.html | 5 ++ .../CsvEditorActions_zh_CN.properties | 20 ++++++++ .../CsvEditorResources_zh_CN.properties | 51 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html create mode 100644 src/main/resources/localization/CsvEditorActions_zh_CN.properties create mode 100644 src/main/resources/localization/CsvEditorResources_zh_CN.properties diff --git a/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html b/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html new file mode 100644 index 00000000..8827be73 --- /dev/null +++ b/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html @@ -0,0 +1,5 @@ + + +Suggests possible fixes for CSV validation errors.[zh_CN] + + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html b/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html new file mode 100644 index 00000000..87f1fc12 --- /dev/null +++ b/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html @@ -0,0 +1,5 @@ + + +This intention quotes all values.[zh_CN]
+ + \ No newline at end of file diff --git a/src/main/resources/localization/CsvEditorActions_zh_CN.properties b/src/main/resources/localization/CsvEditorActions_zh_CN.properties new file mode 100644 index 00000000..53c25c5b --- /dev/null +++ b/src/main/resources/localization/CsvEditorActions_zh_CN.properties @@ -0,0 +1,20 @@ +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.text=New Column Before (Ctrl+Shift+Left)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.description=New column before (ctrl+shift+left)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.text=New Column After (Ctrl+Shift+Right)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.description=New column after (ctrl+shift+right)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.text=Delete Selected Columns (Ctrl+Shift+Del)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.description=Delete selected columns (ctrl+shift+del)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.text=New Row Before (Ctrl+Up)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.description=New row before (ctrl+up)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.text=New Row After (Ctrl+Down)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.description=New row after (ctrl+down)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.text=Delete Selected Rows (Ctrl+Del)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.description=Delete selected rows (ctrl+del)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.text=Auto-Fit Columns Width (Ctrl+Shift+Space)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.description=Auto-fit columns width (ctrl+shift+space)[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.text=Reset Columns Width to Default[zh_CN] +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.description=Reset columns width to default[zh_CN] +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.text=CSV Separator[zh_CN] +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.description=CSV separator[zh_CN] +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.text=CSV Escape Character[zh_CN] +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.description=CSV escape character[zh_CN] \ No newline at end of file diff --git a/src/main/resources/localization/CsvEditorResources_zh_CN.properties b/src/main/resources/localization/CsvEditorResources_zh_CN.properties new file mode 100644 index 00000000..78cf3d73 --- /dev/null +++ b/src/main/resources/localization/CsvEditorResources_zh_CN.properties @@ -0,0 +1,51 @@ +auto.detect.initially=auto-detect initially[zh_CN] +can.be.adjusted.per.file.in.editor.context.menu=Can be adjusted per file in editor context menu[zh_CN] +color.attribute.separator=Separator[zh_CN] +color.attribute.quote=Quote[zh_CN] +color.attribute.text=Text[zh_CN] +color.attribute.text.escaped=Escaped text[zh_CN] +color.attribute.comment=Comment[zh_CN] +color.attribute.column.nr=Column Color %d[zh_CN] +column.numbering=Column numbering:[zh_CN] +default.column.width.in.px=Default column width in px (10 - 10000):[zh_CN] +default.escape.character=Default Escape Character:[zh_CN] +default.row.height.in.px=Default row height in px (20-100):[zh_CN] +default.value.separator.csv.only=Default Value Separator (CSV only):[zh_CN] +editor.usage=Editor usage:[zh_CN] +enforce.value.quoting=Enforce value quoting[zh_CN] +error.while.parsing.content.please.fix.issues.in.text.editor=\ Error while parsing content - please fix issues in text editor![zh_CN] +general=General[zh_CN] +group.separator=Separator[zh_CN] +group.separator.space.before=Space before separator[zh_CN] +group.separator.space.after=Space after separator[zh_CN] +group.tabularize=Tabularize[zh_CN] +group.tabularize.as.table=Format as table[zh_CN] +group.tabularize.keep.quoted=Keep quoted value as is[zh_CN] +group.tabularize.align.right=Align right[zh_CN] +group.tabularize.enhanced.width.calculation=Enhanced width calculation (slower)[zh_CN] +group.trimming=Trimming (only if not tabularized)[zh_CN] +group.trimming.leading=Trim leading whitespaces[zh_CN] +group.trimming.trailing=Trim trailing whitespaces[zh_CN] +highlight.caret.row=Highlight caret row[zh_CN] +highlighting=Highlighting[zh_CN] +keep.trailing.whitespaces.if.unchecked.general.editor.setting.apply=Keep trailing whitespaces (if unchecked, general editor setting apply)[zh_CN] +line.comment.indicator=Line comment indicator:[zh_CN] +maximum.column.width.in.px=Maximum column width in px (0 = no maximum):[zh_CN] +open.file.in.text.editor=Open file in text editor[zh_CN] +others=Others[zh_CN] +settings.title=CSV/TSV/PSV[zh_CN] +settings.codestyle.spaces=Spaces[zh_CN] +settings.codestyle.wrapping=Wrapping[zh_CN] +settings.editor.coloring.rainbow=Rainbow (Column Color)[zh_CN] +settings.editor.coloring.simple=Simple (Text Color)[zh_CN] +settings.editor.help=Editor Options for CSV/TSV/PSV files[zh_CN] +settings.editor.highlight.tab.separator=Highlight tab separator [zh_CN] +settings.editor.prio.table_first=Table editor first[zh_CN] +settings.editor.prio.text_first=Text editor first[zh_CN] +settings.editor.prio.text_only=Text editor only[zh_CN] +show.info.balloon=Show info balloon[zh_CN] +table.editor=Table Editor[zh_CN] +text.editor=Text Editor[zh_CN] +use.soft.wraps=Use soft wraps[zh_CN] +value.coloring=Value Coloring:[zh_CN] +zero.based=Zero-based[zh_CN] \ No newline at end of file From 0181f7ee4bd9af5c5311a231350169cf818d5f33 Mon Sep 17 00:00:00 2001 From: CJYKK <2159913864@qq.com> Date: Wed, 1 Jan 2025 21:07:34 +0800 Subject: [PATCH 02/13] Chore: Simplified Chinese translation --- .../CsvValidation_zh_CN.html | 2 +- .../QuoteValue/description_zh_CN.html | 5 + .../ShiftColumnLeft/description_zh_CN.html | 5 + .../ShiftColumnRight/description_zh_CN.html | 5 + .../UnquoteAll/description_zh_CN.html | 5 + .../UnquoteValue/description_zh_CN.html | 5 + .../CsvEditorActions_zh_CN.properties | 41 +++---- .../CsvEditorResources_zh_CN.properties | 102 +++++++++--------- 8 files changed, 98 insertions(+), 72 deletions(-) create mode 100644 src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html diff --git a/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html b/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html index 8827be73..6dc2d4d9 100644 --- a/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html +++ b/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html @@ -1,5 +1,5 @@ -Suggests possible fixes for CSV validation errors.[zh_CN] +对 CSV 验证错误提出可能的修复建议。 \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html b/src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html new file mode 100644 index 00000000..cd69c2ce --- /dev/null +++ b/src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html @@ -0,0 +1,5 @@ + + +为未添加引号的值添加引号。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html b/src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html new file mode 100644 index 00000000..f3619710 --- /dev/null +++ b/src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html @@ -0,0 +1,5 @@ + + +将列左移并交换位置。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html b/src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html new file mode 100644 index 00000000..c01fc6fd --- /dev/null +++ b/src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html @@ -0,0 +1,5 @@ + + +将列右移并交换位置。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html b/src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html new file mode 100644 index 00000000..96553972 --- /dev/null +++ b/src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html @@ -0,0 +1,5 @@ + + +尽可能地移除所有值的引号。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html b/src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html new file mode 100644 index 00000000..056c87da --- /dev/null +++ b/src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html @@ -0,0 +1,5 @@ + + +移除已有引号的值的引号。
+ + \ No newline at end of file diff --git a/src/main/resources/localization/CsvEditorActions_zh_CN.properties b/src/main/resources/localization/CsvEditorActions_zh_CN.properties index 53c25c5b..b895a81e 100644 --- a/src/main/resources/localization/CsvEditorActions_zh_CN.properties +++ b/src/main/resources/localization/CsvEditorActions_zh_CN.properties @@ -1,20 +1,21 @@ -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.text=New Column Before (Ctrl+Shift+Left)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.description=New column before (ctrl+shift+left)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.text=New Column After (Ctrl+Shift+Right)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.description=New column after (ctrl+shift+right)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.text=Delete Selected Columns (Ctrl+Shift+Del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.description=Delete selected columns (ctrl+shift+del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.text=New Row Before (Ctrl+Up)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.description=New row before (ctrl+up)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.text=New Row After (Ctrl+Down)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.description=New row after (ctrl+down)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.text=Delete Selected Rows (Ctrl+Del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.description=Delete selected rows (ctrl+del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.text=Auto-Fit Columns Width (Ctrl+Shift+Space)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.description=Auto-fit columns width (ctrl+shift+space)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.text=Reset Columns Width to Default[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.description=Reset columns width to default[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.text=CSV Separator[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.description=CSV separator[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.text=CSV Escape Character[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.description=CSV escape character[zh_CN] \ No newline at end of file +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.text=\u5728\u5DE6\u4FA7\u65B0\u589E\u5217 (Ctrl+Shift+Left) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.description=\u5728\u5DE6\u4FA7\u65B0\u589E\u4E00\u5217 (ctrl+shift+left) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.text=\u5728\u53F3\u4FA7\u65B0\u589E\u5217 (Ctrl+Shift+Right) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.description=\u5728\u53F3\u4FA7\u65B0\u589E\u4E00\u5217 (ctrl+shift+right) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.text=\u5220\u9664\u9009\u4E2D\u7684\u5217 (Ctrl+Shift+Del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.description=\u5220\u9664\u9009\u4E2D\u7684\u5217 (ctrl+shift+del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.text=\u5728\u4E0A\u65B9\u65B0\u589E\u884C (Ctrl+Up) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.description=\u5728\u4E0A\u65B9\u65B0\u589E\u4E00\u884C (ctrl+up) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.text=\u5728\u4E0B\u65B9\u65B0\u589E\u884C (Ctrl+Down) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.description=\u5728\u4E0B\u65B9\u65B0\u589E\u4E00\u884C (ctrl+down) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.text=\u5220\u9664\u9009\u4E2D\u7684\u884C (Ctrl+Del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.description=\u5220\u9664\u9009\u4E2D\u7684\u884C (ctrl+del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.text=\u81EA\u52A8\u8C03\u6574\u5217\u5BBD (Ctrl+Shift+Space) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.description=\u81EA\u52A8\u8C03\u6574\u5217\u5BBD (ctrl+shift+space) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.text=\u91CD\u7F6E\u5217\u5BBD\u4E3A\u9ED8\u8BA4\u503C +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.description=\u91CD\u7F6E\u5217\u5BBD\u4E3A\u9ED8\u8BA4\u503C + +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.text=CSV \u5206\u9694\u7B26 +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.description=CSV \u5206\u9694\u7B26 +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.text=CSV \u8F6C\u4E49\u5B57\u7B26 +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.description=CSV \u8F6C\u4E49\u5B57\u7B26 \ No newline at end of file diff --git a/src/main/resources/localization/CsvEditorResources_zh_CN.properties b/src/main/resources/localization/CsvEditorResources_zh_CN.properties index 78cf3d73..7f792dca 100644 --- a/src/main/resources/localization/CsvEditorResources_zh_CN.properties +++ b/src/main/resources/localization/CsvEditorResources_zh_CN.properties @@ -1,51 +1,51 @@ -auto.detect.initially=auto-detect initially[zh_CN] -can.be.adjusted.per.file.in.editor.context.menu=Can be adjusted per file in editor context menu[zh_CN] -color.attribute.separator=Separator[zh_CN] -color.attribute.quote=Quote[zh_CN] -color.attribute.text=Text[zh_CN] -color.attribute.text.escaped=Escaped text[zh_CN] -color.attribute.comment=Comment[zh_CN] -color.attribute.column.nr=Column Color %d[zh_CN] -column.numbering=Column numbering:[zh_CN] -default.column.width.in.px=Default column width in px (10 - 10000):[zh_CN] -default.escape.character=Default Escape Character:[zh_CN] -default.row.height.in.px=Default row height in px (20-100):[zh_CN] -default.value.separator.csv.only=Default Value Separator (CSV only):[zh_CN] -editor.usage=Editor usage:[zh_CN] -enforce.value.quoting=Enforce value quoting[zh_CN] -error.while.parsing.content.please.fix.issues.in.text.editor=\ Error while parsing content - please fix issues in text editor![zh_CN] -general=General[zh_CN] -group.separator=Separator[zh_CN] -group.separator.space.before=Space before separator[zh_CN] -group.separator.space.after=Space after separator[zh_CN] -group.tabularize=Tabularize[zh_CN] -group.tabularize.as.table=Format as table[zh_CN] -group.tabularize.keep.quoted=Keep quoted value as is[zh_CN] -group.tabularize.align.right=Align right[zh_CN] -group.tabularize.enhanced.width.calculation=Enhanced width calculation (slower)[zh_CN] -group.trimming=Trimming (only if not tabularized)[zh_CN] -group.trimming.leading=Trim leading whitespaces[zh_CN] -group.trimming.trailing=Trim trailing whitespaces[zh_CN] -highlight.caret.row=Highlight caret row[zh_CN] -highlighting=Highlighting[zh_CN] -keep.trailing.whitespaces.if.unchecked.general.editor.setting.apply=Keep trailing whitespaces (if unchecked, general editor setting apply)[zh_CN] -line.comment.indicator=Line comment indicator:[zh_CN] -maximum.column.width.in.px=Maximum column width in px (0 = no maximum):[zh_CN] -open.file.in.text.editor=Open file in text editor[zh_CN] -others=Others[zh_CN] -settings.title=CSV/TSV/PSV[zh_CN] -settings.codestyle.spaces=Spaces[zh_CN] -settings.codestyle.wrapping=Wrapping[zh_CN] -settings.editor.coloring.rainbow=Rainbow (Column Color)[zh_CN] -settings.editor.coloring.simple=Simple (Text Color)[zh_CN] -settings.editor.help=Editor Options for CSV/TSV/PSV files[zh_CN] -settings.editor.highlight.tab.separator=Highlight tab separator [zh_CN] -settings.editor.prio.table_first=Table editor first[zh_CN] -settings.editor.prio.text_first=Text editor first[zh_CN] -settings.editor.prio.text_only=Text editor only[zh_CN] -show.info.balloon=Show info balloon[zh_CN] -table.editor=Table Editor[zh_CN] -text.editor=Text Editor[zh_CN] -use.soft.wraps=Use soft wraps[zh_CN] -value.coloring=Value Coloring:[zh_CN] -zero.based=Zero-based[zh_CN] \ No newline at end of file +auto.detect.initially=\u52A0\u8F7D\u6587\u4EF6\u65F6\u81EA\u52A8\u68C0\u6D4B +can.be.adjusted.per.file.in.editor.context.menu=\u53EF\u4EE5\u5728\u7F16\u8F91\u5668\u7684\u4E0A\u4E0B\u6587\u83DC\u5355\u4E2D\u6309\u6587\u4EF6\u8C03\u6574 +color.attribute.separator=\u5206\u9694\u7B26 +color.attribute.quote=\u5F15\u53F7 +color.attribute.text=\u6587\u672C +color.attribute.text.escaped=\u8F6C\u4E49\u6587\u672C +color.attribute.comment=\u6CE8\u91CA +color.attribute.column.nr=\u5217\u989C\u8272 %d +column.numbering=\u5217\u7F16\u53F7\uFF1A +default.column.width.in.px=\u9ED8\u8BA4\u5217\u5BBD\uFF0810 ~ 10000\u50CF\u7D20\uFF09\uFF1A +default.escape.character=\u9ED8\u8BA4\u8F6C\u4E49\u5B57\u7B26\uFF1A +default.row.height.in.px=\u9ED8\u8BA4\u884C\u9AD8\uFF0820 ~ 100\u50CF\u7D20\uFF09\uFF1A +default.value.separator.csv.only=\u9ED8\u8BA4\u503C\u5206\u9694\u7B26\uFF08\u4EC5\u9002\u7528\u4E8ECSV\uFF09\uFF1A +editor.usage=\u7F16\u8F91\u5668\u7528\u6CD5\uFF1A +enforce.value.quoting=\u5F3A\u5236\u4E3A\u503C\u6DFB\u52A0\u5F15\u53F7 +error.while.parsing.content.please.fix.issues.in.text.editor=\ \u89E3\u6790\u5185\u5BB9\u65F6\u51FA\u9519 - \u8BF7\u5728\u6587\u672C\u7F16\u8F91\u5668\u4E2D\u4FEE\u590D\u95EE\u9898\uFF01 +general=\u5E38\u89C4 +group.separator=\u5206\u9694\u7B26 +group.separator.space.before=\u5728\u5206\u9694\u7B26\u524D\u6DFB\u52A0\u7A7A\u683C +group.separator.space.after=\u5728\u5206\u9694\u7B26\u540E\u6DFB\u52A0\u7A7A\u683C +group.tabularize=\u5236\u8868 +group.tabularize.as.table=\u683C\u5F0F\u5316\u4E3A\u8868\u683C +group.tabularize.keep.quoted=\u4FDD\u6301\u5F15\u7528\u503C\u4E0D\u53D8 +group.tabularize.align.right=\u53F3\u5BF9\u9F50 +group.tabularize.enhanced.width.calculation=\u589E\u5F3A\u5BBD\u5EA6\u8BA1\u7B97\uFF08\u8F83\u6162\uFF09 +group.trimming=\u4FEE\u526A\uFF08\u4EC5\u5F53\u672A\u5236\u8868\u65F6\uFF09 +group.trimming.leading=\u4FEE\u526A\u524D\u5BFC\u7A7A\u683C +group.trimming.trailing=\u4FEE\u526A\u5C3E\u968F\u7A7A\u683C +highlight.caret.row=\u9AD8\u4EAE\u5149\u6807\u884C +highlighting=\u9AD8\u4EAE +keep.trailing.whitespaces.if.unchecked.general.editor.setting.apply=\u4FDD\u7559\u5C3E\u968F\u7A7A\u683C\uFF08\u82E5\u672A\u9009\u4E2D\uFF0C\u5219\u4F7F\u7528\u901A\u7528\u7F16\u8F91\u5668\u8BBE\u7F6E\uFF09 +line.comment.indicator=\u884C\u6CE8\u91CA\u6307\u793A\u7B26\uFF1A +maximum.column.width.in.px=\u6700\u5927\u5217\u5BBD\uFF08\u50CF\u7D20\uFF0C0 = \u65E0\u9650\u5236\uFF09: +open.file.in.text.editor=\u5728\u6587\u672C\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\u6587\u4EF6 +others=\u5176\u4ED6 +settings.title=CSV/TSV/PSV +settings.codestyle.spaces=\u7A7A\u683C +settings.codestyle.wrapping=\u6362\u884C +settings.editor.coloring.rainbow=\u5F69\u8679\uFF08\u5217\u989C\u8272\uFF09 +settings.editor.coloring.simple=\u7B80\u5355\uFF08\u6587\u672C\u989C\u8272\uFF09 +settings.editor.help=CSV/TSV/PSV\u6587\u4EF6\u7684\u7F16\u8F91\u5668\u9009\u9879 +settings.editor.highlight.tab.separator=\u9AD8\u4EAE\u5236\u8868\u7B26\u5206\u9694\u7B26 +settings.editor.prio.table_first=\u4F18\u5148\u4F7F\u7528\u8868\u683C\u7F16\u8F91\u5668 +settings.editor.prio.text_first=\u4F18\u5148\u4F7F\u7528\u6587\u672C\u7F16\u8F91\u5668 +settings.editor.prio.text_only=\u4EC5\u4F7F\u7528\u6587\u672C\u7F16\u8F91\u5668 +show.info.balloon=\u663E\u793A\u4FE1\u606F\u6C14\u6CE1 +table.editor=\u8868\u683C\u7F16\u8F91\u5668 +text.editor=\u6587\u672C\u7F16\u8F91\u5668 +use.soft.wraps=\u4F7F\u7528\u8F6F\u6362\u884C +value.coloring=\u503C\u7740\u8272\uFF1A +zero.based=\u4ECE0\u5F00\u59CB \ No newline at end of file From 9fbf811bdd9936ff45998df80af84c17a8a6eb3b Mon Sep 17 00:00:00 2001 From: CJYKK <2159913864@qq.com> Date: Wed, 1 Jan 2025 21:07:34 +0800 Subject: [PATCH 03/13] Chore: Simplified Chinese translation --- .../CsvValidation_zh_CN.html | 2 +- .../QuoteAll/description_zh_CN.html | 2 +- .../QuoteValue/description_zh_CN.html | 5 + .../ShiftColumnLeft/description_zh_CN.html | 5 + .../ShiftColumnRight/description_zh_CN.html | 5 + .../UnquoteAll/description_zh_CN.html | 5 + .../UnquoteValue/description_zh_CN.html | 5 + .../CsvEditorActions_zh_CN.properties | 41 +++---- .../CsvEditorResources_zh_CN.properties | 102 +++++++++--------- 9 files changed, 99 insertions(+), 73 deletions(-) create mode 100644 src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html create mode 100644 src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html diff --git a/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html b/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html index 8827be73..6dc2d4d9 100644 --- a/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html +++ b/src/main/resources/inspectionDescriptions/CsvValidation_zh_CN.html @@ -1,5 +1,5 @@ -Suggests possible fixes for CSV validation errors.[zh_CN] +对 CSV 验证错误提出可能的修复建议。 \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html b/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html index 87f1fc12..37e33b55 100644 --- a/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html +++ b/src/main/resources/intentionDescriptions/QuoteAll/description_zh_CN.html @@ -1,5 +1,5 @@ -This intention quotes all values.[zh_CN]
+此操作会为所有值添加引号。
\ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html b/src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html new file mode 100644 index 00000000..cd69c2ce --- /dev/null +++ b/src/main/resources/intentionDescriptions/QuoteValue/description_zh_CN.html @@ -0,0 +1,5 @@ + + +为未添加引号的值添加引号。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html b/src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html new file mode 100644 index 00000000..f3619710 --- /dev/null +++ b/src/main/resources/intentionDescriptions/ShiftColumnLeft/description_zh_CN.html @@ -0,0 +1,5 @@ + + +将列左移并交换位置。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html b/src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html new file mode 100644 index 00000000..c01fc6fd --- /dev/null +++ b/src/main/resources/intentionDescriptions/ShiftColumnRight/description_zh_CN.html @@ -0,0 +1,5 @@ + + +将列右移并交换位置。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html b/src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html new file mode 100644 index 00000000..96553972 --- /dev/null +++ b/src/main/resources/intentionDescriptions/UnquoteAll/description_zh_CN.html @@ -0,0 +1,5 @@ + + +尽可能地移除所有值的引号。
+ + \ No newline at end of file diff --git a/src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html b/src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html new file mode 100644 index 00000000..056c87da --- /dev/null +++ b/src/main/resources/intentionDescriptions/UnquoteValue/description_zh_CN.html @@ -0,0 +1,5 @@ + + +移除已有引号的值的引号。
+ + \ No newline at end of file diff --git a/src/main/resources/localization/CsvEditorActions_zh_CN.properties b/src/main/resources/localization/CsvEditorActions_zh_CN.properties index 53c25c5b..b895a81e 100644 --- a/src/main/resources/localization/CsvEditorActions_zh_CN.properties +++ b/src/main/resources/localization/CsvEditorActions_zh_CN.properties @@ -1,20 +1,21 @@ -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.text=New Column Before (Ctrl+Shift+Left)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.description=New column before (ctrl+shift+left)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.text=New Column After (Ctrl+Shift+Right)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.description=New column after (ctrl+shift+right)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.text=Delete Selected Columns (Ctrl+Shift+Del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.description=Delete selected columns (ctrl+shift+del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.text=New Row Before (Ctrl+Up)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.description=New row before (ctrl+up)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.text=New Row After (Ctrl+Down)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.description=New row after (ctrl+down)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.text=Delete Selected Rows (Ctrl+Del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.description=Delete selected rows (ctrl+del)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.text=Auto-Fit Columns Width (Ctrl+Shift+Space)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.description=Auto-fit columns width (ctrl+shift+space)[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.text=Reset Columns Width to Default[zh_CN] -action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.description=Reset columns width to default[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.text=CSV Separator[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.description=CSV separator[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.text=CSV Escape Character[zh_CN] -group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.description=CSV escape character[zh_CN] \ No newline at end of file +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.text=\u5728\u5DE6\u4FA7\u65B0\u589E\u5217 (Ctrl+Shift+Left) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnBefore.description=\u5728\u5DE6\u4FA7\u65B0\u589E\u4E00\u5217 (ctrl+shift+left) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.text=\u5728\u53F3\u4FA7\u65B0\u589E\u5217 (Ctrl+Shift+Right) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddColumnAfter.description=\u5728\u53F3\u4FA7\u65B0\u589E\u4E00\u5217 (ctrl+shift+right) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.text=\u5220\u9664\u9009\u4E2D\u7684\u5217 (Ctrl+Shift+Del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedColumns.description=\u5220\u9664\u9009\u4E2D\u7684\u5217 (ctrl+shift+del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.text=\u5728\u4E0A\u65B9\u65B0\u589E\u884C (Ctrl+Up) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowBefore.description=\u5728\u4E0A\u65B9\u65B0\u589E\u4E00\u884C (ctrl+up) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.text=\u5728\u4E0B\u65B9\u65B0\u589E\u884C (Ctrl+Down) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AddRowAfter.description=\u5728\u4E0B\u65B9\u65B0\u589E\u4E00\u884C (ctrl+down) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.text=\u5220\u9664\u9009\u4E2D\u7684\u884C (Ctrl+Del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$DeleteSelectedRows.description=\u5220\u9664\u9009\u4E2D\u7684\u884C (ctrl+del) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.text=\u81EA\u52A8\u8C03\u6574\u5217\u5BBD (Ctrl+Shift+Space) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$AdjustColumnWidths.description=\u81EA\u52A8\u8C03\u6574\u5217\u5BBD (ctrl+shift+space) +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.text=\u91CD\u7F6E\u5217\u5BBD\u4E3A\u9ED8\u8BA4\u503C +action.net.seesharpsoft.intellij.plugins.csv.actions.CsvTableEditorActions$ResetColumnWidths.description=\u91CD\u7F6E\u5217\u5BBD\u4E3A\u9ED8\u8BA4\u503C + +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.text=CSV \u5206\u9694\u7B26 +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeSeparatorActionGroup.description=CSV \u5206\u9694\u7B26 +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.text=CSV \u8F6C\u4E49\u5B57\u7B26 +group.net.seesharpsoft.intellij.plugins.csv.actions.CsvChangeEscapeCharacterActionGroup.description=CSV \u8F6C\u4E49\u5B57\u7B26 \ No newline at end of file diff --git a/src/main/resources/localization/CsvEditorResources_zh_CN.properties b/src/main/resources/localization/CsvEditorResources_zh_CN.properties index 78cf3d73..7f792dca 100644 --- a/src/main/resources/localization/CsvEditorResources_zh_CN.properties +++ b/src/main/resources/localization/CsvEditorResources_zh_CN.properties @@ -1,51 +1,51 @@ -auto.detect.initially=auto-detect initially[zh_CN] -can.be.adjusted.per.file.in.editor.context.menu=Can be adjusted per file in editor context menu[zh_CN] -color.attribute.separator=Separator[zh_CN] -color.attribute.quote=Quote[zh_CN] -color.attribute.text=Text[zh_CN] -color.attribute.text.escaped=Escaped text[zh_CN] -color.attribute.comment=Comment[zh_CN] -color.attribute.column.nr=Column Color %d[zh_CN] -column.numbering=Column numbering:[zh_CN] -default.column.width.in.px=Default column width in px (10 - 10000):[zh_CN] -default.escape.character=Default Escape Character:[zh_CN] -default.row.height.in.px=Default row height in px (20-100):[zh_CN] -default.value.separator.csv.only=Default Value Separator (CSV only):[zh_CN] -editor.usage=Editor usage:[zh_CN] -enforce.value.quoting=Enforce value quoting[zh_CN] -error.while.parsing.content.please.fix.issues.in.text.editor=\ Error while parsing content - please fix issues in text editor![zh_CN] -general=General[zh_CN] -group.separator=Separator[zh_CN] -group.separator.space.before=Space before separator[zh_CN] -group.separator.space.after=Space after separator[zh_CN] -group.tabularize=Tabularize[zh_CN] -group.tabularize.as.table=Format as table[zh_CN] -group.tabularize.keep.quoted=Keep quoted value as is[zh_CN] -group.tabularize.align.right=Align right[zh_CN] -group.tabularize.enhanced.width.calculation=Enhanced width calculation (slower)[zh_CN] -group.trimming=Trimming (only if not tabularized)[zh_CN] -group.trimming.leading=Trim leading whitespaces[zh_CN] -group.trimming.trailing=Trim trailing whitespaces[zh_CN] -highlight.caret.row=Highlight caret row[zh_CN] -highlighting=Highlighting[zh_CN] -keep.trailing.whitespaces.if.unchecked.general.editor.setting.apply=Keep trailing whitespaces (if unchecked, general editor setting apply)[zh_CN] -line.comment.indicator=Line comment indicator:[zh_CN] -maximum.column.width.in.px=Maximum column width in px (0 = no maximum):[zh_CN] -open.file.in.text.editor=Open file in text editor[zh_CN] -others=Others[zh_CN] -settings.title=CSV/TSV/PSV[zh_CN] -settings.codestyle.spaces=Spaces[zh_CN] -settings.codestyle.wrapping=Wrapping[zh_CN] -settings.editor.coloring.rainbow=Rainbow (Column Color)[zh_CN] -settings.editor.coloring.simple=Simple (Text Color)[zh_CN] -settings.editor.help=Editor Options for CSV/TSV/PSV files[zh_CN] -settings.editor.highlight.tab.separator=Highlight tab separator [zh_CN] -settings.editor.prio.table_first=Table editor first[zh_CN] -settings.editor.prio.text_first=Text editor first[zh_CN] -settings.editor.prio.text_only=Text editor only[zh_CN] -show.info.balloon=Show info balloon[zh_CN] -table.editor=Table Editor[zh_CN] -text.editor=Text Editor[zh_CN] -use.soft.wraps=Use soft wraps[zh_CN] -value.coloring=Value Coloring:[zh_CN] -zero.based=Zero-based[zh_CN] \ No newline at end of file +auto.detect.initially=\u52A0\u8F7D\u6587\u4EF6\u65F6\u81EA\u52A8\u68C0\u6D4B +can.be.adjusted.per.file.in.editor.context.menu=\u53EF\u4EE5\u5728\u7F16\u8F91\u5668\u7684\u4E0A\u4E0B\u6587\u83DC\u5355\u4E2D\u6309\u6587\u4EF6\u8C03\u6574 +color.attribute.separator=\u5206\u9694\u7B26 +color.attribute.quote=\u5F15\u53F7 +color.attribute.text=\u6587\u672C +color.attribute.text.escaped=\u8F6C\u4E49\u6587\u672C +color.attribute.comment=\u6CE8\u91CA +color.attribute.column.nr=\u5217\u989C\u8272 %d +column.numbering=\u5217\u7F16\u53F7\uFF1A +default.column.width.in.px=\u9ED8\u8BA4\u5217\u5BBD\uFF0810 ~ 10000\u50CF\u7D20\uFF09\uFF1A +default.escape.character=\u9ED8\u8BA4\u8F6C\u4E49\u5B57\u7B26\uFF1A +default.row.height.in.px=\u9ED8\u8BA4\u884C\u9AD8\uFF0820 ~ 100\u50CF\u7D20\uFF09\uFF1A +default.value.separator.csv.only=\u9ED8\u8BA4\u503C\u5206\u9694\u7B26\uFF08\u4EC5\u9002\u7528\u4E8ECSV\uFF09\uFF1A +editor.usage=\u7F16\u8F91\u5668\u7528\u6CD5\uFF1A +enforce.value.quoting=\u5F3A\u5236\u4E3A\u503C\u6DFB\u52A0\u5F15\u53F7 +error.while.parsing.content.please.fix.issues.in.text.editor=\ \u89E3\u6790\u5185\u5BB9\u65F6\u51FA\u9519 - \u8BF7\u5728\u6587\u672C\u7F16\u8F91\u5668\u4E2D\u4FEE\u590D\u95EE\u9898\uFF01 +general=\u5E38\u89C4 +group.separator=\u5206\u9694\u7B26 +group.separator.space.before=\u5728\u5206\u9694\u7B26\u524D\u6DFB\u52A0\u7A7A\u683C +group.separator.space.after=\u5728\u5206\u9694\u7B26\u540E\u6DFB\u52A0\u7A7A\u683C +group.tabularize=\u5236\u8868 +group.tabularize.as.table=\u683C\u5F0F\u5316\u4E3A\u8868\u683C +group.tabularize.keep.quoted=\u4FDD\u6301\u5F15\u7528\u503C\u4E0D\u53D8 +group.tabularize.align.right=\u53F3\u5BF9\u9F50 +group.tabularize.enhanced.width.calculation=\u589E\u5F3A\u5BBD\u5EA6\u8BA1\u7B97\uFF08\u8F83\u6162\uFF09 +group.trimming=\u4FEE\u526A\uFF08\u4EC5\u5F53\u672A\u5236\u8868\u65F6\uFF09 +group.trimming.leading=\u4FEE\u526A\u524D\u5BFC\u7A7A\u683C +group.trimming.trailing=\u4FEE\u526A\u5C3E\u968F\u7A7A\u683C +highlight.caret.row=\u9AD8\u4EAE\u5149\u6807\u884C +highlighting=\u9AD8\u4EAE +keep.trailing.whitespaces.if.unchecked.general.editor.setting.apply=\u4FDD\u7559\u5C3E\u968F\u7A7A\u683C\uFF08\u82E5\u672A\u9009\u4E2D\uFF0C\u5219\u4F7F\u7528\u901A\u7528\u7F16\u8F91\u5668\u8BBE\u7F6E\uFF09 +line.comment.indicator=\u884C\u6CE8\u91CA\u6307\u793A\u7B26\uFF1A +maximum.column.width.in.px=\u6700\u5927\u5217\u5BBD\uFF08\u50CF\u7D20\uFF0C0 = \u65E0\u9650\u5236\uFF09: +open.file.in.text.editor=\u5728\u6587\u672C\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\u6587\u4EF6 +others=\u5176\u4ED6 +settings.title=CSV/TSV/PSV +settings.codestyle.spaces=\u7A7A\u683C +settings.codestyle.wrapping=\u6362\u884C +settings.editor.coloring.rainbow=\u5F69\u8679\uFF08\u5217\u989C\u8272\uFF09 +settings.editor.coloring.simple=\u7B80\u5355\uFF08\u6587\u672C\u989C\u8272\uFF09 +settings.editor.help=CSV/TSV/PSV\u6587\u4EF6\u7684\u7F16\u8F91\u5668\u9009\u9879 +settings.editor.highlight.tab.separator=\u9AD8\u4EAE\u5236\u8868\u7B26\u5206\u9694\u7B26 +settings.editor.prio.table_first=\u4F18\u5148\u4F7F\u7528\u8868\u683C\u7F16\u8F91\u5668 +settings.editor.prio.text_first=\u4F18\u5148\u4F7F\u7528\u6587\u672C\u7F16\u8F91\u5668 +settings.editor.prio.text_only=\u4EC5\u4F7F\u7528\u6587\u672C\u7F16\u8F91\u5668 +show.info.balloon=\u663E\u793A\u4FE1\u606F\u6C14\u6CE1 +table.editor=\u8868\u683C\u7F16\u8F91\u5668 +text.editor=\u6587\u672C\u7F16\u8F91\u5668 +use.soft.wraps=\u4F7F\u7528\u8F6F\u6362\u884C +value.coloring=\u503C\u7740\u8272\uFF1A +zero.based=\u4ECE0\u5F00\u59CB \ No newline at end of file From 36ba098bb6ac185ced14a9082cf477cdd119a8d3 Mon Sep 17 00:00:00 2001 From: Cole Leavitt Date: Fri, 22 Aug 2025 14:18:02 -0700 Subject: [PATCH 04/13] Fix PSI access threading issues in CsvTableModelSwing --- .../table/swing/CsvTableModelSwing.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java index a3423b62..72020353 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java @@ -1,6 +1,7 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.swing; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiElement; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.editor.table.CsvTableEditor; @@ -25,12 +26,9 @@ public class CsvTableModelSwing extends CsvTableModelBase implements TableModel { - /** - * List of listeners - */ protected EventListenerList listenerList = new EventListenerList(); - protected ScheduledFuture delayedUpdate; + protected ScheduledFuture delayedUpdate; protected ScheduledExecutorService executorService; @@ -64,10 +62,7 @@ private void doNotifyUpdate() { } protected void fireTableChanged(TableModelEvent e) { - // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); - // Process the listeners last to first, notifying - // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TableModelListener.class) { ((TableModelListener) listeners[i + 1]).tableChanged(e); @@ -97,17 +92,17 @@ public void removeTableModelListener(TableModelListener l) { @Override public String getColumnName(int column) { - PsiElement headerField = PsiHelper.findFirst(getPsiFile(), CsvTypes.FIELD); - if (headerField != null) { - headerField = PsiHelper.getNextNthSiblingOfType(headerField, column, CsvField.class); - } - String headerText = headerField == null ? "" : CsvHelper.unquoteCsvValue(headerField.getText(), getEscapeCharacter()).trim(); - - Map params = new HashMap<>(); - params.put("header", headerText); - params.put("index", CsvEditorSettings.getInstance().isZeroBasedColumnNumbering() ? column : column + 1); - - return CsvHelper.formatString("${header} (${index})", params); + return ApplicationManager.getApplication().runReadAction((Computable) () -> { + PsiElement headerField = PsiHelper.findFirst(getPsiFile(), CsvTypes.FIELD); + if (headerField != null) { + headerField = PsiHelper.getNextNthSiblingOfType(headerField, column, CsvField.class); + } + String headerText = headerField == null ? "" : CsvHelper.unquoteCsvValue(headerField.getText(), getEscapeCharacter()).trim(); + Map params = new HashMap<>(); + params.put("header", headerText); + params.put("index", CsvEditorSettings.getInstance().isZeroBasedColumnNumbering() ? column : column + 1); + return CsvHelper.formatString("${header} (${index})", params); + }); } @Override From 5f59e72d27ab739a2f68087b75d94ac33f19bef1 Mon Sep 17 00:00:00 2001 From: Cole Leavitt Date: Fri, 22 Aug 2025 14:38:29 -0700 Subject: [PATCH 05/13] CsvTableModelSwing: add docstring for getColumnName and add back in original comments --- .../csv/editor/table/swing/CsvTableModelSwing.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java index 72020353..df367b84 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableModelSwing.java @@ -26,6 +26,9 @@ public class CsvTableModelSwing extends CsvTableModelBase implements TableModel { + /** + * List of listeners + */ protected EventListenerList listenerList = new EventListenerList(); protected ScheduledFuture delayedUpdate; @@ -62,7 +65,10 @@ private void doNotifyUpdate() { } protected void fireTableChanged(TableModelEvent e) { + // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); + // Process the listeners last to first, notifying + // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TableModelListener.class) { ((TableModelListener) listeners[i + 1]).tableChanged(e); @@ -90,6 +96,10 @@ public void removeTableModelListener(TableModelListener l) { listenerList.remove(TableModelListener.class, l); } + /** + * Gets header name for a given column, with index formatting. + * PSI access is wrapped in a read action for thread safety. + */ @Override public String getColumnName(int column) { return ApplicationManager.getApplication().runReadAction((Computable) () -> { @@ -114,4 +124,4 @@ public Class getColumnClass(int columnIndex) { public boolean isCellEditable(int rowIndex, int columnIndex) { return getPsiFileHolder().isEditable(); } -} +} \ No newline at end of file From 6e764845bc1f070992a4cc3ef7e3fab39339c119 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sat, 1 Feb 2025 18:27:49 -0500 Subject: [PATCH 06/13] Fix: Access is allowed with explicit read lock #898 #901 --- .../csv/editor/table/CsvTableEditor.java | 12 +++---- .../plugins/csv/psi/CsvPsiTreeUpdater.java | 33 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java index 61a9f71b..d16c5d6e 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java @@ -2,6 +2,7 @@ import com.intellij.ide.structureView.StructureViewBuilder; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorFontType; @@ -213,12 +214,11 @@ public final CsvFile getCsvFile() { return null; } if (this.psiFile == null || !this.psiFile.isValid()) { - this.document = FileDocumentManager.getInstance().getDocument(this.file); - - PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); - - this.psiFile = documentManager.getPsiFile(this.document); - + this.psiFile = ReadAction.compute(() -> { + this.document = FileDocumentManager.getInstance().getDocument(this.file); + PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); + return documentManager.getPsiFile(this.document); + }); this.currentSeparator = CsvHelper.getValueSeparator(this.psiFile); this.currentEscapeCharacter = CsvHelper.getEscapeCharacter(this.psiFile); } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiTreeUpdater.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiTreeUpdater.java index 6ee85fe1..d78b55c0 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiTreeUpdater.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiTreeUpdater.java @@ -1,6 +1,7 @@ package net.seesharpsoft.intellij.plugins.csv.psi; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileTypes.FileType; @@ -515,27 +516,25 @@ private static class DocumentPsiAction extends PsiAction { @Override public void execute() { - ApplicationManager.getApplication().runWriteAction( - () -> { - PsiFile psiFile = (PsiFile) getAnchor(); + WriteAction.run(() -> { + PsiFile psiFile = (PsiFile) getAnchor(); - PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject()); - Document document = manager.getDocument(psiFile); - if (document == null) return; + PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject()); + Document document = manager.getDocument(psiFile); + if (document == null) return; - manager.doPostponedOperationsAndUnblockDocument(document); + manager.doPostponedOperationsAndUnblockDocument(document); - int offset = 0; - for (Pair replacement : myReplacements) { - TextRange textRange = replacement.getFirst().shiftRight(offset); - String text = replacement.getSecond(); - document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), text); - offset += text.length() - textRange.getLength(); - } + int offset = 0; + for (Pair replacement : myReplacements) { + TextRange textRange = replacement.getFirst().shiftRight(offset); + String text = replacement.getSecond(); + document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), text); + offset += text.length() - textRange.getLength(); + } - manager.commitDocument(document); - } - ); + manager.commitDocument(document); + }); } } } From 8d1b8e1c169f1880fc8dba5d72fc5dce6f137876 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 12:08:31 -0400 Subject: [PATCH 07/13] Fix: Rework CSV file detection for FileEditorProvider java.lang.NoSuchFieldException: INSTANCE #904 --- .../intellij/plugins/csv/CsvHelper.java | 30 +++++++------------ .../csv/components/CsvFileAttributes.java | 6 ++-- .../csv/editor/CsvFileEditorProvider.java | 2 +- src/main/resources/META-INF/plugin.xml | 10 +++++-- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java index 958c6be3..cbdce1ed 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java @@ -2,6 +2,7 @@ import com.intellij.lang.*; import com.intellij.lexer.Lexer; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeRegistry; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; @@ -51,32 +52,21 @@ public static PsiElement createEmptyCsvField(PsiFile psiFile) { return node.getPsi(); } - public static boolean isCsvFile(String extension) { - if (extension == null) { - return false; - } - Language language = LanguageUtil.getFileTypeLanguage( - FileTypeRegistry.getInstance().getFileTypeByExtension(extension) - ); + public static boolean isCsvFile(FileType fileType) { + Language language = LanguageUtil.getFileTypeLanguage(fileType); return language != null && language.isKindOf(CsvLanguage.INSTANCE); } - public static boolean isCsvFile(Project project, VirtualFile file) { - if (file == null) { - return false; - } - if (project == null) { - return isCsvFile(file.getExtension()); - } - final Language language = LanguageUtil.getLanguageForPsi(project, file); - return language != null && language.isKindOf(CsvLanguage.INSTANCE); + public static boolean isCsvFile(String extension) { + return extension != null && isCsvFile(FileTypeRegistry.getInstance().getFileTypeByExtension(extension)); + } + + public static boolean isCsvFile(VirtualFile file) { + return file != null && isCsvFile(file.getFileType()); } public static boolean isCsvFile(PsiFile file) { - if (file == null) { - return false; - } - return isCsvFile(file.getProject(), getVirtualFile(file)); + return file != null && isCsvFile(getVirtualFile(file)); } public static boolean isCommentElement(PsiElement element) { diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java index 7b17649d..508ac267 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java @@ -83,7 +83,7 @@ private synchronized Attribute getFileAttribute(@NotNull Project project, @NotNu Attribute attribute = attributeMap.get(key); if (attribute == null && createIfMissing) { attribute = new Attribute(); - if (!CsvHelper.isCsvFile(project, virtualFile)) { + if (!CsvHelper.isCsvFile(virtualFile)) { LOG.error("CSV file attribute requested for non CSV file: " + virtualFile.toString()); } else { attributeMap.put(key, attribute); @@ -167,7 +167,7 @@ private CsvValueSeparator autoDetectSeparator(Project project, VirtualFile virtu @NotNull public CsvValueSeparator getValueSeparator(Project project, VirtualFile virtualFile) { - if (!CsvHelper.isCsvFile(project, virtualFile)) { + if (!CsvHelper.isCsvFile(virtualFile)) { return CsvEditorSettings.getInstance().getDefaultValueSeparator(); } FileType fileType = virtualFile.getFileType(); @@ -207,7 +207,7 @@ public void resetEscapeSeparator(@NotNull PsiFile psiFile) { @NotNull public CsvEscapeCharacter getEscapeCharacter(Project project, VirtualFile virtualFile) { - if (!CsvHelper.isCsvFile(project, virtualFile)) { + if (!CsvHelper.isCsvFile(virtualFile)) { return CsvEditorSettings.getInstance().getDefaultEscapeCharacter(); } FileType fileType = virtualFile.getFileType(); diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorProvider.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorProvider.java index 76c961f2..cbace8ba 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorProvider.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorProvider.java @@ -22,7 +22,7 @@ public static boolean acceptCsvFile(@NotNull Project project, @NotNull VirtualFi return !SingleRootFileViewProvider.isTooLargeForContentLoading(file) && !SingleRootFileViewProvider.isTooLargeForIntelligence(file) && !(file instanceof DiffViewerVirtualFile) - && CsvHelper.isCsvFile(project, file); + && CsvHelper.isCsvFile(file); } catch(Exception exc) { return false; } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 47b3b07e..35de7398 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -49,9 +49,9 @@ org.jetbrains.plugins.github - - - + + + @@ -60,6 +60,10 @@ implementationClass="net.seesharpsoft.intellij.plugins.csv.highlighter.CsvSyntaxHighlighterFactory"/> + + From 30d7fae1a034ac099d5522439b3db6ff2536c908 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 12:22:39 -0400 Subject: [PATCH 08/13] Fix: Legacy configurable id calculation mode from localizable name will be used for configurable class CsvCodeStyleSettingsProvider. Please override getConfigurableId or getLanguage. #909 --- .../plugins/csv/settings/CsvCodeStyleSettingsProvider.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java index ef75f206..9bb5aeb1 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java @@ -4,6 +4,7 @@ import com.intellij.application.options.CodeStyleAbstractPanel; import com.intellij.application.options.IndentOptionsEditor; import com.intellij.application.options.TabbedLanguageCodeStylePanel; +import com.intellij.lang.Language; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.*; @@ -41,6 +42,11 @@ public String getHelpTopic() { }; } + @Override + public Language getLanguage() { + return CsvLanguage.INSTANCE; + } + private static class CsvCodeStyleMainPanel extends TabbedLanguageCodeStylePanel { CsvCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) { super(CsvLanguage.INSTANCE, currentSettings, settings); From 24ebb46361a944bd3e747a5d10f36e876f930f87 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 17:51:44 -0400 Subject: [PATCH 09/13] Chore: Project structure refactoring to avoid circular dependencies --- .../intellij/plugins/csv/CsvHelper.java | 7 +- .../intellij/plugins/csv/CsvLexer.flex | 5 +- .../intellij/plugins/csv/CsvLexerAdapter.java | 3 + .../intellij/plugins/csv/CsvLexerFactory.java | 6 +- .../intellij/plugins/csv/CsvPlugin.java | 39 +------ .../plugins/csv/CsvPluginManager.java | 39 +++++++ .../intellij/plugins/csv/CsvSharpLexer.java | 2 + .../CsvChangeEscapeCharacterAction.java | 2 +- .../CsvChangeEscapeCharacterActionGroup.java | 2 +- .../csv/actions/CsvChangeSeparatorAction.java | 4 +- .../CsvChangeSeparatorActionGroup.java | 2 +- .../csv/actions/CsvCustomSeparatorAction.java | 2 +- .../{ => components}/CsvEscapeCharacter.java | 2 +- .../CsvEscapeCharacterHolder.java | 2 +- .../csv/components/CsvFileAttributes.java | 4 +- .../{ => components}/CsvSeparatorHolder.java | 2 +- .../{ => components}/CsvValueSeparator.java | 2 +- .../plugins/csv/editor/CsvAnnotator.java | 2 +- .../csv/editor/table/CsvTableEditor.java | 4 +- .../csv/editor/table/CsvTableEditorState.java | 1 - .../csv/editor/table/CsvTableModelBase.java | 2 +- .../table/swing/CsvMultiLineCellRenderer.java | 6 +- .../highlighter/CsvHighlightingElement.java | 19 ++-- .../csv/highlighter/CsvTextAttributeKeys.java | 107 ++++++++++++++++++ .../inspection/CsvValidationInspection.java | 2 +- .../CsvShiftColumnIntentionAction.java | 2 +- .../plugins/csv/psi/CsvPsiParserFileType.java | 4 + .../CsvCodeStyleSettingsProvider.java | 9 +- .../csv/settings/CsvColorSettings.java | 101 +---------------- .../csv/settings/CsvEditorSettings.java | 17 +-- .../settings/CsvEditorSettingsProvider.java | 13 ++- .../CsvLanguageCodeStyleSettingsProvider.java | 5 +- .../intellij/plugins/psv/PsvFileType.java | 4 +- .../intellij/plugins/tsv/TsvFileType.java | 4 +- .../intellij/plugins/csv/CsvHelperTest.java | 2 + .../CsvChangeEscapeCharacterActionTest.java | 2 +- .../actions/CsvChangeSeparatorActionTest.java | 2 +- .../csv/components/CsvFileAttributesTest.java | 1 - .../editor/table/CsvTableModelBaseTest.java | 2 +- .../table/CsvTableModelCustomizedTest.java | 4 +- .../csv/intention/CsvIntentionTest.java | 2 +- .../plugins/csv/parser/CsvParsingTest.java | 4 +- .../CsvEditorSettingsProviderTest.java | 4 +- 43 files changed, 242 insertions(+), 208 deletions(-) create mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPluginManager.java rename src/main/java/net/seesharpsoft/intellij/plugins/csv/{ => components}/CsvEscapeCharacter.java (98%) rename src/main/java/net/seesharpsoft/intellij/plugins/csv/{ => components}/CsvEscapeCharacterHolder.java (61%) rename src/main/java/net/seesharpsoft/intellij/plugins/csv/{ => components}/CsvSeparatorHolder.java (57%) rename src/main/java/net/seesharpsoft/intellij/plugins/csv/{ => components}/CsvValueSeparator.java (98%) create mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvTextAttributeKeys.java diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java index cbdce1ed..5a81910d 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java @@ -16,7 +16,9 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import net.seesharpsoft.intellij.lang.FileParserDefinition; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.psi.CsvField; import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile; import net.seesharpsoft.intellij.plugins.csv.psi.CsvRecord; @@ -25,10 +27,7 @@ import net.seesharpsoft.intellij.psi.PsiHelper; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexer.flex b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexer.flex index 3d2e1301..3f8cce89 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexer.flex +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexer.flex @@ -1,10 +1,11 @@ package net.seesharpsoft.intellij.plugins.csv; import com.intellij.psi.tree.IElementType; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes; -import com.intellij.psi.TokenType; import com.intellij.lexer.FlexLexer; -import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; %% diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerAdapter.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerAdapter.java index 81bc23d7..c18bdafd 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerAdapter.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerAdapter.java @@ -1,6 +1,9 @@ package net.seesharpsoft.intellij.plugins.csv; import com.intellij.lexer.FlexAdapter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; public class CsvLexerAdapter extends FlexAdapter implements CsvSeparatorHolder { diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerFactory.java index ddf086b9..f8b3b598 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerFactory.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvLexerFactory.java @@ -4,11 +4,11 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; import org.jetbrains.annotations.NotNull; -import static net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings.COMMENT_INDICATOR_DEFAULT; - public class CsvLexerFactory { protected static CsvLexerFactory INSTANCE = new CsvLexerFactory(); @@ -20,7 +20,7 @@ protected Lexer createLexer(@NotNull CsvValueSeparator separator, @NotNull CsvEs final String commentIndicator = CsvEditorSettings.getInstance().getCommentIndicator(); if (separator.requiresCustomLexer() || escapeCharacter.isCustom() || - (!commentIndicator.isEmpty() && !commentIndicator.equals(COMMENT_INDICATOR_DEFAULT))) { + (!commentIndicator.isEmpty() && !commentIndicator.equals(CsvEditorSettings.COMMENT_INDICATOR_DEFAULT))) { return new CsvSharpLexer(new CsvSharpLexer.Configuration( separator.getCharacter(), "\n", diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java index f4bcb690..4810f928 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java @@ -1,12 +1,8 @@ package net.seesharpsoft.intellij.plugins.csv; -import com.intellij.DynamicBundle; import com.intellij.ide.BrowserUtil; import com.intellij.ide.actions.ShowSettingsUtilImpl; -import com.intellij.ide.plugins.IdeaPluginDescriptor; -import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.notification.*; -import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; @@ -21,24 +17,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ResourceBundle; - public class CsvPlugin implements ProjectActivity, DumbAware { - private static ResourceBundle _resourceBundle; - - protected static IdeaPluginDescriptor getPluginDescriptor() { - return PluginManagerCore.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv")); - } - - protected static String getVersion() { - return getPluginDescriptor().getVersion(); - } - - protected static String getChangeNotes() { - return getPluginDescriptor().getChangeNotes(); - } - private static void openLink(Project project, String link) { if (project.isDisposed()) return; @@ -79,13 +59,13 @@ public void run(@NotNull ProgressIndicator progressIndicator) { doAsyncProjectMaintenance(project); NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("net.seesharpsoft.intellij.plugins.csv"); - if (notificationGroup == null || CsvEditorSettings.getInstance().checkCurrentPluginVersion(getVersion())) { + if (notificationGroup == null || CsvEditorSettings.getInstance().checkCurrentPluginVersion(CsvPluginManager.getVersion())) { return continuation; } Notification notification = notificationGroup.createNotification( - "CSV Editor " + getVersion() + " - Change Notes", - getChangeNotes() + + "CSV Editor " + CsvPluginManager.getVersion() + " - Change Notes", + CsvPluginManager.getChangeNotes() + "

You can always customize plugin settings to your likings (shortcuts below)!

" + "
" + "

Visit the CSV Editor homepage to read more about the available features & settings, " + @@ -112,17 +92,4 @@ public void run(@NotNull ProgressIndicator progressIndicator) { return continuation; } - - public static ResourceBundle getResourceBundle() { - if (_resourceBundle == null) { - _resourceBundle = DynamicBundle.getPluginBundle(getPluginDescriptor()); - } - return _resourceBundle; - } - - public static String getLocalizedText(String token) { - return getResourceBundle().getString(token); - } - - } \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPluginManager.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPluginManager.java new file mode 100644 index 00000000..4eb3d2c8 --- /dev/null +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPluginManager.java @@ -0,0 +1,39 @@ +package net.seesharpsoft.intellij.plugins.csv; + +import com.intellij.DynamicBundle; +import com.intellij.ide.plugins.IdeaPluginDescriptor; +import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.openapi.extensions.PluginId; + +import java.util.ResourceBundle; + +public final class CsvPluginManager { + private static ResourceBundle _resourceBundle; + + public static ResourceBundle getResourceBundle() { + if (_resourceBundle == null) { + _resourceBundle = DynamicBundle.getPluginBundle(getPluginDescriptor()); + } + return _resourceBundle; + } + + public static String getLocalizedText(String token) { + return getResourceBundle().getString(token); + } + + public static IdeaPluginDescriptor getPluginDescriptor() { + return PluginManagerCore.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv")); + } + + public static String getVersion() { + return getPluginDescriptor().getVersion(); + } + + public static String getChangeNotes() { + return getPluginDescriptor().getChangeNotes(); + } + + private CsvPluginManager() { + // static + } +} diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSharpLexer.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSharpLexer.java index 70ff0fc0..0b00e4b4 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSharpLexer.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSharpLexer.java @@ -4,6 +4,8 @@ import com.intellij.psi.tree.IElementType; import net.seesharpsoft.UnhandledSwitchCaseException; import net.seesharpsoft.commons.util.Tokenizer; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterAction.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterAction.java index 37ef53db..c1a00086 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterAction.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterAction.java @@ -4,7 +4,7 @@ import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.psi.PsiFile; import com.intellij.util.FileContentUtilCore; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionGroup.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionGroup.java index 761412b1..dc45ee50 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionGroup.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionGroup.java @@ -2,7 +2,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.psi.PsiFile; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorAction.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorAction.java index 97f80411..75364a2f 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorAction.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorAction.java @@ -6,8 +6,8 @@ import com.intellij.psi.PsiFile; import com.intellij.util.FileContentUtilCore; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionGroup.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionGroup.java index 17a18567..562790f7 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionGroup.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionGroup.java @@ -3,7 +3,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.psi.PsiFile; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvCustomSeparatorAction.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvCustomSeparatorAction.java index cfdb1177..c2ba4d8b 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvCustomSeparatorAction.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvCustomSeparatorAction.java @@ -5,7 +5,7 @@ import com.intellij.psi.PsiFile; import com.intellij.util.FileContentUtilCore; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.components.CsvFileAttributes; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacter.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java similarity index 98% rename from src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacter.java rename to src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java index 262abc08..f98c72d2 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacter.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java @@ -1,4 +1,4 @@ -package net.seesharpsoft.intellij.plugins.csv; +package net.seesharpsoft.intellij.plugins.csv.components; import com.intellij.util.xmlb.Converter; import com.intellij.xml.util.XmlStringUtil; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacterHolder.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacterHolder.java similarity index 61% rename from src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacterHolder.java rename to src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacterHolder.java index 19625bca..f4626a80 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvEscapeCharacterHolder.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacterHolder.java @@ -1,4 +1,4 @@ -package net.seesharpsoft.intellij.plugins.csv; +package net.seesharpsoft.intellij.plugins.csv.components; public interface CsvEscapeCharacterHolder { CsvEscapeCharacter getEscapeCharacter(); diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java index 508ac267..77ea080f 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java @@ -14,7 +14,9 @@ import com.intellij.util.xmlb.XmlSerializerUtil; import com.intellij.util.xmlb.annotations.OptionTag; import net.seesharpsoft.commons.collection.Pair; -import net.seesharpsoft.intellij.plugins.csv.*; +import net.seesharpsoft.intellij.plugins.csv.CsvHelper; +import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; +import net.seesharpsoft.intellij.plugins.csv.CsvStorageHelper; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; import net.seesharpsoft.intellij.util.StringUtils; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSeparatorHolder.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvSeparatorHolder.java similarity index 57% rename from src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSeparatorHolder.java rename to src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvSeparatorHolder.java index 0daf604d..f44bebcb 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvSeparatorHolder.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvSeparatorHolder.java @@ -1,4 +1,4 @@ -package net.seesharpsoft.intellij.plugins.csv; +package net.seesharpsoft.intellij.plugins.csv.components; public interface CsvSeparatorHolder { CsvValueSeparator getSeparator(); diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvValueSeparator.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java similarity index 98% rename from src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvValueSeparator.java rename to src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java index 083a7aa1..297eda3d 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvValueSeparator.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java @@ -1,4 +1,4 @@ -package net.seesharpsoft.intellij.plugins.csv; +package net.seesharpsoft.intellij.plugins.csv.components; import com.intellij.util.xmlb.Converter; import com.intellij.xml.util.XmlStringUtil; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java index 7efed1f5..3df77ba6 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java @@ -8,7 +8,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.xml.util.XmlStringUtil; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.psi.CsvField; import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile; import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java index d16c5d6e..a5b5dc02 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java @@ -15,9 +15,9 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.util.ui.UIUtil; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; import net.seesharpsoft.intellij.psi.PsiFileHolder; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorState.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorState.java index ff4057fe..afc09a4a 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorState.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorState.java @@ -6,7 +6,6 @@ import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.openapi.vfs.VirtualFile; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; -import org.jdom.Attribute; import org.jdom.Element; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBase.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBase.java index 76bd38c7..65b7f853 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBase.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBase.java @@ -2,7 +2,7 @@ import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.psi.CsvField; import net.seesharpsoft.intellij.plugins.csv.psi.CsvPsiTreeUpdater; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvMultiLineCellRenderer.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvMultiLineCellRenderer.java index f502aefd..74517e7f 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvMultiLineCellRenderer.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvMultiLineCellRenderer.java @@ -7,7 +7,7 @@ import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; -import net.seesharpsoft.intellij.plugins.csv.settings.CsvColorSettings; +import net.seesharpsoft.intellij.plugins.csv.highlighter.CsvTextAttributeKeys; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -48,7 +48,7 @@ public CsvMultiLineCellRenderer(CsvTableEditorKeyListener keyListener, UserDataH } protected TextAttributes getColumnTextAttributes(int column) { - return CsvColorSettings.getTextAttributesOfColumn(column, myUserDataHolder); + return CsvTextAttributeKeys.getTextAttributesOfColumn(column, myUserDataHolder); } private Color getColumnForegroundColor(int column, Color fallback) { @@ -194,7 +194,7 @@ public Comment(CsvTableEditorKeyListener keyListener, UserDataHolder userDataHol @Override protected TextAttributes getColumnTextAttributes(int column) { - return CsvColorSettings.getCommentTextAttributes(); + return CsvTextAttributeKeys.getCommentTextAttributes(); } } } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightingElement.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightingElement.java index 8f2142a4..a3bc3f20 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightingElement.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightingElement.java @@ -5,7 +5,6 @@ import com.intellij.psi.tree.IElementType; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes; -import net.seesharpsoft.intellij.plugins.csv.settings.CsvColorSettings; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -13,11 +12,11 @@ public interface CsvHighlightingElement { TextAttributesKey[] getTextAttributesKeys(); class TokenBased extends IElementType implements CsvHighlightingElement { - public static final TokenBased COMMA = new TokenBased(CsvTypes.COMMA.toString(), CsvColorSettings.COMMA); - public static final TokenBased QUOTE = new TokenBased(CsvTypes.QUOTE.toString(), CsvColorSettings.QUOTE); - public static final TokenBased TEXT = new TokenBased(CsvTypes.TEXT.toString(), CsvColorSettings.TEXT); - public static final TokenBased COMMENT = new TokenBased(CsvTypes.COMMENT.toString(), CsvColorSettings.COMMENT); - public static final TokenBased BAD_CHARACTER = new TokenBased(HighlighterColors.BAD_CHARACTER.getExternalName(), CsvColorSettings.BAD_CHARACTER); + public static final TokenBased COMMA = new TokenBased(CsvTypes.COMMA.toString(), CsvTextAttributeKeys.COMMA); + public static final TokenBased QUOTE = new TokenBased(CsvTypes.QUOTE.toString(), CsvTextAttributeKeys.QUOTE); + public static final TokenBased TEXT = new TokenBased(CsvTypes.TEXT.toString(), CsvTextAttributeKeys.TEXT); + public static final TokenBased COMMENT = new TokenBased(CsvTypes.COMMENT.toString(), CsvTextAttributeKeys.COMMENT); + public static final TokenBased BAD_CHARACTER = new TokenBased(HighlighterColors.BAD_CHARACTER.getExternalName(), CsvTextAttributeKeys.BAD_CHARACTER); private final TextAttributesKey[] myTextAttributesKeys; @@ -36,18 +35,18 @@ class ColumnBased extends TokenBased { private static final ColumnBased[] COLUMNS; static { - COLUMNS = new ColumnBased[CsvColorSettings.MAX_COLUMN_COLORING_COLORS]; - for (int i = 0; i < CsvColorSettings.MAX_COLUMN_COLORING_COLORS; ++i) { + COLUMNS = new ColumnBased[CsvTextAttributeKeys.MAX_COLUMN_COLORING_COLORS]; + for (int i = 0; i < CsvTextAttributeKeys.MAX_COLUMN_COLORING_COLORS; ++i) { COLUMNS[i] = new ColumnBased(String.format("Column %s", i), i); } } public static ColumnBased forIndex(int index) { - return COLUMNS[index % CsvColorSettings.MAX_COLUMN_COLORING_COLORS]; + return COLUMNS[index % CsvTextAttributeKeys.MAX_COLUMN_COLORING_COLORS]; } private ColumnBased(@NonNls @NotNull String debugName, int index) { - super(debugName, CsvColorSettings.getTextAttributesKeys(index)); + super(debugName, CsvTextAttributeKeys.getTextAttributesKeys(index)); } } } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvTextAttributeKeys.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvTextAttributeKeys.java new file mode 100644 index 00000000..b519620a --- /dev/null +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvTextAttributeKeys.java @@ -0,0 +1,107 @@ +package net.seesharpsoft.intellij.plugins.csv.highlighter; + +import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; +import com.intellij.openapi.editor.HighlighterColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.options.colors.AttributesDescriptor; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.UserDataHolder; +import net.seesharpsoft.UnhandledSwitchCaseException; +import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; + +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; + +import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; +import static net.seesharpsoft.intellij.plugins.csv.CsvPluginManager.getResourceBundle; + +public final class CsvTextAttributeKeys { + public static final TextAttributesKey COMMA = + createTextAttributesKey("CSV_DEFAULT_COMMA", DefaultLanguageHighlighterColors.COMMA); + public static final TextAttributesKey QUOTE = + createTextAttributesKey("CSV_DEFAULT_QUOTE", DefaultLanguageHighlighterColors.CONSTANT); + public static final TextAttributesKey TEXT = + createTextAttributesKey("CSV_DEFAULT_STRING", DefaultLanguageHighlighterColors.STRING); + public static final TextAttributesKey ESCAPED_TEXT = + createTextAttributesKey("CSV_ESCAPED_STRING", DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); + public static final TextAttributesKey COMMENT = + createTextAttributesKey("CSV_DEFAULT_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); + public static final TextAttributesKey BAD_CHARACTER = + createTextAttributesKey("CSV_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER); + + public static final Integer MAX_COLUMN_COLORING_COLORS = 10; + public static final AttributesDescriptor[] DESCRIPTORS; + private static final List COLUMN_COLORING_ATTRIBUTES; + private static final Key> COLUMN_COLORING_TEXT_ATTRIBUTES = Key.create("CSV_PLUGIN_COLUMN_COLORING_ATTRIBUTES"); + + static { + List attributesDescriptors = new ArrayList<>(); + ResourceBundle bundle = getResourceBundle(); + attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.separator"), CsvTextAttributeKeys.COMMA)); + attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.quote"), CsvTextAttributeKeys.QUOTE)); + attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.text"), CsvTextAttributeKeys.TEXT)); + attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.text.escaped"), CsvTextAttributeKeys.ESCAPED_TEXT)); + attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.comment"), CsvTextAttributeKeys.COMMENT)); + + COLUMN_COLORING_ATTRIBUTES = new ArrayList<>(); + for (int i = 0; i < MAX_COLUMN_COLORING_COLORS; ++i) { + TextAttributesKey textAttributesKey = createTextAttributesKey(String.format("CSV_PLUGIN_COLUMN_COLORING_ATTRIBUTE_%d", i), CsvTextAttributeKeys.TEXT); + COLUMN_COLORING_ATTRIBUTES.add(textAttributesKey); + attributesDescriptors.add(new AttributesDescriptor(String.format(bundle.getString("color.attribute.column.nr"), i + 1), textAttributesKey)); + } + DESCRIPTORS = attributesDescriptors.toArray(new AttributesDescriptor[0]); + } + + public static TextAttributesKey getTextAttributesKeys(int columnIndex) { + return COLUMN_COLORING_ATTRIBUTES.get(columnIndex % 10); + } + + public static TextAttributes getCommentTextAttributes() { + EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); + return editorColorsScheme.getAttributes(CsvTextAttributeKeys.COMMENT); + } + + public static TextAttributes getTextAttributesOfColumn(int columnIndex, UserDataHolder userDataHolder) { + List textAttributeList = userDataHolder.getUserData(COLUMN_COLORING_TEXT_ATTRIBUTES); + if (textAttributeList == null) { + EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); + textAttributeList = new ArrayList<>(); + int maxIndex = 0; + switch (CsvEditorSettings.getInstance().getValueColoring()) { + case RAINBOW: + maxIndex = applyColumnTextAttributes(editorColorsScheme, textAttributeList); + break; + case SIMPLE: + textAttributeList.add(editorColorsScheme.getAttributes(CsvTextAttributeKeys.TEXT)); + break; + default: + throw new UnhandledSwitchCaseException(CsvEditorSettings.getInstance().getValueColoring()); + } + textAttributeList = textAttributeList.subList(0, maxIndex + 1); + userDataHolder.putUserData(COLUMN_COLORING_TEXT_ATTRIBUTES, textAttributeList); + } + return textAttributeList.isEmpty() ? null : textAttributeList.get(columnIndex % textAttributeList.size()); + } + + private static int applyColumnTextAttributes(EditorColorsScheme editorColorsScheme, List textAttributeList) { + int maxIndex = 0; + TextAttributes defaultTextAttributes = editorColorsScheme.getAttributes(CsvTextAttributeKeys.TEXT); + for (int colorDescriptorIndex = 0; colorDescriptorIndex < MAX_COLUMN_COLORING_COLORS; ++colorDescriptorIndex) { + TextAttributesKey textAttributesKey = COLUMN_COLORING_ATTRIBUTES.get(colorDescriptorIndex); + TextAttributes textAttributes = editorColorsScheme.getAttributes(textAttributesKey); + textAttributeList.add(textAttributes); + if (!textAttributes.equals(defaultTextAttributes)) { + maxIndex = colorDescriptorIndex; + } + } + return maxIndex; + } + + private CsvTextAttributeKeys() { + // static utility class + } +} diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvValidationInspection.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvValidationInspection.java index 87a3fb1b..cc9dd572 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvValidationInspection.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvValidationInspection.java @@ -15,7 +15,7 @@ import com.intellij.util.IncorrectOperationException; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.intention.CsvIntentionHelper; import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes; import net.seesharpsoft.intellij.psi.PsiHelper; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvShiftColumnIntentionAction.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvShiftColumnIntentionAction.java index 5cb3e095..4e11d136 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvShiftColumnIntentionAction.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvShiftColumnIntentionAction.java @@ -7,7 +7,7 @@ import com.intellij.psi.PsiElement; import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfo; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.psi.CsvFile; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiParserFileType.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiParserFileType.java index 1f0e31ee..5f7fae18 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiParserFileType.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvPsiParserFileType.java @@ -4,6 +4,10 @@ import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.NlsSafe; import net.seesharpsoft.intellij.plugins.csv.*; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacterHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java index 9bb5aeb1..41b56da7 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsProvider.java @@ -9,10 +9,11 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.*; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; -import net.seesharpsoft.intellij.plugins.csv.CsvPlugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static net.seesharpsoft.intellij.plugins.csv.CsvPluginManager.getLocalizedText; + public class CsvCodeStyleSettingsProvider extends CodeStyleSettingsProvider { @Override public CustomCodeStyleSettings createCustomSettings(@NotNull CodeStyleSettings settings) { @@ -22,7 +23,7 @@ public CustomCodeStyleSettings createCustomSettings(@NotNull CodeStyleSettings s @Nullable @Override public String getConfigurableDisplayName() { - return CsvPlugin.getLocalizedText("settings.title"); + return getLocalizedText("settings.title"); } @NotNull @@ -72,7 +73,7 @@ public CsvWrappingPanel(CodeStyleSettings settings) { @Override public @NotNull String getTabTitle() { - return CsvPlugin.getLocalizedText("settings.codestyle.wrapping"); + return getLocalizedText("settings.codestyle.wrapping"); } } @@ -83,7 +84,7 @@ public CsvSpacesPanel(CodeStyleSettings settings) { @Override protected @NotNull String getTabTitle() { - return CsvPlugin.getLocalizedText("settings.codestyle.spaces"); + return getLocalizedText("settings.codestyle.spaces"); } @Override diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvColorSettings.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvColorSettings.java index 6bc92c67..c6cb9936 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvColorSettings.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvColorSettings.java @@ -1,115 +1,22 @@ package net.seesharpsoft.intellij.plugins.csv.settings; -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; -import com.intellij.openapi.editor.HighlighterColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.UserDataHolder; -import net.seesharpsoft.UnhandledSwitchCaseException; import net.seesharpsoft.intellij.plugins.csv.CsvIconProvider; -import net.seesharpsoft.intellij.plugins.csv.CsvPlugin; import net.seesharpsoft.intellij.plugins.csv.highlighter.CsvSyntaxHighlighter; +import net.seesharpsoft.intellij.plugins.csv.highlighter.CsvTextAttributeKeys; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.ResourceBundle; -import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; +import static net.seesharpsoft.intellij.plugins.csv.CsvPluginManager.getLocalizedText; public class CsvColorSettings implements ColorSettingsPage { - - public static final TextAttributesKey COMMA = - createTextAttributesKey("CSV_DEFAULT_COMMA", DefaultLanguageHighlighterColors.COMMA); - public static final TextAttributesKey QUOTE = - createTextAttributesKey("CSV_DEFAULT_QUOTE", DefaultLanguageHighlighterColors.CONSTANT); - public static final TextAttributesKey TEXT = - createTextAttributesKey("CSV_DEFAULT_STRING", DefaultLanguageHighlighterColors.STRING); - public static final TextAttributesKey ESCAPED_TEXT = - createTextAttributesKey("CSV_ESCAPED_STRING", DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); - public static final TextAttributesKey COMMENT = - createTextAttributesKey("CSV_DEFAULT_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); - public static final TextAttributesKey BAD_CHARACTER = - createTextAttributesKey("CSV_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER); - - public static final Integer MAX_COLUMN_COLORING_COLORS = 10; - private static final AttributesDescriptor[] DESCRIPTORS; - private static final List COLUMN_COLORING_ATTRIBUTES; - private static final Key> COLUMN_COLORING_TEXT_ATTRIBUTES = Key.create("CSV_PLUGIN_COLUMN_COLORING_ATTRIBUTES"); - - static { - List attributesDescriptors = new ArrayList<>(); - ResourceBundle bundle = CsvPlugin.getResourceBundle(); - attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.separator"), COMMA)); - attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.quote"), QUOTE)); - attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.text"), TEXT)); - attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.text.escaped"), ESCAPED_TEXT)); - attributesDescriptors.add(new AttributesDescriptor(bundle.getString("color.attribute.comment"), COMMENT)); - - COLUMN_COLORING_ATTRIBUTES = new ArrayList<>(); - for (int i = 0; i < MAX_COLUMN_COLORING_COLORS; ++i) { - TextAttributesKey textAttributesKey = createTextAttributesKey(String.format("CSV_PLUGIN_COLUMN_COLORING_ATTRIBUTE_%d", i), TEXT); - COLUMN_COLORING_ATTRIBUTES.add(textAttributesKey); - attributesDescriptors.add(new AttributesDescriptor(String.format(bundle.getString("color.attribute.column.nr"), i + 1), textAttributesKey)); - } - DESCRIPTORS = attributesDescriptors.toArray(new AttributesDescriptor[0]); - } - - public static TextAttributesKey getTextAttributesKeys(int columnIndex) { - return COLUMN_COLORING_ATTRIBUTES.get(columnIndex % 10); - } - - public static TextAttributes getCommentTextAttributes() { - EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); - return editorColorsScheme.getAttributes(COMMENT); - } - - public static TextAttributes getTextAttributesOfColumn(int columnIndex, UserDataHolder userDataHolder) { - List textAttributeList = userDataHolder.getUserData(COLUMN_COLORING_TEXT_ATTRIBUTES); - if (textAttributeList == null) { - EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); - textAttributeList = new ArrayList<>(); - int maxIndex = 0; - switch (CsvEditorSettings.getInstance().getValueColoring()) { - case RAINBOW: - maxIndex = applyColumnTextAttributes(editorColorsScheme, textAttributeList); - break; - case SIMPLE: - textAttributeList.add(editorColorsScheme.getAttributes(TEXT)); - break; - default: - throw new UnhandledSwitchCaseException(CsvEditorSettings.getInstance().getValueColoring()); - } - textAttributeList = textAttributeList.subList(0, maxIndex + 1); - userDataHolder.putUserData(COLUMN_COLORING_TEXT_ATTRIBUTES, textAttributeList); - } - return textAttributeList.isEmpty() ? null : textAttributeList.get(columnIndex % textAttributeList.size()); - } - - private static int applyColumnTextAttributes(EditorColorsScheme editorColorsScheme, List textAttributeList) { - int maxIndex = 0; - TextAttributes defaultTextAttributes = editorColorsScheme.getAttributes(TEXT); - for (int colorDescriptorIndex = 0; colorDescriptorIndex < MAX_COLUMN_COLORING_COLORS; ++colorDescriptorIndex) { - TextAttributesKey textAttributesKey = COLUMN_COLORING_ATTRIBUTES.get(colorDescriptorIndex); - TextAttributes textAttributes = editorColorsScheme.getAttributes(textAttributesKey); - textAttributeList.add(textAttributes); - if (!textAttributes.equals(defaultTextAttributes)) { - maxIndex = colorDescriptorIndex; - } - } - return maxIndex; - } - @Nullable @Override public Icon getIcon() { @@ -141,7 +48,7 @@ public Map getAdditionalHighlightingTagToDescriptorMa @NotNull @Override public AttributesDescriptor[] getAttributeDescriptors() { - return DESCRIPTORS; + return CsvTextAttributeKeys.DESCRIPTORS; } @NotNull @@ -153,6 +60,6 @@ public ColorDescriptor[] getColorDescriptors() { @NotNull @Override public String getDisplayName() { - return CsvPlugin.getLocalizedText("settings.title"); + return getLocalizedText("settings.title"); } } \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettings.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettings.java index e7262642..8ca09f17 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettings.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettings.java @@ -8,10 +8,9 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.util.xmlb.annotations.OptionTag; import com.intellij.util.xmlb.annotations.Transient; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; -import net.seesharpsoft.intellij.plugins.csv.CsvPlugin; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvStorageHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -19,6 +18,8 @@ import java.beans.PropertyChangeSupport; import java.util.Objects; +import static net.seesharpsoft.intellij.plugins.csv.CsvPluginManager.getLocalizedText; + @State( name = "CsvEditorSettings", storages = {@Storage(CsvStorageHelper.CSV_STATE_STORAGE_FILE)} @@ -41,9 +42,9 @@ public class CsvEditorSettings implements PersistentStateComponent(CsvEditorSettings.ValueColoring.values()); comboValueColoring.setRenderer(new CustomDisplayListCellRenderer<>(CsvEditorSettings.ValueColoring::getDisplay)); - cbTabHighlightColor = new CheckBoxWithColorChooser(CsvPlugin.getLocalizedText("settings.editor.highlight.tab.separator")); + cbTabHighlightColor = new CheckBoxWithColorChooser(getLocalizedText("settings.editor.highlight.tab.separator")); cbTabHighlightColor.setColor(JBColor.CYAN); NumberFormat numberFormat = NumberFormat.getIntegerInstance(); diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvLanguageCodeStyleSettingsProvider.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvLanguageCodeStyleSettingsProvider.java index 810e4b9c..48be98e5 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvLanguageCodeStyleSettingsProvider.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvLanguageCodeStyleSettingsProvider.java @@ -5,11 +5,12 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; -import net.seesharpsoft.intellij.plugins.csv.CsvPlugin; import org.jetbrains.annotations.NotNull; import java.util.ResourceBundle; +import static net.seesharpsoft.intellij.plugins.csv.CsvPluginManager.getResourceBundle; + public class CsvLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider { @NotNull @Override @@ -19,7 +20,7 @@ public Language getLanguage() { @Override public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) { - ResourceBundle bundle = CsvPlugin.getResourceBundle(); + ResourceBundle bundle = getResourceBundle(); if (settingsType == SettingsType.LANGUAGE_SPECIFIC) { consumer.showCustomOption(CsvCodeStyleSettings.class, "SPACE_BEFORE_SEPARATOR", diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileType.java b/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileType.java index f3f62416..680d619c 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileType.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileType.java @@ -3,8 +3,8 @@ import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.util.IconLoader; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; -import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileType.java b/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileType.java index 2e760f68..96fa949d 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileType.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileType.java @@ -3,8 +3,8 @@ import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.util.IconLoader; import net.seesharpsoft.intellij.plugins.csv.CsvLanguage; -import net.seesharpsoft.intellij.plugins.csv.CsvSeparatorHolder; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvSeparatorHolder; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/CsvHelperTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/CsvHelperTest.java index f46913de..67ef2d5d 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/CsvHelperTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/CsvHelperTest.java @@ -1,6 +1,8 @@ package net.seesharpsoft.intellij.plugins.csv; import com.intellij.testFramework.PlatformLiteFixture; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; public class CsvHelperTest extends PlatformLiteFixture { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionTest.java index 15821c9e..34b8513d 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeEscapeCharacterActionTest.java @@ -1,7 +1,7 @@ package net.seesharpsoft.intellij.plugins.csv.actions; import com.intellij.openapi.actionSystem.Presentation; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; public class CsvChangeEscapeCharacterActionTest extends CsvActionTestBase { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java index 55b46eaf..ff92858b 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java @@ -2,7 +2,7 @@ import com.intellij.openapi.actionSystem.Presentation; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; public class CsvChangeSeparatorActionTest extends CsvActionTestBase { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributesTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributesTest.java index 541278aa..68a50927 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributesTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributesTest.java @@ -1,7 +1,6 @@ package net.seesharpsoft.intellij.plugins.csv.components; import net.seesharpsoft.intellij.plugins.csv.CsvBasePlatformTestCase; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBaseTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBaseTest.java index eddad7d7..9727cdf2 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBaseTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelBaseTest.java @@ -6,7 +6,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.testFramework.PsiTestUtil; import net.seesharpsoft.intellij.plugins.csv.CsvBasePlatformTestCase; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.settings.CsvCodeStyleSettings; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; import net.seesharpsoft.intellij.psi.PsiFileHolder; diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelCustomizedTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelCustomizedTest.java index 0a5d7188..a64b2c77 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelCustomizedTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableModelCustomizedTest.java @@ -1,7 +1,7 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; public class CsvTableModelCustomizedTest extends CsvTableModelBaseTest { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java index 0f169878..6f593afd 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java @@ -2,7 +2,7 @@ import com.intellij.codeInsight.intention.IntentionAction; import net.seesharpsoft.intellij.plugins.csv.CsvBasePlatformTestCase; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; public class CsvIntentionTest extends CsvBasePlatformTestCase { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/parser/CsvParsingTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/parser/CsvParsingTest.java index 3c2c9331..126debd8 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/parser/CsvParsingTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/parser/CsvParsingTest.java @@ -1,9 +1,9 @@ package net.seesharpsoft.intellij.plugins.csv.parser; import com.intellij.testFramework.ParsingTestCase; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; import net.seesharpsoft.intellij.plugins.csv.CsvParserDefinition; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings; import static net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings.COMMENT_INDICATOR_DEFAULT; diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProviderTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProviderTest.java index fd89d848..6e58ec9b 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProviderTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProviderTest.java @@ -2,8 +2,8 @@ import com.intellij.openapi.options.ConfigurationException; import net.seesharpsoft.intellij.plugins.csv.CsvBasePlatformTestCase; -import net.seesharpsoft.intellij.plugins.csv.CsvEscapeCharacter; -import net.seesharpsoft.intellij.plugins.csv.CsvValueSeparator; +import net.seesharpsoft.intellij.plugins.csv.components.CsvEscapeCharacter; +import net.seesharpsoft.intellij.plugins.csv.components.CsvValueSeparator; import java.awt.*; From d674ec31e7ed062d9ba43917566c06a50fdf74b4 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 17:53:59 -0400 Subject: [PATCH 10/13] Chore: Version update --- CHANGELOG.md | 12 ++++++++++++ gradle.properties | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64725b18..2bea676b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,18 @@ ### Fixed +## [4.1.0] - Sep 07, 2025 + +### Fixed + +- Access is allowed with explicit read lock #898 #901 +- Rework CSV file detection for FileEditorProvider #904 +- Legacy configurable id calculation mode from localizable name will be used for configurable class CsvCodeStyleSettingsProvider. Please override getConfigurableId or getLanguage. #909 + +### Changed + +- Project structure refactoring to avoid circular dependencies + ## [4.0.2] - Dec 29, 2024 ### Added diff --git a/gradle.properties b/gradle.properties index 442acf8f..fbef94eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginName=CSV Editor pluginId=net.seesharpsoft.intellij.plugins.csv -pluginVersion=4.0.2 +pluginVersion=4.1.0 pluginSinceBuild=242 From c66754ea17b370134fc8c3820d1cc13917a48ae0 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 18:37:04 -0400 Subject: [PATCH 11/13] Chore: Simplify customizable language elements --- .../intellij/plugins/csv/CsvHelper.java | 4 +- .../components/CsvCustomizableElement.java | 57 ++++++++++++++++++ .../csv/components/CsvEscapeCharacter.java | 59 +++---------------- .../csv/components/CsvValueSeparator.java | 57 ++---------------- 4 files changed, 72 insertions(+), 105 deletions(-) create mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvCustomizableElement.java diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java index 5a81910d..be03b01c 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvHelper.java @@ -279,7 +279,7 @@ public static String unquoteCsvValue(String content, CsvEscapeCharacter escapeCh if (trimmedContent.length() > 1 && trimmedContent.startsWith("\"") && trimmedContent.endsWith("\"")) { result = trimmedContent.substring(1, trimmedContent.length() - 1); if (escapeCharacter != null) { - result = result.replaceAll("(?:" + escapeCharacter.getRegexPattern() + ")\"", "\""); + result = result.replaceAll("(?:" + escapeCharacter.getStringPattern() + ")\"", "\""); } } return result; @@ -299,7 +299,7 @@ public static String quoteCsvField(String content, } if (quotingEnforced || isQuotingRequired(content, valueSeparator)) { String result = content; - result = result.replaceAll("\"", escapeCharacter.getRegexPattern() + "\""); + result = result.replaceAll("\"", escapeCharacter.getStringPattern() + "\""); return "\"" + result + "\""; } return content; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvCustomizableElement.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvCustomizableElement.java new file mode 100644 index 00000000..aa7a2c26 --- /dev/null +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvCustomizableElement.java @@ -0,0 +1,57 @@ +package net.seesharpsoft.intellij.plugins.csv.components; + +import java.util.Objects; +import java.util.regex.Pattern; + +public class CsvCustomizableElement { + private final String myCharacter; + private final String myDisplay; + private final Pattern myPattern; + private final String myName; + + protected static final String CUSTOM_NAME = "CUSTOM"; + protected static final String CUSTOM_DISPLAY = "Custom"; + + protected CsvCustomizableElement(String character, String display, String regexPattern, String name) { + myCharacter = character; + myDisplay = display; + myPattern = Pattern.compile(regexPattern); + myName = name; + } + + public String getCharacter() { + return myCharacter; + } + + public String getDisplay() { + return myDisplay; + } + + public Pattern getPattern() { return myPattern; } + + public String getName() { + return myName; + } + + public boolean isCustom() { + return CUSTOM_NAME.equals(getName()); + } + + @Override + public int hashCode() { + return Objects.hash(getCharacter(), isCustom()); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof CsvCustomizableElement otherObj) || !obj.getClass().equals(this.getClass())) { + return false; + } + return Objects.equals(otherObj.getCharacter(), this.getCharacter()) && Objects.equals(otherObj.isCustom(), this.isCustom()); + } + + @Override + public String toString() { + return getDisplay(); + } +} diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java index f98c72d2..8c150102 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java @@ -4,18 +4,10 @@ import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; -import java.util.Objects; import java.util.regex.Pattern; -public class CsvEscapeCharacter { - private final String myCharacter; - private final String myDisplay; - private final Pattern myPattern; - private final String myRegexPattern; - private final String myName; - - private static final String CUSTOM_NAME = "CUSTOM"; - private static final String CUSTOM_DISPLAY = "Custom"; +public class CsvEscapeCharacter extends CsvCustomizableElement { + private final String myStringPattern; public static CsvEscapeCharacter QUOTE = new CsvEscapeCharacter("\"", "Double Quote (\")", "\"", "QUOTE"); public static CsvEscapeCharacter BACKSLASH = new CsvEscapeCharacter("\\", "Backslash (\\)", "\\\\", "BACKSLASH"); @@ -63,52 +55,15 @@ public CsvEscapeCharacter(String myCharacter) { } private CsvEscapeCharacter(String character, String display, String regexPattern, String name) { - myCharacter = character; - myDisplay = display; - myRegexPattern = regexPattern; - myPattern = Pattern.compile(Pattern.quote(myCharacter + "\"")); - myName = name; - } - - public String getCharacter() { - return myCharacter; - } - - public String getDisplay() { - return myDisplay; - } - - public String getRegexPattern() { - return myRegexPattern; + super(character, display, Pattern.quote(character + "\""), name); + myStringPattern = regexPattern; } public boolean isEscapedQuote(String text) { - return myPattern.matcher(text).matches(); - } - - public String getName() { - return myName; - } - - public boolean isCustom() { - return CUSTOM_NAME.equals(getName()); - } - - @Override - public int hashCode() { - return Objects.hash(getCharacter(), isCustom()); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof CsvEscapeCharacter otherObj)) { - return false; - } - return Objects.equals(otherObj.getCharacter(), this.getCharacter()) && Objects.equals(otherObj.isCustom(), this.isCustom()); + return getPattern().matcher(text).matches(); } - @Override - public String toString() { - return getDisplay(); + public String getStringPattern() { + return myStringPattern; } } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java index 297eda3d..d5b06777 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java @@ -2,20 +2,13 @@ import com.intellij.util.xmlb.Converter; import com.intellij.xml.util.XmlStringUtil; +import org.jetbrains.annotations.NotNull; -import java.util.Objects; import java.util.regex.Pattern; -public class CsvValueSeparator { - private final String myCharacter; - private final String myDisplay; - private final Pattern myPattern; - private final String myName; +public class CsvValueSeparator extends CsvCustomizableElement { private final boolean myRequiresCustomLexer; - private static final String CUSTOM_NAME = "CUSTOM"; - private static final String CUSTOM_DISPLAY = "Custom"; - public static final CsvValueSeparator COMMA = new CsvValueSeparator(",", "Comma (,)", "COMMA"); public static final CsvValueSeparator SEMICOLON = new CsvValueSeparator(";", "Semicolon (;)", "SEMICOLON"); public static final CsvValueSeparator PIPE = new CsvValueSeparator("|", "Pipe (|)", "PIPE"); @@ -64,7 +57,7 @@ public static CsvValueSeparator[] values() { } public static class CsvValueSeparatorConverter extends Converter { - public CsvValueSeparator fromString(String value) { + public CsvValueSeparator fromString(@NotNull String value) { return CsvValueSeparator.create(XmlStringUtil.unescapeIllegalXmlChars(value)); } @@ -82,57 +75,19 @@ private CsvValueSeparator(String character, String display, String name) { } private CsvValueSeparator(String character, String display, String name, boolean requiresCustomLexer) { - myCharacter = character; - myDisplay = display; - myPattern = Pattern.compile(Pattern.quote(myCharacter)); - myName = name; + super(character, display, Pattern.quote(character), name); myRequiresCustomLexer = requiresCustomLexer; } - public String getCharacter() { - return myCharacter; - } - - public String getDisplay() { - return myDisplay; - } - public boolean isValueSeparator(String text) { - return myPattern.matcher(text).matches(); + return getPattern().matcher(text).matches(); } public boolean isValueSeparator(char c) { - return myCharacter.charAt(0) == c; - } - - public String getName() { - return myName; - } - - public boolean isCustom() { - return CUSTOM_NAME.equals(getName()); + return getCharacter().charAt(0) == c; } public boolean requiresCustomLexer() { return myRequiresCustomLexer || isCustom(); } - - @Override - public int hashCode() { - return Objects.hash(getCharacter(), isCustom()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null || !(obj instanceof CsvValueSeparator)) { - return false; - } - CsvValueSeparator otherObj = (CsvValueSeparator) obj; - return Objects.equals(otherObj.getCharacter(), this.getCharacter()) && Objects.equals(otherObj.isCustom(), this.isCustom()); - } - - @Override - public String toString() { - return getDisplay(); - } } From f228375a5c91c95da6509ee8afc71e31c339bcd7 Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 18:54:34 -0400 Subject: [PATCH 12/13] Chore: Code refactoring --- .../csv/components/CsvEscapeCharacter.java | 18 ++++------ .../csv/components/CsvValueSeparator.java | 36 +++++-------------- 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java index 8c150102..2fff93ca 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvEscapeCharacter.java @@ -3,6 +3,7 @@ import com.intellij.util.xmlb.Converter; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.regex.Pattern; @@ -13,20 +14,13 @@ public class CsvEscapeCharacter extends CsvCustomizableElement { public static CsvEscapeCharacter BACKSLASH = new CsvEscapeCharacter("\\", "Backslash (\\)", "\\\\", "BACKSLASH"); public static CsvEscapeCharacter[] values() { - return new CsvEscapeCharacter[]{QUOTE, BACKSLASH}; + return new CsvEscapeCharacter[]{ QUOTE, BACKSLASH }; } - public static CsvEscapeCharacter getDefaultEscapeCharacter(String character) { - if (character != null) { - switch (character) { - case "QUOTE": - case "\"": - return QUOTE; - case "BACKSLASH": - case "\\": - return BACKSLASH; - default: - break; + private static @Nullable CsvEscapeCharacter getDefaultEscapeCharacter(@NotNull String character) { + for (CsvEscapeCharacter defaultEC : values()) { + if (defaultEC.getCharacter().equals(character) || defaultEC.getName().equals(character)) { + return defaultEC; } } return null; diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java index d5b06777..6abc2471 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvValueSeparator.java @@ -3,6 +3,7 @@ import com.intellij.util.xmlb.Converter; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.regex.Pattern; @@ -16,29 +17,14 @@ public class CsvValueSeparator extends CsvCustomizableElement { public static final CsvValueSeparator COLON = new CsvValueSeparator(":", "Colon (:)", "COLON"); public static final CsvValueSeparator RS = new CsvValueSeparator("\u001E", "Record Separator ([RS])", "RS", true); - public static CsvValueSeparator getDefaultValueSeparator(String character) { - if (character != null) { - switch (character) { - case "COMMA": - case ",": - return COMMA; - case "SEMICOLON": - case ";": - return SEMICOLON; - case "PIPE": - case "|": - return PIPE; - case "TAB": - case "\t": - return TAB; - case "COLON": - case ":": - return COLON; - case "RS": - case "\u001E": - return RS; - default: - break; + public static CsvValueSeparator @NotNull [] values() { + return new CsvValueSeparator[]{ COMMA, SEMICOLON, PIPE, TAB, COLON, RS }; + } + + private static @Nullable CsvValueSeparator getDefaultValueSeparator(@NotNull String character) { + for (CsvValueSeparator defaultVS : values()) { + if (defaultVS.getCharacter().equals(character) || defaultVS.getName().equals(character)) { + return defaultVS; } } return null; @@ -52,10 +38,6 @@ public static CsvValueSeparator create(String character) { return defaultValueSeparator == null ? new CsvValueSeparator(character) : defaultValueSeparator; } - public static CsvValueSeparator[] values() { - return new CsvValueSeparator[]{COMMA, SEMICOLON, PIPE, TAB, COLON, RS}; - } - public static class CsvValueSeparatorConverter extends Converter { public CsvValueSeparator fromString(@NotNull String value) { return CsvValueSeparator.create(XmlStringUtil.unescapeIllegalXmlChars(value)); From 84192014fd635f74aca254ee6b8a73ebebf6907e Mon Sep 17 00:00:00 2001 From: GeeK Date: Sun, 7 Sep 2025 19:50:07 -0400 Subject: [PATCH 13/13] Chore: Enable manual trigger of the CIBuild action --- .github/workflows/CIBuild.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CIBuild.yml b/.github/workflows/CIBuild.yml index 7d3b5e2d..3417f27c 100644 --- a/.github/workflows/CIBuild.yml +++ b/.github/workflows/CIBuild.yml @@ -16,6 +16,12 @@ on: branches: [ main ] schedule: - cron: '18 7 * * 6' + workflow_dispatch: + inputs: + environment: + description: 'Environment to run tests against' + type: environment + required: true jobs: analyze: @@ -36,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -69,4 +75,4 @@ jobs: run: xvfb-run ./gradlew build - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3