Skip to content
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

226 rename provider expanded with visitor pattern #237

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
805598c
remove unused imports from HoverProvider
jjohnsoncertinia Sep 29, 2023
8e1e165
add getTargetLocationForMethodCallOut and cachedMethod to MethodCallW…
jjohnsoncertinia Sep 29, 2023
bf9e095
add boundExpressions to SOSL
jjohnsoncertinia Sep 29, 2023
fc4b15d
add getMethodSymbolLocations for global function renaming
jjohnsoncertinia Sep 29, 2023
86271c4
Merge branch 'main' into 226-rename-provider-expanded-with-visitor-pa…
kjonescertinia Sep 29, 2023
e02d201
add missing imports after main merge
jjohnsoncertinia Sep 30, 2023
a80101e
resolve warnings for braces
jjohnsoncertinia Sep 30, 2023
aa5525c
add support for renaming from method declaration
jjohnsoncertinia Sep 30, 2023
2d3dc38
remove redundant match statement
jjohnsoncertinia Oct 6, 2023
626277a
Safeguard option.get with option.getOrElse
jjohnsoncertinia Oct 6, 2023
390e25b
Merge remote-tracking branch 'origin/238-remove-use-of-eagerblock-con…
jjohnsoncertinia Oct 9, 2023
a4fea0d
update Block matchers to use Block
jjohnsoncertinia Oct 9, 2023
8c229ec
add case for refreshed validation missing key
jjohnsoncertinia Oct 10, 2023
0a1cee2
add partial tests for rename functions
jjohnsoncertinia Oct 10, 2023
c1a916d
Merge remote-tracking branch 'origin/main' into 226-rename-provider-e…
jjohnsoncertinia Oct 10, 2023
30e8549
Optimise imports
jjohnsoncertinia Oct 10, 2023
1a92ddb
add more descriptive var name
jjohnsoncertinia Oct 10, 2023
4fbe304
Fix location comparison in getTargetLocationForMethodCallOut
jjohnsoncertinia Oct 11, 2023
e0e3ad2
Fix broken method rename tests
jjohnsoncertinia Oct 11, 2023
2b933de
Always load and use saved file contents and code simplifications/impr…
jjohnsoncertinia Oct 11, 2023
6fd01bb
add more expression type checks
jjohnsoncertinia Oct 11, 2023
bba1b5c
add body declaration type checks
jjohnsoncertinia Oct 11, 2023
f14dace
Add further test coverage for renaming methods
jjohnsoncertinia Oct 11, 2023
bc1a3fa
add more expression type cases
jjohnsoncertinia Oct 12, 2023
8ff5433
add more expression type tests
jjohnsoncertinia Oct 12, 2023
a279307
add handling for SummaryMethods
jjohnsoncertinia Oct 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions jvm/src/main/scala/com/nawforce/apexlink/cst/Expressions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import com.nawforce.apexlink.names.TypeNames
import com.nawforce.apexlink.names.TypeNames._
import com.nawforce.apexlink.org.{OPM, OrgInfo, Referenceable}
import com.nawforce.apexlink.types.apex.{ApexClassDeclaration, ApexConstructorLike}
import com.nawforce.apexlink.types.core.{FieldDeclaration, TypeDeclaration}
import com.nawforce.apexlink.types.core.{FieldDeclaration, MethodDeclaration, TypeDeclaration}
import com.nawforce.apexlink.types.other.{AnyDeclaration, RecordSetDeclaration}
import com.nawforce.apexlink.types.platform.{PlatformTypeDeclaration, PlatformTypes}
import com.nawforce.apexlink.types.synthetic.CustomConstructorDeclaration
import com.nawforce.apexparser.ApexParser._
import com.nawforce.pkgforce.diagnostics.{ERROR_CATEGORY, Issue, WARNING_CATEGORY}
import com.nawforce.pkgforce.names.{EncodedName, Name, Names, TypeName}
import com.nawforce.pkgforce.path.{Locatable, PathLocation}
import com.nawforce.pkgforce.path.{Locatable, Location, PathLocation}
import com.nawforce.runtime.parsers.CodeParser

import scala.collection.immutable.ArraySeq
Expand Down Expand Up @@ -555,6 +555,8 @@ abstract class MethodCall extends Expression

final case class MethodCallWithId(target: Id, arguments: ArraySeq[Expression]) extends MethodCall {

var cachedMethod: Option[MethodDeclaration] = None

override def verify(input: ExprContext, context: ExpressionVerifyContext): ExprContext = {
verify(location, input.typeDeclaration, input.isStatic, input, context)
}
Expand All @@ -572,6 +574,7 @@ final case class MethodCallWithId(target: Id, arguments: ArraySeq[Expression]) e
val argTypes = args.map(arg => if (arg.isDefined) arg.typeName else TypeNames.Any)
callee.findMethod(target.name, argTypes, staticContext, context) match {
case Right(method) =>
cachedMethod = Some(method)
context.addDependency(method)
method match {
case ref: Referenceable => ref.addLocation(location)
Expand Down Expand Up @@ -609,6 +612,19 @@ final case class MethodCallWithId(target: Id, arguments: ArraySeq[Expression]) e
ExprContext.empty
}
}

/** Given a method declaration, if this method callout belongs to that method declaration then returns the location
* if the callout. If the callout does not match to the method declaration, returns None.
*/
def getTargetLocationForMethodCallOut(md: MethodDeclaration): Option[Location] = {
cachedMethod.getOrElse(None) match {
case mdFromCallout: ApexMethodDeclaration
if mdFromCallout.idLocation == md.asInstanceOf[ApexMethodDeclaration].idLocation =>
Some(target.location.location)
case _ => None
}
}

}

final case class MethodCallCtor(isSuper: Boolean, arguments: ArraySeq[Expression])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
*/
package com.nawforce.apexlink.org

import com.nawforce.apexlink.cst.ApexMethodDeclaration
import com.nawforce.apexlink.org.TextOps.TestOpsUtils
import com.nawforce.apexlink.rpc.HoverItem
import com.nawforce.apexlink.types.apex.{
ApexClassDeclaration,
ApexConstructorLike,
ApexFullDeclaration,
ApexMethodLike
}
import com.nawforce.pkgforce.path.{IdLocatable, Locatable, Location, PathLike, UnsafeLocatable}
import com.nawforce.pkgforce.path.{Locatable, Location, PathLike}

trait HoverProvider extends SourceOps {
this: OPM.PackageImpl =>
Expand Down
Loading