Skip to content

Commit

Permalink
Autocomplete when if is not closed #133 : get rid of now unneeded h…
Browse files Browse the repository at this point in the history
…ack of auto-formatting non-closed if
  • Loading branch information
xonixx committed May 1, 2023
1 parent dfba221 commit fd5791b
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/main/java/intellij_awk/AwkFormattingBlock.java
Expand Up @@ -159,36 +159,6 @@ public boolean isIncomplete() {
public @NotNull ChildAttributes getChildAttributes(int newChildIndex) {
PsiElement psi = myNode.getPsi();
if (psi instanceof AwkFile) {
if (newChildIndex > 0) {
// handle if(1)<ENTER>, while(1)<ENTER> etc
// below is hacky code, because in presence of uncompleted if(1) the file is not parsed to
// correct AST yet and is rather a flat token list in a awk file node
List<Block> children = buildChildren();
int blockIndex = newChildIndex - 1;
ASTNode prevNode = getChildBlockNode(children, blockIndex);
PsiElement errOrDummyBlockElt;
if (prevNode.getElementType() == AwkTypes.RPAREN
|| (errOrDummyBlockElt = prevNode.getPsi().getLastChild()) != null
&& isType(errOrDummyBlockElt, AwkTypes.RPAREN)) {

// search corresponding LPAREN and then keyword before it
while (--blockIndex > 0) {
ASTNode node = getChildBlockNode(children, blockIndex);
if (node.getElementType() == AwkTypes.LPAREN) {
node = getChildBlockNode(children, blockIndex - 1);
if (IF_FOR_WHILE.contains(node.getElementType())) {
int indentSize =
codeStyleSettings
.getCommonSettings(AwkLanguage.INSTANCE)
.getIndentOptions()
.INDENT_SIZE;
int colNo = getLineColumnRelativeToParent(myNode, node).column;
return new ChildAttributes(Indent.getSpaceIndent(colNo + indentSize), null);
}
}
}
}
}
return new ChildAttributes(Indent.getNoneIndent(), null);
} /*else if (psi instanceof AwkTerminatedStatementList
// case of https://github.com/xonixx/intellij-awk/issues/106
Expand Down

0 comments on commit fd5791b

Please sign in to comment.