Skip to content

Commit

Permalink
1.2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Sep 25, 2023
1 parent 2e19884 commit f9cfdf7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pluginName=intellij-aicoder
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder
# SemVer format -> https://semver.org
pluginVersion=1.2.14
pluginVersion=1.2.15
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
#pluginSinceBuild = 203
pluginSinceBuild=231
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DocAction extends SelectionAction<String> {
@Override
String processSelection(SelectionState state, String config) {
CharSequence code = state.selectedText
IndentedText indentedInput = IndentedText.fromString3(code.toString() as java.lang.CharSequence)
IndentedText indentedInput = IndentedText.fromString(code.toString())
String docString = proxy.processCode(
indentedInput.textBlock.toString(),
"Write detailed " + (state.language?.docStyle ?: "documentation") + " prefix for code block",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public IndentedText(CharSequence indent, CharSequence... lines) {
this.setLines(lines);
}

/**
* This method is used to convert a string into an IndentedText object.
*
* @param text The string to be converted into an IndentedText object.
* @return IndentedText object created from the input string.
*/
public static IndentedText fromString(String text) {
text = text == null ? "" : text;
text = text.replace("\t", TextBlock.TAB_REPLACEMENT.toString());
Expand All @@ -35,24 +41,6 @@ public static IndentedText fromString(String text) {
.toArray(CharSequence[]::new));
}

public static IndentedText fromString2(CharSequence text) {
text = text == null ? "" : text;
text = text.toString().replace("\t", TextBlock.TAB_REPLACEMENT.toString());
CharSequence indent = StringUtil.getWhitespacePrefix2(text.toString().split(TextBlock.DELIMITER));
return new IndentedText(indent, Arrays.stream(text.toString().split(TextBlock.DELIMITER))
.map(s -> StringUtil.stripPrefix(s, indent))
.toArray(CharSequence[]::new));
}

public static IndentedText fromString3(CharSequence text) {
text = text == null ? "" : text;
text = text.toString().replace("\t", TextBlock.TAB_REPLACEMENT.toString());
CharSequence indent = StringUtil.getWhitespacePrefix2(text.toString().split(TextBlock.DELIMITER));
return new IndentedText(indent, Arrays.stream(text.toString().split(TextBlock.DELIMITER))
.map(s -> StringUtil.stripPrefix(s, indent))
.toArray(CharSequence[]::new));
}

@Override
public String toString() {
return Arrays.stream(rawString()).collect(Collectors.joining(TextBlock.DELIMITER + getIndent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ object UITools {
if (stripUnbalancedTerminators) {
result = StringUtil.stripUnbalancedTerminators(result)
}
result = IndentedText.fromString2(result).withIndent(indent).toString()
result = IndentedText.fromString(result.toString()).withIndent(indent).toString()
indent.toString() + result
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DocAction extends SelectionAction<String> {
@Override
String processSelection(SelectionState state, String config) {
CharSequence code = state.selectedText
IndentedText indentedInput = IndentedText.fromString3(code.toString() as java.lang.CharSequence)
IndentedText indentedInput = IndentedText.fromString(code.toString())
String docString = proxy.processCode(
indentedInput.textBlock.toString(),
"Write detailed " + (state.language?.docStyle ?: "documentation") + " prefix for code block",
Expand Down

0 comments on commit f9cfdf7

Please sign in to comment.