Merge pull request #4486 from erik-krogh/lessTokens

Approved by asgerf
This commit is contained in:
CodeQL CI
2020-10-21 02:56:38 -07:00
committed by GitHub
5 changed files with 20 additions and 6 deletions

View File

@@ -77,7 +77,7 @@ VarAccess getFirstCandidateAccess(ImportDeclaration decl) {
result =
min(decl.getASpecifier().getLocal().getVariable().getAnAccess().(CandidateVarAccess) as p
order by
p.getFirstToken().getIndex()
p.getLocation().getStartLine(), p.getLocation().getStartColumn()
)
}

View File

@@ -1609,7 +1609,9 @@ private string getConcatenatedString(Expr add) {
strictconcat(Expr leaf |
leaf = getAnAddOperand*(add)
|
getConstantString(leaf) order by leaf.getFirstToken().getIndex()
getConstantString(leaf)
order by
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
) and
result.length() < 1000 * 1000
}

View File

@@ -576,7 +576,9 @@ module StringOps {
strictconcat(StringLiteralLike leaf |
leaf = getALeaf().asExpr()
|
leaf.getStringValue() order by leaf.getFirstToken().getIndex()
leaf.getStringValue()
order by
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
)
}
}

View File

@@ -466,7 +466,11 @@ class LocalTypeName extends @local_type_name, LexicalName {
* Gets the first declaration of this type name.
*/
TypeDecl getFirstDeclaration() {
result = min(getADeclaration() as decl order by decl.getFirstToken().getIndex())
result =
min(getADeclaration() as decl
order by
decl.getLocation().getStartLine(), decl.getLocation().getStartColumn()
)
}
/** Gets a use of this type name in a type annotation. */
@@ -526,7 +530,11 @@ class LocalNamespaceName extends @local_namespace_name, LexicalName {
* Gets the first declaration of this namespace name.
*/
LocalNamespaceDecl getFirstDeclaration() {
result = min(getADeclaration() as decl order by decl.getFirstToken().getIndex())
result =
min(getADeclaration() as decl
order by
decl.getLocation().getStartLine(), decl.getLocation().getStartColumn()
)
}
/** Gets a use of this namespace name in a type annotation. */

View File

@@ -239,7 +239,9 @@ module PrettyPrintCatCall {
concat(Expr leaf |
leaf = root.getALeaf().asExpr()
|
createLeafRepresentation(leaf), " + " order by leaf.getFirstToken().getIndex()
createLeafRepresentation(leaf), " + "
order by
leaf.getLocation().getStartLine(), leaf.getLocation().getStartColumn()
)
or
// Template string