Skip to content

Commit

Permalink
fix ImplicitTypeRule for making TYPE explicit, but not LENGTH (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgrassau committed Dec 16, 2024
1 parent 1a03ac4 commit d461f4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ private Token executeOn(Code code, Command command, Token identifier, int baseIn
if (!hasType) {
typeKeyword = Token.createForAbap(0, 1, "TYPE", TokenType.KEYWORD, identifier.sourceLineNum);
typeIdentifier = Token.createForAbap(0, 1, ABAP.DEFAULT_TYPE, TokenType.IDENTIFIER, identifier.sourceLineNum);
identifier.insertRightSibling(typeKeyword);
// in case of 'DATA lv_k(lc_text_length).' (with deactivated configReplaceParenthesisWithLength), identifier may still open a level
Token identifierEnd = identifier.getNextSiblingWhileLevelOpener();
identifierEnd.insertRightSibling(typeKeyword);
typeKeyword.insertRightSibling(typeIdentifier);
changed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,19 @@ void testConstantLengthInParenthesisOfStructure() {

testRule();
}

@Test
void testReplaceTypeButNotLength() {
rule.configReplaceParenthesisWithLength.setValue(false);

buildSrc(" CONSTANTS lc_text_length TYPE i VALUE 10.");
buildSrc(" DATA lv_k(lc_text_length).");

buildExp(" CONSTANTS lc_text_length TYPE i VALUE 10.");
buildExp(" DATA lv_k(lc_text_length) TYPE c.");

putAnyMethodAroundSrcAndExp();

testRule();
}
}

0 comments on commit d461f4b

Please sign in to comment.