Skip to content

Commit 5102602

Browse files
committed
SONARPY-2025 PythonScanner parses the wrong file when given a GeneratedFile (#1877)
1 parent 33baa34 commit 5102602

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sonar-python-plugin/src/main/java/org/sonar/plugins/python/PythonScanner.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.sonar.sslr.api.AstNode;
2323
import com.sonar.sslr.api.RecognitionException;
2424
import java.io.File;
25+
import java.io.IOException;
2526
import java.util.ArrayDeque;
2627
import java.util.ArrayList;
2728
import java.util.Collections;
@@ -98,12 +99,12 @@ protected String name() {
9899
}
99100

100101
@Override
101-
protected void scanFile(PythonInputFile inputFile) {
102+
protected void scanFile(PythonInputFile inputFile) throws IOException {
102103
PythonFile pythonFile = SonarQubePythonFile.create(inputFile.wrappedFile());
103104
PythonVisitorContext visitorContext;
104105
InputFile.Type fileType = inputFile.wrappedFile().type();
105106
try {
106-
AstNode astNode = parser.parse(pythonFile.content());
107+
AstNode astNode = parser.parse(inputFile.contents());
107108
PythonTreeMaker treeMaker = getTreeMaker(inputFile);
108109
FileInput parse = treeMaker.fileInput(astNode);
109110
visitorContext = new PythonVisitorContext(parse,

0 commit comments

Comments
 (0)