From d6c3ae2fb49f1a62245d394a5eae85da457265c9 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 29 Jan 2019 12:58:32 +0000 Subject: [PATCH] JavaScript: Fix bug in extraction of `next_token`. --- .../src/com/semmle/js/extractor/LexicalExtractor.java | 2 +- javascript/extractor/src/com/semmle/js/extractor/Main.java | 2 +- javascript/ql/test/library-tests/Comments/next_token.expected | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/javascript/extractor/src/com/semmle/js/extractor/LexicalExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/LexicalExtractor.java index 242ce0d2a13..c7c9d017cff 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/LexicalExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/LexicalExtractor.java @@ -133,7 +133,7 @@ public class LexicalExtractor { locationManager.emitNodeLocation(token, key); // fill in next_token relation - while (j < comments.size() && comments.get(j).getLoc().getEnd().compareTo(token.getLoc().getStart()) < 0) + while (j < comments.size() && comments.get(j).getLoc().getEnd().compareTo(token.getLoc().getStart()) <= 0) trapwriter.addTuple("next_token", this.trapwriter.localID(comments.get(j++)), key); // the parser sometimes duplicates tokens; skip the second one by nulling it out diff --git a/javascript/extractor/src/com/semmle/js/extractor/Main.java b/javascript/extractor/src/com/semmle/js/extractor/Main.java index b6183eff35c..792823af247 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/Main.java +++ b/javascript/extractor/src/com/semmle/js/extractor/Main.java @@ -41,7 +41,7 @@ public class Main { * such a way that it may produce different tuples for the same file under the same * {@link ExtractorConfig}. */ - public static final String EXTRACTOR_VERSION = "2019-01-17"; + public static final String EXTRACTOR_VERSION = "2019-01-29"; public static final Pattern NEWLINE = Pattern.compile("\n"); diff --git a/javascript/ql/test/library-tests/Comments/next_token.expected b/javascript/ql/test/library-tests/Comments/next_token.expected index 69c22e8e57a..b68f4d93a7d 100644 --- a/javascript/ql/test/library-tests/Comments/next_token.expected +++ b/javascript/ql/test/library-tests/Comments/next_token.expected @@ -3,5 +3,5 @@ | comments.js:3:7:3:29 | HTML comment end | comments.js:7:10:7:17 | function | -| comments.js:7:1:7:9 | /*start*/ | comments.js:7:19:7:19 | f | -| comments.js:7:24:7:30 | /*end*/ | comments.js:8:1:8:0 | | +| comments.js:7:1:7:9 | /*start*/ | comments.js:7:10:7:17 | function | +| comments.js:7:24:7:30 | /*end*/ | comments.js:7:31:7:31 | } |