diff options
| author | Jim Lawson | 2019-03-18 12:17:33 -0700 |
|---|---|---|
| committer | GitHub | 2019-03-18 12:17:33 -0700 |
| commit | 2c449c5d6e23dcbb60e8c64cab6b6f4ba6ae313f (patch) | |
| tree | 3daffa8eb0f57faf31d3977700be38f5be31e59a /coreMacros | |
| parent | cfb2f08db9d9df121a82f138dd71297dbcea66cc (diff) | |
Split #974 into two PRs - scalastyle updates (#1037)
* Update style warnings now that subprojects are aggregated.
Use "scalastyle-test-config.xml" for scalastyle config in tests.
Enable "_" in method names and accept method names ending in "_=".
Re-sync scalastyle-test-config.xml with scalastyle-config.xml
* Remove bogus tests that crept in with git add
* Add missing import.
Diffstat (limited to 'coreMacros')
5 files changed, 19 insertions, 15 deletions
diff --git a/coreMacros/src/main/scala/chisel3/SourceInfoDoc.scala b/coreMacros/src/main/scala/chisel3/SourceInfoDoc.scala index 2f14585e..4e7533d4 100644 --- a/coreMacros/src/main/scala/chisel3/SourceInfoDoc.scala +++ b/coreMacros/src/main/scala/chisel3/SourceInfoDoc.scala @@ -1,4 +1,4 @@ -// See LICENSE for license details +// See LICENSE for license details. package chisel3 diff --git a/coreMacros/src/main/scala/chisel3/internal/RangeTransform.scala b/coreMacros/src/main/scala/chisel3/internal/RangeTransform.scala index 2f16083e..4977899a 100644 --- a/coreMacros/src/main/scala/chisel3/internal/RangeTransform.scala +++ b/coreMacros/src/main/scala/chisel3/internal/RangeTransform.scala @@ -13,6 +13,7 @@ import scala.reflect.macros.whitebox object RangeTransform class RangeTransform(val c: Context) { import c.universe._ + // scalastyle:off method.length line.size.limit def apply(args: c.Tree*): c.Tree = { val stringTrees = c.prefix.tree match { case q"$_(scala.StringContext.apply(..$strings))" => strings @@ -22,6 +23,7 @@ class RangeTransform(val c: Context) { case Literal(Constant(string: String)) => string case _ => c.abort(c.enclosingPosition, s"Range macro unable to parse StringContext element, got: ${showRaw(tree)}") } } + // scalastyle:on line.size.limit var nextStringIndex: Int = 1 var nextArgIndex: Int = 0 diff --git a/coreMacros/src/main/scala/chisel3/internal/RuntimeDeprecationTransform.scala b/coreMacros/src/main/scala/chisel3/internal/RuntimeDeprecationTransform.scala index 570e5383..1ba41a6d 100644 --- a/coreMacros/src/main/scala/chisel3/internal/RuntimeDeprecationTransform.scala +++ b/coreMacros/src/main/scala/chisel3/internal/RuntimeDeprecationTransform.scala @@ -22,7 +22,7 @@ class RuntimeDeprecatedTransform(val c: Context) { case q"new deprecated($desc, $since)" => desc } match { // ensure there's only one and return it case msg :: Nil => msg - case _ => c.abort(c.enclosingPosition, s"@chiselRuntimeDeprecated annotion must be used with exactly one @deprecated annotation, got annotations $annotations") + case _ => c.abort(c.enclosingPosition, s"@chiselRuntimeDeprecated annotion must be used with exactly one @deprecated annotation, got annotations $annotations") // scalastyle:ignore line.size.limit } val message = s"$tname is deprecated: $annotationMessage" val transformedExpr = q""" { @@ -31,7 +31,7 @@ class RuntimeDeprecatedTransform(val c: Context) { } """ q"$mods def $tname[..$tparams](...$paramss): $tpt = $transformedExpr" } - case other => c.abort(c.enclosingPosition, s"@chiselRuntimeDeprecated annotion may only be used on defs, got ${showCode(other)}") + case other => c.abort(c.enclosingPosition, s"@chiselRuntimeDeprecated annotion may only be used on defs, got ${showCode(other)}") // scalastyle:ignore line.size.limit }) q"..$transformed" } diff --git a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala index 29b27b9e..fba526af 100644 --- a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala +++ b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/NamingAnnotations.scala @@ -62,7 +62,7 @@ class NamingTransforms(val c: Context) { trait ValNameTransformer extends Transformer { val contextVar: TermName - override def transform(tree: Tree) = tree match { + override def transform(tree: Tree): Tree = tree match { // Intentionally not prefixed with $mods, since modifiers usually mean the val definition // is in a non-transformable location, like as a parameter list. // TODO: is this exhaustive / correct in all cases? @@ -79,8 +79,8 @@ class NamingTransforms(val c: Context) { * classes and applies the naming transform on inner functions. */ class ModuleTransformer(val contextVar: TermName) extends ValNameTransformer { - override def transform(tree: Tree) = tree match { - case q"$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$stats }" => + override def transform(tree: Tree): Tree = tree match { + case q"$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$stats }" => // scalastyle:ignore line.size.limit tree // don't recurse into inner classes case q"$mods trait $tpname[..$tparams] extends { ..$earlydefns } with ..$parents { $self => ..$stats }" => tree // don't recurse into inner classes @@ -105,7 +105,7 @@ class NamingTransforms(val c: Context) { /** Method-specific val name transform, handling the return case. */ class MethodTransformer(val contextVar: TermName) extends ValNameTransformer { - override def transform(tree: Tree) = tree match { + override def transform(tree: Tree): Tree = tree match { // TODO: better error messages when returning nothing case q"return $expr" => q"return $globalNamingStack.pop_return_context($expr, $contextVar)" // Do not recurse into methods @@ -117,7 +117,7 @@ class NamingTransforms(val c: Context) { /** Applies the val name transform to a module body. Pretty straightforward, since Module is * the naming top level. */ - def transformModuleBody(stats: List[c.Tree]) = { + def transformModuleBody(stats: List[c.Tree]): Tree = { val contextVar = TermName(c.freshName("namingContext")) val transformedBody = (new ModuleTransformer(contextVar)).transformTrees(stats) @@ -132,7 +132,7 @@ class NamingTransforms(val c: Context) { /** Applies the val name transform to a method body, doing additional bookkeeping with the * context to allow names to propagate and prefix through the function call stack. */ - def transformHierarchicalMethod(expr: c.Tree) = { + def transformHierarchicalMethod(expr: c.Tree): Tree = { val contextVar = TermName(c.freshName("namingContext")) val transformedBody = (new MethodTransformer(contextVar)).transform(expr) @@ -161,6 +161,7 @@ class NamingTransforms(val c: Context) { var namedElts: Int = 0 val transformed = annottees.map(annottee => annottee match { + // scalastyle:off line.size.limit case q"$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$stats }" => { val transformedStats = transformModuleBody(stats) namedElts += 1 @@ -181,20 +182,21 @@ class NamingTransforms(val c: Context) { if (namedElts != 1) { c.abort(c.enclosingPosition, s"@chiselName annotation did not match exactly one valid tree, got:\r\n${annottees.map(tree => showCode(tree)).mkString("\r\n\r\n")}") } + // scalastyle:on line.size.limit q"..$transformed" } } @compileTimeOnly("enable macro paradise to expand macro annotations") -class dump extends StaticAnnotation { +class dump extends StaticAnnotation { // scalastyle:ignore class.name def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.DebugTransforms.dump } @compileTimeOnly("enable macro paradise to expand macro annotations") -class treedump extends StaticAnnotation { +class treedump extends StaticAnnotation { // scalastyle:ignore class.name def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.DebugTransforms.treedump } @compileTimeOnly("enable macro paradise to expand macro annotations") -class chiselName extends StaticAnnotation { +class chiselName extends StaticAnnotation { // scalastyle:ignore class.name def macroTransform(annottees: Any*): Any = macro chisel3.internal.naming.NamingTransforms.chiselName } diff --git a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala index aa474cb6..48036ce7 100644 --- a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala +++ b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala @@ -22,7 +22,7 @@ import scala.reflect.macros.whitebox trait SourceInfoTransformMacro { val c: Context import c.universe._ - def thisObj = c.prefix.tree + def thisObj: Tree = c.prefix.tree def implicitSourceInfo = q"implicitly[_root_.chisel3.internal.sourceinfo.SourceInfo]" def implicitCompileOptions = q"implicitly[_root_.chisel3.core.CompileOptions]" } @@ -94,10 +94,10 @@ abstract class AutoSourceTransform extends SourceInfoTransformMacro { /** Returns the TermName of the transformed function, which is the applied function name with do_ * prepended. */ - def doFuncTerm = { + def doFuncTerm: TermName = { val funcName = c.macroApplication match { case q"$_.$funcName[..$_](...$_)" => funcName - case _ => throw new Exception(s"Chisel Internal Error: Could not resolve function name from macro application: ${showCode(c.macroApplication)}") + case _ => throw new Exception(s"Chisel Internal Error: Could not resolve function name from macro application: ${showCode(c.macroApplication)}") // scalastyle:ignore line.size.limit } TermName("do_" + funcName) } |
