Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AstNodeBuilder(
.lineNumber(line)
.columnNumber(column)
.order(orderTracker.order)
.index(orderTracker.order)
.typeFullName(Defines.Any)

diffGraph.addNode(param)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,11 @@ class MixedAstCreationPassTest extends AbstractPassTest {
val List(a) = fooMethod.parameter.nameExact("param1_0").l
a.code shouldBe "{a}"
a.order shouldBe 1
a.index shouldBe 1
val List(b) = fooMethod.parameter.nameExact("b").l
b.code shouldBe "b"
b.order shouldBe 2
b.index shouldBe 2
}

"have correct structure for object destruction assignment in call argument" in AstFixture("foo({a, b} = x);") {
Expand Down Expand Up @@ -1071,6 +1073,7 @@ class MixedAstCreationPassTest extends AbstractPassTest {

val List(paramA) = foo.parameter.nameExact("a").l
paramA.order shouldBe 1
paramA.index shouldBe 1

val List(block) = foo.astChildren.isBlock.l
val List(assignment) = block.astChildren.isCall.l
Expand All @@ -1090,9 +1093,11 @@ class MixedAstCreationPassTest extends AbstractPassTest {
val List(foo) = cpg.method.nameExact("foo").l
val List(paramA) = foo.parameter.nameExact("a").l
paramA.order shouldBe 1
paramA.index shouldBe 1

val List(paramB) = foo.parameter.nameExact("b").l
paramB.order shouldBe 2
paramB.index shouldBe 2

val List(block) = foo.astChildren.isBlock.l

Expand Down Expand Up @@ -1123,8 +1128,10 @@ class MixedAstCreationPassTest extends AbstractPassTest {
val List(foo) = cpg.method.nameExact("foo").l
val List(paramA) = foo.parameter.nameExact("a").l
paramA.order shouldBe 1
paramA.index shouldBe 1
val List(paramB) = foo.parameter.nameExact("b").l
paramB.order shouldBe 2
paramB.index shouldBe 2

val List(block) = foo.astChildren.isBlock.l
val List(assignmentB) = block.astChildren.isCall.codeExact("b = b === void 0 ? 1 : b").l
Expand All @@ -1144,10 +1151,13 @@ class MixedAstCreationPassTest extends AbstractPassTest {
val List(foo) = cpg.method.nameExact("foo").l
val List(paramA) = foo.parameter.nameExact("a").l
paramA.order shouldBe 1
paramA.index shouldBe 1
val List(paramB) = foo.parameter.nameExact("b").l
paramB.order shouldBe 2
paramB.index shouldBe 2
val List(paramC) = foo.parameter.nameExact("c").l
paramC.order shouldBe 3
paramC.index shouldBe 3

val List(block) = foo.astChildren.isBlock.l
val List(assignmentB) = block.astChildren.isCall.codeExact("b = b === void 0 ? 1 : b").l
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,12 @@ class SimpleAstCreationPassTest extends AbstractPassTest {

val List(param1, param2) = lambda.parameter.l
param1.order shouldBe 0
param1.index shouldBe 0
param1.name shouldBe "this"
param1.code shouldBe "this"

param2.order shouldBe 1
param2.index shouldBe 1
param2.name shouldBe "param1_0"
param2.code shouldBe "{param}"

Expand Down Expand Up @@ -452,8 +454,16 @@ class SimpleAstCreationPassTest extends AbstractPassTest {
"have correct structure for empty method" in AstFixture("function method(x) {}") { cpg =>
val List(method) = cpg.method.nameExact("method").l
method.astChildren.isBlock.size shouldBe 1
method.parameter.order(0).nameExact("this").typeFullName(Defines.Any).size shouldBe 1
method.parameter.order(1).nameExact("x").typeFullName(Defines.Any).size shouldBe 1

val List(thisParam, xParam) = method.parameter.l
thisParam.order shouldBe 0
thisParam.index shouldBe 0
thisParam.name shouldBe "this"
thisParam.typeFullName shouldBe Defines.Any
xParam.order shouldBe 1
xParam.index shouldBe 1
xParam.name shouldBe "x"
xParam.typeFullName shouldBe Defines.Any
}

"have correct structure for decl assignment" in AstFixture("function foo(x) { var local = 1; }") { cpg =>
Expand All @@ -462,9 +472,11 @@ class SimpleAstCreationPassTest extends AbstractPassTest {

val List(t, x) = method.parameter.l
t.order shouldBe 0
t.index shouldBe 0
t.name shouldBe "this"
t.typeFullName shouldBe Defines.Any
x.order shouldBe 1
x.index shouldBe 1
x.name shouldBe "x"
x.typeFullName shouldBe Defines.Any

Expand All @@ -484,9 +496,11 @@ class SimpleAstCreationPassTest extends AbstractPassTest {

val List(t, x) = method.parameter.l
t.order shouldBe 0
t.index shouldBe 0
t.name shouldBe "this"
t.typeFullName shouldBe Defines.Any
x.order shouldBe 1
x.index shouldBe 1
x.name shouldBe "x"
x.typeFullName shouldBe Defines.Any

Expand All @@ -507,12 +521,15 @@ class SimpleAstCreationPassTest extends AbstractPassTest {

val List(t, x, y) = method.parameter.l
t.order shouldBe 0
t.index shouldBe 0
t.name shouldBe "this"
t.typeFullName shouldBe Defines.Any
x.order shouldBe 1
x.index shouldBe 1
x.name shouldBe "x"
x.typeFullName shouldBe Defines.Any
y.order shouldBe 2
y.index shouldBe 2
y.name shouldBe "y"
y.typeFullName shouldBe Defines.Any

Expand Down Expand Up @@ -681,9 +698,11 @@ class SimpleAstCreationPassTest extends AbstractPassTest {
val List(method) = cpg.method.nameExact("method").l

val List(parameterInX) = method.parameter.order(1).l
parameterInX.index shouldBe 1
parameterInX.name shouldBe "x"

val List(parameterInY) = method.parameter.order(2).l
parameterInY.index shouldBe 2
parameterInY.name shouldBe "y"

val List(methodBlock) = method.astChildren.isBlock.l
Expand Down