Skip to content
Snippets Groups Projects
Unverified Commit 9be56a19 authored by Shawn Garner's avatar Shawn Garner Committed by GitHub
Browse files

Parse dependency definitions inside single and multi-line Sequences inside...

Parse dependency definitions inside single and multi-line Sequences inside Scala dependency file (#10306)
parent 928afb53
No related merge requests found
...@@ -10,4 +10,11 @@ object Dependencies { ...@@ -10,4 +10,11 @@ object Dependencies {
val ujson = "com.example" %% "foo" % "0.7.1" val ujson = "com.example" %% "foo" % "0.7.1"
lazy val abc = "com.abc" % "abc" % abcVersion lazy val abc = "com.abc" % "abc" % abcVersion
val relatedDeps = Seq(
"com.abc" % "abc-a" % abcVersion,
"com.abc" % "abc-b" % abcVersion
)
val aloneDepInSeq = Seq("com.abc" % "abc-c" % abcVersion)
} }
...@@ -69,6 +69,36 @@ Object { ...@@ -69,6 +69,36 @@ Object {
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
Object {
"currentValue": "1.2.3",
"datasource": "sbt-package",
"depName": "com.abc:abc-a",
"groupName": "abcVersion for com.abc",
"lookupName": "com.abc:abc-a",
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
],
},
Object {
"currentValue": "1.2.3",
"datasource": "sbt-package",
"depName": "com.abc:abc-b",
"groupName": "abcVersion for com.abc",
"lookupName": "com.abc:abc-b",
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
],
},
Object {
"currentValue": "1.2.3",
"datasource": "sbt-package",
"depName": "com.abc:abc-c",
"groupName": "abcVersion for com.abc",
"lookupName": "com.abc:abc-c",
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
],
},
], ],
"packageFileVersion": undefined, "packageFileVersion": undefined,
} }
......
...@@ -86,6 +86,16 @@ const isVarDef = (str: string): boolean => ...@@ -86,6 +86,16 @@ const isVarDef = (str: string): boolean =>
str str
); );
const isVarSeqSingleLine = (str: string): boolean =>
/^\s*(private\s*)?(lazy\s*)?val\s+[_a-zA-Z][_a-zA-Z0-9]*\s*=\s*Seq\(.*\).*\s*$/.test(
str
);
const isVarSeqMultipleLine = (str: string): boolean =>
/^\s*(private\s*)?(lazy\s*)?val\s+[_a-zA-Z][_a-zA-Z0-9]*\s*=\s*Seq\(.*[^)]*.*$/.test(
str
);
const getVarName = (str: string): string => const getVarName = (str: string): string =>
str str
.replace(/^\s*(private\s*)?(lazy\s*)?val\s+/, '') .replace(/^\s*(private\s*)?(lazy\s*)?val\s+/, '')
...@@ -231,6 +241,18 @@ function parseSbtLine( ...@@ -231,6 +241,18 @@ function parseSbtLine(
isMultiDeps = false; isMultiDeps = false;
const url = getResolverUrl(line); const url = getResolverUrl(line);
registryUrls.push(url); registryUrls.push(url);
} else if (isVarSeqSingleLine(line)) {
isMultiDeps = false;
const depExpr = line.replace(/^.*Seq\(\s*/, '').replace(/\).*$/, '');
dep = parseDepExpr(depExpr, {
...ctx,
});
} else if (isVarSeqMultipleLine(line)) {
isMultiDeps = true;
const depExpr = line.replace(/^.*Seq\(\s*/, '');
dep = parseDepExpr(depExpr, {
...ctx,
});
} else if (isVarDef(line)) { } else if (isVarDef(line)) {
variables[getVarName(line)] = getVarInfo(line, ctx); variables[getVarName(line)] = getVarInfo(line, ctx);
} else if (isVarDependency(line)) { } else if (isVarDependency(line)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment