-
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
Second steps towards scalafix.v1 #809
Merged
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4981ff1
Rename v1.Sym to v1.Symbol
olafurpg 39aaa37
Break down v1.Symbol.{Info,Kind,...} into separate top-levels
olafurpg 7394d38
Implement missing methods in v1 symbol API
olafurpg 4a191e1
Implement Signature
olafurpg e1c4316
Complete rest of semanticdb data structures
olafurpg 65f9081
Implement conversions from protobuf to scalafix.v1
olafurpg c216efb
Remove several references to v0 from v1 package
olafurpg 839ad33
Make info(Symbol) return Option[SymbolInfo]
olafurpg 0595d7f
Migrate DisableSyntax to v1
olafurpg f934943
Migrate syntactic rules to v1
olafurpg 7198487
Make DisableSyntax.noFinalVal a linter instead of rewrite
olafurpg 52062c6
Add scala-xml
olafurpg eb376ab
Remove trailing commas
olafurpg 81cc01b
Clean up SemanticDoc by moving private[scalafix] to internal class
olafurpg 31cf36d
Make SymbolMatcher a trait defined by single Symbol => Boolean method
olafurpg 1ed54a4
Make Doc.tree and dependent values lazy
olafurpg d08dac0
Add sanity test suite for lazy value
olafurpg 82bfc0e
Assert values in new test suite
olafurpg 9fe94d8
Add an integration test to demonstrate that `LazyValue[Tree]` works
olafurpg 6eba621
Upgrade to latest scalameta milestone
olafurpg e7aee9c
Migrate message-based rules to v1
olafurpg 93c993a
s/LintMessage/Diagnostic/
olafurpg 535a233
Use clearer name for suppression skipping
olafurpg 2c70212
Simplify lint infrastructures
olafurpg 25a9603
Improve utilities for v1.Symbol
olafurpg 9e40b55
Upgrade ExplicitResultTypes to v1
olafurpg ea560e1
Migrate MissingFinal to v1
olafurpg 595f249
Migrate remaining syntactic rules
olafurpg d60f8c2
Rename v1.Type to v1.Tpe to avoid conflicts with scala.meta.Type
olafurpg a0217b2
Migrate DottyVarArgPattern and DottyKeywords to v1
olafurpg 868ff20
Use new isX methods from scalameta M10
olafurpg 87c3276
Pass in symbol table to SymbolInfo for improved toString
olafurpg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package scalafix.v1 | ||
|
||
import scala.runtime.Statics | ||
|
||
final class Annotation(val tpe: Type) { | ||
override def toString: String = s"Annotation($tpe)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: Annotation => | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package scalafix.v1 | ||
|
||
sealed abstract class Constant extends Product with Serializable | ||
case object UnitConstant extends Constant | ||
final case class BooleanConstant(value: Boolean) extends Constant | ||
final case class ByteConstant(value: Byte) extends Constant | ||
final case class ShortConstant(value: Short) extends Constant | ||
final case class CharConstant(value: Char) extends Constant | ||
final case class IntConstant(value: Int) extends Constant | ||
final case class LongConstant(value: Long) extends Constant | ||
final case class FloatConstant(value: Float) extends Constant | ||
final case class DoubleConstant(value: Double) extends Constant | ||
final case class StringConstant(value: String) extends Constant | ||
case object NullConstant extends Constant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,282 @@ | ||
package scalafix.v1 | ||
|
||
import scala.runtime.Statics | ||
sealed abstract class Type | ||
|
||
case object NoType extends Type | ||
|
||
final class TypeRef( | ||
val prefix: Type, | ||
val symbol: Symbol, | ||
val typeArguments: List[Type] | ||
) extends Type { | ||
override def toString: String = | ||
s"TypeRef($prefix,$symbol,$typeArguments)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: TypeRef => | ||
this.prefix == s.prefix && | ||
this.symbol == s.symbol && | ||
this.typeArguments == s.typeArguments | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(prefix)) | ||
acc = Statics.mix(acc, Statics.anyHash(symbol)) | ||
acc = Statics.mix(acc, Statics.anyHash(typeArguments)) | ||
Statics.finalizeHash(acc, 3) | ||
} | ||
} | ||
|
||
final class SingleType( | ||
val prefix: Type, | ||
val symbol: Symbol | ||
) extends Type { | ||
override def toString: String = | ||
s"SingleType($prefix,$symbol)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: TypeRef => | ||
this.prefix == s.prefix && | ||
this.symbol == s.symbol | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(prefix)) | ||
acc = Statics.mix(acc, Statics.anyHash(symbol)) | ||
Statics.finalizeHash(acc, 2) | ||
} | ||
} | ||
|
||
final class ThisType( | ||
val symbol: Symbol | ||
) extends Type { | ||
override def toString: String = | ||
s"ThisType($symbol)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: ThisType => | ||
this.symbol == s.symbol | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(symbol)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} | ||
|
||
final class SuperType( | ||
val prefix: Type, | ||
val symbol: Symbol | ||
) extends Type { | ||
override def toString: String = | ||
s"SuperType($prefix,$symbol)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: SuperType => | ||
this.prefix == s.prefix && | ||
this.symbol == s.symbol | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(prefix)) | ||
acc = Statics.mix(acc, Statics.anyHash(symbol)) | ||
Statics.finalizeHash(acc, 2) | ||
} | ||
} | ||
|
||
final class ConstantType( | ||
val constant: Constant | ||
) extends Type { | ||
override def toString: String = | ||
s"ConstantType($constant)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: ConstantType => | ||
this.constant == s.constant | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(constant)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} | ||
|
||
final class IntersectionType( | ||
val types: List[Type] | ||
) extends Type { | ||
override def toString: String = | ||
s"IntersectionType($types)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: IntersectionType => | ||
this.types == s.types | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(types)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} | ||
|
||
final class UnionType( | ||
val types: List[Type] | ||
) extends Type { | ||
override def toString: String = | ||
s"UnionType($types)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: UnionType => | ||
this.types == s.types | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(types)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} | ||
|
||
final class WithType( | ||
val types: List[Type] | ||
) extends Type { | ||
override def toString: String = | ||
s"WithType($types)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: WithType => | ||
this.types == s.types | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(types)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} | ||
|
||
final class StructuralType( | ||
val tpe: Type, | ||
val declarations: List[SymbolInfo], | ||
) extends Type { | ||
override def toString: String = | ||
s"StructuralType($tpe,$declarations)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: StructuralType => | ||
this.declarations == s.declarations && | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(declarations)) | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 2) | ||
} | ||
} | ||
|
||
final class AnnotatedType( | ||
val annotations: List[Annotation], | ||
val tpe: Type | ||
) extends Type { | ||
override def toString: String = | ||
s"AnnotatedType($annotations,$tpe)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: AnnotatedType => | ||
this.annotations == s.annotations && | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(annotations)) | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 2) | ||
} | ||
} | ||
|
||
final class ExistentialType( | ||
val tpe: Type, | ||
val declarations: List[SymbolInfo], | ||
) extends Type { | ||
override def toString: String = | ||
s"ExistentialType($tpe,$declarations)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: ExistentialType => | ||
this.declarations == s.declarations && | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(declarations)) | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 2) | ||
} | ||
} | ||
|
||
final class UniversalType( | ||
val tpe: Type, | ||
val declarations: List[SymbolInfo], | ||
) extends Type { | ||
override def toString: String = | ||
s"UniversalType($tpe,$declarations)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: UniversalType => | ||
this.declarations == s.declarations && | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(declarations)) | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 2) | ||
} | ||
} | ||
|
||
final class ByNameType( | ||
val tpe: Type | ||
) extends Type { | ||
override def toString: String = | ||
s"ByNameType($tpe)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: ByNameType => | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} | ||
|
||
final class RepeatedType( | ||
val tpe: Type | ||
) extends Type { | ||
override def toString: String = | ||
s"RepeatedType($tpe)" | ||
override def equals(obj: Any): Boolean = | ||
this.eq(obj.asInstanceOf[AnyRef]) || (obj match { | ||
case s: ByNameType => | ||
this.tpe == s.tpe | ||
case _ => false | ||
}) | ||
override def hashCode(): Int = { | ||
var acc = -889275714 | ||
acc = Statics.mix(acc, Statics.anyHash(tpe)) | ||
Statics.finalizeHash(acc, 1) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, removed.