-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect -P:semanticdb:exclude #875
Comments
I think this is scalameta/scalameta#1038 (which has been closed but it's not fixed) |
Is there a workaround? @gabro It is still not working after excluding file. unmanagedSources.in(Compile, scalafix) := unmanagedSources.in(Compile).value.filterNot(file =>file.getName.contains("Macros"))
here Macros is Macros.scala file that has macro related code. |
As a workaround, you can add a dummy statement before the class DefineImplicits() extends scala.annotation.StaticAnnotation {
val dummy = 42
// scalafix:off
inline def apply(defn: Any): Any = meta {
// ...
} This works because the bug only happens when |
(I'm tracking the new issue here scalameta/scalameta#1776) |
Ok, thank you @gabro Do you have an idea why it is not excluding file? |
No, I have no idea. It could be that it still tries to parse the file before excluding it, but I'm not sure. |
Ok thank you @gabro but the workaround is not working. val dummy = 42
inline def apply(defn: Any): Any = meta { -} |
is it the same exact error? |
@gabro Yes, it is same. error: ; expected but def found
[error] inline def apply(defn: Any): Any = meta {
[error] ^
|
Mm, it might be slightly different then. We'll have to wait for @olafurpg to clear this up. |
@gabro anyway thank you! |
@abdheshkumar Is the error reported during compilation or after running scalafix? Either way, I am afraid that scalafix semantic rules won't work for source files where inline/meta macro annotations are used. It is not enough to exclude the file defining the macro but also all files where the macros are used. The inline/meta macro annotations are no longer under development and it is recommended to use org.scalamacros:paradise annotations instead (which have been merged into the Scala compiler for 2.13). To exclude a file from compilation with semanticdb-scalac, add the following to your build scalacOptions += "-P:semanticdb:exclude:Macros" To support the
|
@olafurpg thank you so much for the detailed reply. I am getting that error while running |
@olafurpg Looks like that error has gone now. // scalafix:off
q"""
Map(${cases: _*})
"""
// scalafix:on I am getting error: repeated argument not allowed here
[error] Map(${cases: _*})
[error] ^
|
I think, `scalacOptions += "-P:semanticdb:exclude:Macros|Schema" fixed the problems. |
What happens if you change to |
@olafurpg thank you that trick solved [info] Running scalafix on 22 Scala sources
[error] SemanticDB not found: META-INF/semanticdb/libraries/utils/shared/src/main/scala/utils/implicits/Macros.scala.semanticdb
[error] (Compile / scalafix) scalafix.sbt.ScalafixFailed: MissingSemanticdbError
[error] Total time: 18 s, completed 21-Sep-2018 01:10:05
sbt:utilities library> I have equired scalacOptions enabled and semanticdb-scalac compile plugin. sbt:utilities library> show scalacOptions
[info] * -unchecked
[info] * -deprecation
[info] * -feature
[info] * -language:higherKinds
[info] * -Ypartial-unification
[info] * -Yrangepos
[info] * -Ywarn-unused-import
[info] * -P:semanticdb:exclude:Macros
[success] Total time: 9 s, completed 21-Sep-2018 01:13:33
sbt:utilities library> show libraryDependencies
[info] * org.spire-math:kind-projector:0.9.3:plugin->default(compile)
[info] * org.scalamacros:paradise:2.1.0:plugin->default(compile)
[info] * org.scalameta:paradise:3.0.0-M11:plugin->default(compile)
[info] * org.scalameta:semanticdb-scalac:4.0.0-RC1:plugin->default(compile) Please, could you help me on this too? |
Do you have the following settings enabled?
The error happens because "Macros.scala" is one of the 22 sources in the "Running scalafix on 22 Scala sources" message. |
You can validate which files are processed by running |
I think the best solution here is to make scalafix respect the |
Pending fix #885 |
Reproduce:
https://gitter.im/scalacenter/scalafix?at=5ba395ea5df5194734e91fef
Error:
The text was updated successfully, but these errors were encountered: