Skip to content

Commit

Permalink
ConfigOps: sourceroot as relative to targetroot (#3280)
Browse files Browse the repository at this point in the history
That is, one could specify `-P:semanticdb:sourceroot:targetroot:../xyz`.
  • Loading branch information
kitbellew committed Jul 26, 2023
1 parent 9828e76 commit 77b90a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/semanticdb/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ and the "Value" column describes the `<value>` component):
<td>
Used to relativize source file paths into
<code>TextDocument.uri</code>.
<br/>
If the value starts with `targetroot:`, the remaining part is
interpreted as relative to `targetroot` (see below; must be
specified first) instead of current working directory.
</td>
<td>Current working directory</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,18 @@ object SemanticdbConfig {
config = config.copy(fileFilter = config.fileFilter.copy(include = include.r))
case SetExclude(exclude) =>
config = config.copy(fileFilter = config.fileFilter.copy(exclude = exclude.r))
case SetSourceroot(path) =>
config = config.copy(sourceroot = AbsolutePath(path))
case SetSourceroot(pattern) =>
val abspath = pattern match {
case SetTargetroot(relative) =>
if (config.targetroot eq SemanticdbConfig.default.targetroot)
reporter.error(
NoPosition,
s"${prefix}sourceroot:$pattern must follow '${prefix}targetroot:'."
)
config.targetroot.resolve(relative)
case p => AbsolutePath(p)
}
config = config.copy(sourceroot = abspath)
case SetTargetroot(path) =>
config = config.copy(targetroot = AbsolutePath(path))
case SetText(BinaryMode(mode)) =>
Expand Down

0 comments on commit 77b90a4

Please sign in to comment.