Skip to content

Commit f01ee59

Browse files
committed
add a docstring, and rename rawString -> foldedString
1 parent 7b0ebd3 commit f01ee59

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ private boolean isOctalDigit(char ch) {
619619
return '0' <= ch && ch <= '7';
620620
}
621621

622+
/**
623+
* Constant-folds simple string concatenations in `exp` while keeping an offset translation
624+
* that tracks back to the original source.
625+
*/
622626
private Pair<String, OffsetTranslation> getStringConcatResult(Expression exp) {
623627
if (exp instanceof BinaryExpression) {
624628
BinaryExpression be = (BinaryExpression) exp;
@@ -857,15 +861,15 @@ private void extractRegxpFromBinop(BinaryExpression nd, Context c) {
857861
if (concatResult == null) {
858862
return;
859863
}
860-
String rawString = concatResult.fst();
861-
if (rawString.length() > 1000 && !rawString.trim().isEmpty()) {
864+
String foldedString = concatResult.fst();
865+
if (foldedString.length() > 1000 && !foldedString.trim().isEmpty()) {
862866
return;
863867
}
864868
OffsetTranslation offsets = concatResult.snd();
865869
Position start = nd.getLoc().getStart();
866870
com.semmle.util.locations.Position startPos = new com.semmle.util.locations.Position(start.getLine(), start.getColumn(), start.getOffset());
867871
SourceMap sourceMap = SourceMap.legacyWithStartPos(SourceMap.fromString(nd.getLoc().getSource()).offsetBy(0, offsets), startPos);
868-
regexpExtractor.extract(rawString, sourceMap, nd, true);
872+
regexpExtractor.extract(foldedString, sourceMap, nd, true);
869873
return;
870874
}
871875

0 commit comments

Comments
 (0)