diff --git a/src/main/java/org/wso2/lsp4intellij/utils/DocumentUtils.java b/src/main/java/org/wso2/lsp4intellij/utils/DocumentUtils.java
index 017b828e..d73b4c8e 100644
--- a/src/main/java/org/wso2/lsp4intellij/utils/DocumentUtils.java
+++ b/src/main/java/org/wso2/lsp4intellij/utils/DocumentUtils.java
@@ -27,10 +27,9 @@
import org.eclipse.lsp4j.TextEdit;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
-import javax.annotation.Nullable;
-
import java.util.List;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
import static java.lang.Math.max;
import static java.lang.Math.min;
@@ -41,37 +40,10 @@
*/
public class DocumentUtils {
- private static Logger LOG = Logger.getInstance(DocumentUtils.class);
+ private static final Logger LOG = Logger.getInstance(DocumentUtils.class);
public static final String WIN_SEPARATOR = "\r\n";
public static final String LINUX_SEPARATOR = "\n";
- /**
- * Gets the line at the given offset given an editor and bolds the text between the given offsets
- *
- * @param editor The editor
- * @param startOffset The starting offset
- * @param endOffset The ending offset
- * @return The document line
- */
- public static String getLineText(Editor editor, int startOffset, int endOffset) {
- return computableReadAction(() -> {
- Document doc = editor.getDocument();
- int lineIdx = doc.getLineNumber(startOffset);
- int lineStartOff = doc.getLineStartOffset(lineIdx);
- int lineEndOff = doc.getLineEndOffset(lineIdx);
- String line = doc.getText(new TextRange(lineStartOff, lineEndOff));
- int startOffsetInLine = startOffset - lineStartOff;
- int endOffsetInLine = endOffset - lineStartOff;
- StringBuilder sb = new StringBuilder( line.length()+7 );
- sb.append(line, 0, startOffsetInLine);
- sb.append("");
- sb.append(line, startOffsetInLine, endOffsetInLine);
- sb.append("");
- sb.append(line, endOffsetInLine, line.length());
- return sb.toString();
- });
- }
-
/**
* Transforms a LogicalPosition (IntelliJ) to an LSP Position
*
@@ -113,10 +85,7 @@ public static Position offsetToLSPPos(Editor editor, int offset) {
int line = doc.getLineNumber(offset);
int lineStart = doc.getLineStartOffset(line);
String lineTextBeforeOffset = doc.getText(TextRange.create(lineStart, offset));
-
- int tabs = StringUtil.countChars(lineTextBeforeOffset, '\t');
- int tabSize = getTabSize(editor);
- int column = lineTextBeforeOffset.length() - tabs * (tabSize - 1);
+ int column = lineTextBeforeOffset.length();
return new Position(line, column);
});
}
@@ -160,8 +129,6 @@ public static int LSPPosToOffset(Editor editor, Position pos) {
return Math.min(max(offset, 0), docLength);
});
-
-
}
@Nullable
@@ -188,13 +155,11 @@ public static int getTabSize(Editor editor) {
return computableReadAction(() -> editor.getSettings().getTabSize(editor.getProject()));
}
- public static boolean shouldUseSpaces(Editor editor){
+ public static boolean shouldUseSpaces(Editor editor) {
return computableReadAction(() -> !editor.getSettings().isUseTabCharacter(editor.getProject()));
}
public static List> toEither(List edits) {
return edits.stream().map(Either::forLeft).collect(Collectors.toList());
}
-
-
}