-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #123 Изменение алгоритма работы выделения текста при анализе. Т…
…еперь анализируется весь модуль. При выводе на форму issues - работает фильтр по выделенным строкам.
- Loading branch information
Showing
9 changed files
with
128 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/github/otymko/phoenixbsl/logic/text/Constant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.otymko.phoenixbsl.logic.text; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class Constant { | ||
public final String SEPARATOR = "\n"; | ||
public final String FUN_SYMBOL = "☻"; // 9787 | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/github/otymko/phoenixbsl/logic/text/Location.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.otymko.phoenixbsl.logic.text; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.Value; | ||
|
||
@Value | ||
@RequiredArgsConstructor | ||
public class Location { | ||
private static final Location EMPTY = new Location(0, 0); | ||
|
||
int startLine; | ||
int endLine; | ||
|
||
public static Location empty() { | ||
return EMPTY; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/github/otymko/phoenixbsl/logic/text/SourceText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.github.otymko.phoenixbsl.logic.text; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.Value; | ||
|
||
@Value | ||
@RequiredArgsConstructor | ||
public class SourceText { | ||
String content; | ||
int offset; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/github/otymko/phoenixbsl/logic/utils/IssueHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.otymko.phoenixbsl.logic.utils; | ||
|
||
import com.github.otymko.phoenixbsl.logic.PhoenixAPI; | ||
import com.github.otymko.phoenixbsl.logic.text.Location; | ||
import com.github.otymko.phoenixbsl.model.Issue; | ||
import lombok.experimental.UtilityClass; | ||
import org.eclipse.lsp4j.Diagnostic; | ||
|
||
@UtilityClass | ||
public class IssueHelper { | ||
|
||
public boolean checkDiagnosticBySelection(Diagnostic diagnostic, Location selection) { | ||
if (selection == Location.empty()) { | ||
return true; | ||
} | ||
return diagnostic.getRange().getStart().getLine() >= selection.getStartLine() | ||
&& diagnostic.getRange().getEnd().getLine() <= selection.getEndLine(); | ||
} | ||
|
||
public Issue createIssue(Diagnostic diagnostic) { | ||
var range = diagnostic.getRange(); | ||
var position = range.getStart(); | ||
var startLine = position.getLine() + 1; | ||
|
||
var issue = new Issue(); | ||
issue.setSource(PhoenixAPI.getValueSourceByString(diagnostic.getSource())); | ||
issue.setDescription(diagnostic.getMessage()); | ||
issue.setStartLine(startLine); | ||
issue.setLocation(String.valueOf(startLine)); | ||
issue.setSeverity(diagnostic.getSeverity()); | ||
return issue; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/github/otymko/phoenixbsl/logic/utils/TextUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.otymko.phoenixbsl.logic.utils; | ||
|
||
import com.github.otymko.phoenixbsl.logic.text.Constant; | ||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class TextUtil { | ||
|
||
public String pasteSelectionInText(String text, String selection) { | ||
return text.replace(Constant.FUN_SYMBOL, selection); | ||
} | ||
|
||
public int numberOfLinesInText(String text) { | ||
return text.split(Constant.SEPARATOR).length; | ||
} | ||
|
||
} |