Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9faf675

Browse files
authored
Merge pull request #4486 from erik-krogh/lessTokens
Approved by asgerf
2 parents 3fe2a17 + 9112d41 commit 9faf675

5 files changed

Lines changed: 20 additions & 6 deletions

File tree

javascript/ql/src/Declarations/UnstableCyclicImport.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ VarAccess getFirstCandidateAccess(ImportDeclaration decl) {
7777
result =
7878
min(decl.getASpecifier().getLocal().getVariable().getAnAccess().(CandidateVarAccess) as p
7979
order by
80-
p.getFirstToken().getIndex()
80+
p.getLocation().getStartLine(), p.getLocation().getStartColumn()
8181
)
8282
}
8383

javascript/ql/src/semmle/javascript/Expr.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,9 @@ private string getConcatenatedString(Expr add) {
16091609
strictconcat(Expr leaf |
16101610
leaf = getAnAddOperand*(add)
16111611
|
1612-
getConstantString(leaf) order by leaf.getFirstToken().getIndex()
1612+
getConstantString(leaf)
1613+
order by
1614+
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
16131615
) and
16141616
result.length() < 1000 * 1000
16151617
}

javascript/ql/src/semmle/javascript/StringOps.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,9 @@ module StringOps {
576576
strictconcat(StringLiteralLike leaf |
577577
leaf = getALeaf().asExpr()
578578
|
579-
leaf.getStringValue() order by leaf.getFirstToken().getIndex()
579+
leaf.getStringValue()
580+
order by
581+
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
580582
)
581583
}
582584
}

javascript/ql/src/semmle/javascript/TypeScript.qll

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ class LocalTypeName extends @local_type_name, LexicalName {
466466
* Gets the first declaration of this type name.
467467
*/
468468
TypeDecl getFirstDeclaration() {
469-
result = min(getADeclaration() as decl order by decl.getFirstToken().getIndex())
469+
result =
470+
min(getADeclaration() as decl
471+
order by
472+
decl.getLocation().getStartLine(), decl.getLocation().getStartColumn()
473+
)
470474
}
471475

472476
/** Gets a use of this type name in a type annotation. */
@@ -526,7 +530,11 @@ class LocalNamespaceName extends @local_namespace_name, LexicalName {
526530
* Gets the first declaration of this namespace name.
527531
*/
528532
LocalNamespaceDecl getFirstDeclaration() {
529-
result = min(getADeclaration() as decl order by decl.getFirstToken().getIndex())
533+
result =
534+
min(getADeclaration() as decl
535+
order by
536+
decl.getLocation().getStartLine(), decl.getLocation().getStartColumn()
537+
)
530538
}
531539

532540
/** Gets a use of this namespace name in a type annotation. */

javascript/ql/src/semmle/javascript/security/UselessUseOfCat.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ module PrettyPrintCatCall {
239239
concat(Expr leaf |
240240
leaf = root.getALeaf().asExpr()
241241
|
242-
createLeafRepresentation(leaf), " + " order by leaf.getFirstToken().getIndex()
242+
createLeafRepresentation(leaf), " + "
243+
order by
244+
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
243245
)
244246
or
245247
// Template string

0 commit comments

Comments
 (0)