Skip to content

Commit

Permalink
Merge pull request #304 from apex-dev-tools/303-improve-super-type-de…
Browse files Browse the repository at this point in the history
…claration-performance-lookup

303 improve super type declaration performance lookup
  • Loading branch information
pwrightcertinia authored Dec 3, 2024
2 parents 7068aaa + 739a8d5 commit b1f9340
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,25 @@ trait ApexClassDeclaration extends ApexDeclaration with DependencyHolder {
/** Override to handle request to flush the type to passed cache if dirty */
def flush(pc: ParsedCache, context: PackageContext): Unit

override def superClassDeclaration: Option[TypeDeclaration] =
superClass.flatMap(sc => TypeResolver(sc, this).toOption)
private var _superClassDeclaration: Option[TypeDeclaration] = None

override def interfaceDeclarations: ArraySeq[TypeDeclaration] =
interfaces.flatMap(i => TypeResolver(i, this).toOption)
override def superClassDeclaration: Option[TypeDeclaration] = {
// Don't cache empty as maybe currently missing
if (_superClassDeclaration.isEmpty) {
_superClassDeclaration = superClass.flatMap(sc => TypeResolver(sc, this).toOption)
}
_superClassDeclaration
}

private var _interfaceDeclarations: ArraySeq[TypeDeclaration] = ArraySeq.empty

override def interfaceDeclarations: ArraySeq[TypeDeclaration] = {
// Don't cache empty as maybe currently missing
if (_interfaceDeclarations.size != interfaces.size) {
_interfaceDeclarations = interfaces.flatMap(i => TypeResolver(i, this).toOption)
}
_interfaceDeclarations
}

/** Obtain a source hash for this class and all it's ancestors */
def deepHash: Int = {
Expand Down

0 comments on commit b1f9340

Please sign in to comment.