-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expose methods used by Scaladoc in Quotes API #13382
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,6 +246,13 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |
optional(self.rhs.asInstanceOf[tpd.Template].self) | ||
def body: List[Statement] = | ||
self.rhs.asInstanceOf[tpd.Template].body | ||
def tpe: TypeRepr = | ||
self.symbol.typeRef.appliedTo(self.symbol.typeParams.map(_.typeRef)) | ||
def supertypes: List[TypeRepr] = self.symbol match | ||
case cls: dotc.core.Symbols.ClassSymbol => | ||
val ref = cls.classDenot.classInfo.appliedRef | ||
ref.baseClasses.map(ref.baseType(_)) | ||
case _ => List() | ||
end extension | ||
end ClassDefMethods | ||
|
||
|
@@ -1694,11 +1701,17 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |
val tpNoRefinement = self.dropDependentRefinement | ||
tpNoRefinement != self | ||
&& dotc.core.Symbols.defn.isNonRefinedFunction(tpNoRefinement) | ||
def isTupleType: Boolean = | ||
dotc.core.Symbols.defn.isTupleType(self) | ||
def isCompiletimeAppliedType: Boolean = | ||
dotc.core.Symbols.defn.isCompiletimeAppliedType(self.typeSymbol) | ||
def select(sym: Symbol): TypeRepr = self.select(sym) | ||
def appliedTo(targ: TypeRepr): TypeRepr = | ||
dotc.core.Types.decorateTypeApplications(self).appliedTo(targ) | ||
def appliedTo(targs: List[TypeRepr]): TypeRepr = | ||
dotc.core.Types.decorateTypeApplications(self).appliedTo(targs) | ||
def memberInfo(sym: Symbol): TypeRepr = | ||
self.memberInfo(sym) | ||
end extension | ||
end TypeReprMethods | ||
|
||
|
@@ -2465,6 +2478,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |
def isAnonymousFunction: Boolean = self.denot.isAnonymousFunction | ||
def isAbstractType: Boolean = self.denot.isAbstractType | ||
def isClassConstructor: Boolean = self.denot.isClassConstructor | ||
def isSuperAccessor = self.name.is(dotc.core.NameKinds.SuperAccessorName) | ||
def isType: Boolean = self.isType | ||
def isTerm: Boolean = self.isTerm | ||
def isPackageDef: Boolean = self.is(dotc.core.Flags.Package) | ||
|
@@ -2544,6 +2558,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |
def typeMembers: List[Symbol] = | ||
self.unforcedDecls.filter(_.isType) | ||
|
||
def allTypeMembers: List[Symbol] = | ||
lookupPrefix.allMembers.iterator.map(_.symbol).collect { | ||
case sym if sym.isType => sym.asType | ||
}.toList | ||
|
||
def declarations: List[Symbol] = | ||
self.typeRef.info.decls.toList | ||
|
||
|
@@ -2733,6 +2752,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |
def sourceCode: Option[String] = | ||
// TODO detect when we do not have a source and return None | ||
Some(new String(self.source.content(), self.start, self.end - self.start)) | ||
def exists: Boolean = self.exists | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe all positions should exist. If one does not we should figure out why it is not set. |
||
end extension | ||
end PositionMethods | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,6 +490,10 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |
* @syntax markdown | ||
*/ | ||
def body: List[Statement] | ||
/** Type of the class */ | ||
def tpe: TypeRepr | ||
/** Supertypes of the class */ | ||
def supertypes: List[TypeRepr] | ||
end extension | ||
end ClassDefMethods | ||
|
||
|
@@ -2473,6 +2477,17 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |
*/ | ||
def isDependentFunctionType: Boolean | ||
|
||
/** Is this type a tuple type? | ||
* | ||
* @return true if the dealiased type of `self` without refinement is `TupleN[T1, T2, ..., Tn]` | ||
*/ | ||
def isTupleType: Boolean | ||
|
||
/** Is this type a compile-time applied type? | ||
* | ||
*/ | ||
def isCompiletimeAppliedType: Boolean | ||
|
||
/** The type <this . sym>, reduced if possible */ | ||
def select(sym: Symbol): TypeRepr | ||
|
||
|
@@ -2482,6 +2497,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |
/** The current type applied to given type arguments: `this[targ0, ..., targN]` */ | ||
def appliedTo(targs: List[TypeRepr]): TypeRepr | ||
|
||
/** Member info of `sym` as seen from the TypeRepr */ | ||
def memberInfo(sym: Symbol): TypeRepr | ||
|
||
end extension | ||
} | ||
|
||
|
@@ -3559,6 +3577,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |
/** Is this the constructor of a class? */ | ||
def isClassConstructor: Boolean | ||
|
||
/* Is this the super accessor? */ | ||
def isSuperAccessor: Boolean | ||
|
||
/** Is this the definition of a type? */ | ||
def isType: Boolean | ||
|
||
|
@@ -3649,6 +3670,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |
/** Type member directly declared in the class */ | ||
def typeMembers: List[Symbol] | ||
|
||
Comment on lines
3670
to
3672
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see there some inconsistency as |
||
/** All type members declared or inherited */ | ||
def allTypeMembers: List[Symbol] | ||
|
||
/** All members directly declared in the class */ | ||
def declarations: List[Symbol] | ||
|
||
|
@@ -4126,6 +4150,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |
/** Source code within the position */ | ||
def sourceCode: Option[String] | ||
|
||
/** Does the position exist? */ | ||
def exists: Boolean | ||
|
||
end extension | ||
} | ||
|
||
|
This file was deleted.
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.
Applying this type to the types refs of the parameter symbol seems wrong. Not sure what the resulting type represents.