mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Make line indent provider correctly handle comments
This commit is contained in:
@@ -53,6 +53,7 @@ public class JavaLineIndentProvider extends JavaLikeLangLineIndentProvider {
|
||||
SYNTAX_MAP.put(JavaDocTokenType.DOC_COMMENT_START, DocBlockStart);
|
||||
SYNTAX_MAP.put(JavaDocTokenType.DOC_COMMENT_END, DocBlockEnd);
|
||||
SYNTAX_MAP.put(JavaTokenType.COMMA, Comma);
|
||||
SYNTAX_MAP.put(JavaTokenType.END_OF_LINE_COMMENT, LineComment);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
-8
@@ -55,6 +55,7 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
|
||||
BlockComment,
|
||||
DocBlockStart,
|
||||
DocBlockEnd,
|
||||
LineComment,
|
||||
Comma
|
||||
}
|
||||
|
||||
@@ -165,15 +166,11 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
|
||||
}
|
||||
while (!position.isAtEnd()) {
|
||||
if (currLanguage == Language.ANY || currLanguage == null) currLanguage = position.getLanguage();
|
||||
if (position.isAt(Semicolon) ||
|
||||
position.isAt(BlockOpeningBrace) ||
|
||||
position.isAt(BlockClosingBrace) ||
|
||||
! ((position.getLanguage() != Language.ANY) && position.isAtLanguage(currLanguage))) {
|
||||
if (position.isAtAnyOf(Semicolon, BlockOpeningBrace, BlockClosingBrace, BlockComment, DocBlockEnd, LineComment) ||
|
||||
(position.getLanguage() != Language.ANY) && !position.isAtLanguage(currLanguage)) {
|
||||
SemanticEditorPosition statementStart = getPosition(position.getEditor(), position.getStartOffset());
|
||||
if (statementStart.after().isAt(Whitespace) && statementStart.isAtMultiline()) {
|
||||
if (!statementStart.after().isAtEnd()) {
|
||||
return statementStart.getStartOffset();
|
||||
}
|
||||
if (!statementStart.after().afterOptional(Whitespace).isAtEnd()) {
|
||||
return statementStart.getStartOffset();
|
||||
}
|
||||
}
|
||||
position.before();
|
||||
|
||||
Reference in New Issue
Block a user