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

269 update to apex parser 40 for corrections to trigger parsing #270

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ lazy val apexls = crossProject(JSPlatform, JVMPlatform)
"org.scala-lang.modules" %% "scala-xml" % "1.3.0",
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.0",
"org.scala-js" %% "scalajs-stubs" % "1.0.0",
"io.github.apex-dev-tools" % "apex-parser" % "3.6.0",
"io.github.apex-dev-tools" % "apex-parser" % "4.0.0",
"io.github.apex-dev-tools" % "vf-parser" % "1.1.0",
"io.github.apex-dev-tools" % "sobject-types" % "60.0.1",
"io.github.apex-dev-tools" % "standard-types" % "60.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
*/
package com.nawforce.runtime.parsers

import com.nawforce.apexparser.ApexParser.TypeRefContext
import com.nawforce.apexparser.{ApexLexer, ApexParser, CaseInsensitiveInputStream}
import com.nawforce.pkgforce.diagnostics.IssuesAnd
import com.nawforce.pkgforce.path.{PathLike, PathLocation}
import com.nawforce.runtime.parsers.CodeParser.ParserRuleContext
import com.nawforce.runtime.parsers.antlr.CommonTokenStream
import io.github.apexdevtools.apexparser.{ApexLexer, ApexParser, CaseInsensitiveInputStream}

import scala.collection.compat.immutable.ArraySeq
import scala.reflect.ClassTag
Expand Down
26 changes: 6 additions & 20 deletions js/src/main/scala/com/nawforce/runtime/parsers/Source.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
*/
package com.nawforce.runtime.parsers

import com.nawforce.apexparser.CaseInsensitiveInputStream
import com.nawforce.pkgforce.path.{Location, PathLike, PathLocation}
import com.nawforce.runtime.SourceBlob
import com.nawforce.runtime.parsers.CodeParser.ParserRuleContext
import io.github.apexdevtools.apexparser.CaseInsensitiveInputStream

trait Locatable {
var locationPath: PathLike
Expand All @@ -41,7 +41,8 @@ case class Source(
lazy val hash: Int = code.hash

def extractSource(context: ParserRuleContext): Source = {
val subdata = code.subdata(context.start.startIndex, context.stop.stopIndex + 1)
val stop = CodeParser.toScala(context.stop).getOrElse(context.start)
val subdata = code.subdata(context.start.startIndex, stop.stopIndex + 1)
new Source(
path,
subdata,
Expand All @@ -66,14 +67,15 @@ case class Source(
/** Find a location for a rule, adapts based on source offsets to give absolute position in file
*/
def getLocation(context: ParserRuleContext): PathLocation = {
val stop = CodeParser.toScala(context.stop).getOrElse(context.start)
PathLocation(
path,
adjustLocation(
Location(
context.start.line,
context.start.charPositionInLine,
context.stop.line,
context.stop.charPositionInLine + context.stop.text.length
stop.line,
stop.charPositionInLine + stop.text.length
)
)
)
Expand All @@ -96,22 +98,6 @@ case class Source(

Location(startLine, startPosition, endLine, endPosition)
}

def stampLocation(locatable: Locatable, context: ParserRuleContext): Unit = {
locatable.locationPath = path
locatable.startLine = context.start.line + lineOffset
locatable.startOffset =
if (context.start.line == 1)
context.start.charPositionInLine + columnOffset
else
context.start.charPositionInLine
locatable.endLine = context.stop.line + lineOffset
locatable.endOffset =
if (context.stop.line == 1)
context.stop.charPositionInLine + context.stop.text.length + columnOffset
else
context.stop.charPositionInLine + context.stop.text.length
}
}

object Source {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

package com.nawforce.runtime.parsers

import com.nawforce.apexparser.CaseInsensitiveInputStream
import com.nawforce.pkgforce.parsers.UTF8Decode
import com.nawforce.runtime.SourceBlob
import com.nawforce.runtime.parsers.antlr.CharStreams
import io.github.apexdevtools.apexparser.CaseInsensitiveInputStream

import java.nio.charset.StandardCharsets
import scala.util.hashing.MurmurHash3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

package com.nawforce.runtime.parsers

import com.nawforce.apexparser.ApexParser._
import com.nawforce.runtime.parsers.antlr.{AbstractParseTreeVisitor, ApexParserVisitor, RuleNode}
import io.github.apexdevtools.apexparser.ApexParser._

import scala.collection.compat.immutable.ArraySeq
import scala.reflect.ClassTag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.nawforce.runtime.parsers.antlr

import com.nawforce.apexparser.ApexParser._
import io.github.apexdevtools.apexparser.ApexParser._

import scala.scalajs.js

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import scala.scalajs.js.annotation.JSImport
@js.native
@JSImport("antlr4ts", "ParserRuleContext")
class ParserRuleContext extends RuleContext {
val start: Token = js.native
val stop: Token = js.native
val start: Token = js.native
val stop: js.UndefOr[Token] = js.native

def parent: ParserRuleContext = js.native
val childCount: Int = js.native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.nawforce.runtime.parsers.antlr

import com.nawforce.apexparser.CaseInsensitiveInputStream
import io.github.apexdevtools.apexparser.CaseInsensitiveInputStream

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
*/
package com.nawforce.apexparser
package io.github.apexdevtools.apexparser

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
*/
package com.nawforce.apexparser
package io.github.apexdevtools.apexparser

import com.nawforce.apexparser.ApexParser._
import io.github.apexdevtools.apexparser.ApexParser._
import com.nawforce.runtime.parsers.antlr.{CommonTokenStream, ParserRuleContext, TerminalNode}

import scala.scalajs.js
Expand Down Expand Up @@ -43,7 +43,7 @@ object ApexParser {
class TriggerUnitContext extends ParserRuleContext {
def id(): js.Array[IdContext] = js.native
def triggerCase(): js.Array[TriggerCaseContext] = js.native
def block(): BlockContext = js.native
def triggerBlock(): TriggerBlockContext = js.native
}

@js.native
Expand All @@ -57,6 +57,30 @@ object ApexParser {
def UNDELETE(): js.UndefOr[TerminalNode] = js.native
}

@js.native
@JSImport("@apexdevtools/apex-parser", "TriggerBlockContext")
class TriggerBlockContext extends ParserRuleContext {
def triggerBlockMember(): js.Array[TriggerBlockMemberContext] = js.native
}

@js.native
@JSImport("@apexdevtools/apex-parser", "TriggerBlockMemberContext")
class TriggerBlockMemberContext extends ParserRuleContext {
def triggerMemberDeclaration(): js.UndefOr[TriggerMemberDeclarationContext] = js.native
def modifier(): js.Array[ModifierContext] = js.native
def statement(): js.Array[StatementContext] = js.native
}

@js.native
@JSImport("@apexdevtools/apex-parser", "TriggerMemberDeclarationContext")
class TriggerMemberDeclarationContext extends ParserRuleContext {
def methodDeclaration(): js.UndefOr[MethodDeclarationContext] = js.native
def fieldDeclaration(): js.UndefOr[FieldDeclarationContext] = js.native
def interfaceDeclaration(): js.UndefOr[InterfaceDeclarationContext] = js.native
def classDeclaration(): js.UndefOr[ClassDeclarationContext] = js.native
def propertyDeclaration(): js.UndefOr[PropertyDeclarationContext] = js.native
}

@js.native
@JSImport("@apexdevtools/apex-parser", "CompilationUnitContext")
class CompilationUnitContext extends ParserRuleContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
*/
package com.nawforce.apexparser
package io.github.apexdevtools.apexparser

import com.nawforce.runtime.parsers.antlr.CharStream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import com.nawforce.apexlink.types.apex.{
ThisType
}
import com.nawforce.apexlink.types.core._
import com.nawforce.apexparser.ApexParser._
import com.nawforce.pkgforce.diagnostics.{ERROR_CATEGORY, Issue}
import com.nawforce.pkgforce.modifiers._
import com.nawforce.pkgforce.names.{Name, TypeName}
import com.nawforce.pkgforce.parsers._
import com.nawforce.pkgforce.path.Location
import com.nawforce.runtime.parsers.CodeParser
import io.github.apexdevtools.apexparser.ApexParser._

import scala.collection.immutable.ArraySeq
import scala.collection.mutable
Expand Down
2 changes: 1 addition & 1 deletion jvm/src/main/scala/com/nawforce/apexlink/cst/CST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ package com.nawforce.apexlink.cst

import com.nawforce.apexlink.diagnostics.IssueOps
import com.nawforce.apexlink.names.XNames.NameUtils
import com.nawforce.apexparser.ApexParser._
import com.nawforce.pkgforce.names.{Name, Names, TypeName}
import com.nawforce.pkgforce.path.Positionable
import com.nawforce.runtime.parsers.{CodeParser, Source}
import io.github.apexdevtools.apexparser.ApexParser._

import scala.util.DynamicVariable

Expand Down
2 changes: 1 addition & 1 deletion jvm/src/main/scala/com/nawforce/apexlink/cst/Creator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import com.nawforce.apexlink.cst.AssignableSupport.{couldBeEqual, isAssignableDe
import com.nawforce.apexlink.names.TypeNames
import com.nawforce.apexlink.names.TypeNames._
import com.nawforce.apexlink.types.core.TypeDeclaration
import com.nawforce.apexparser.ApexParser._
import com.nawforce.pkgforce.modifiers.ABSTRACT_MODIFIER
import com.nawforce.pkgforce.names._
import com.nawforce.runtime.parsers.CodeParser
import io.github.apexdevtools.apexparser.ApexParser._

import scala.collection.immutable.ArraySeq

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import com.nawforce.apexlink.types.core.{FieldDeclaration, MethodDeclaration, Ty
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, Location, PathLocation}
import com.nawforce.runtime.parsers.CodeParser
import io.github.apexdevtools.apexparser.ApexParser._

import scala.collection.immutable.ArraySeq

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ package com.nawforce.apexlink.cst

import com.nawforce.apexlink.types.core.TypeDeclaration
import com.nawforce.apexlink.types.platform.PlatformTypes
import com.nawforce.apexparser.ApexParser.LiteralContext
import com.nawforce.pkgforce.names.Name
import com.nawforce.runtime.parsers.CodeParser
import io.github.apexdevtools.apexparser.ApexParser.LiteralContext

sealed abstract class Literal() {
def getType: TypeDeclaration
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/main/scala/com/nawforce/apexlink/cst/Primaries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import com.nawforce.apexlink.names.TypeNames
import com.nawforce.apexlink.types.apex.{ApexClassDeclaration, ApexFieldLike}
import com.nawforce.apexlink.types.core.{FieldDeclaration, TypeDeclaration}
import com.nawforce.apexlink.types.platform.PlatformTypes
import com.nawforce.apexparser.ApexParser._
import com.nawforce.apexparser.ApexParserBaseVisitor
import com.nawforce.pkgforce.names.{DotName, EncodedName, Name, Names, TypeName}
import com.nawforce.pkgforce.names._
import com.nawforce.pkgforce.path.Location
import com.nawforce.runtime.parsers.CodeParser
import io.github.apexdevtools.apexparser.ApexParser._
import io.github.apexdevtools.apexparser.ApexParserBaseVisitor

import scala.collection.compat.immutable.ArraySeq

Expand Down
13 changes: 5 additions & 8 deletions jvm/src/main/scala/com/nawforce/apexlink/cst/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ package com.nawforce.apexlink.cst

import com.nawforce.apexlink.types.apex.{ApexFieldLike, ThisType}
import com.nawforce.apexlink.types.core.{TypeDeclaration, TypeId}
import com.nawforce.apexparser.ApexParser.{PropertyBlockContext, PropertyDeclarationContext}
import com.nawforce.pkgforce.modifiers.{
ApexModifiers,
FINAL_MODIFIER,
Modifier,
ModifierResults,
PRIVATE_MODIFIER
}
import com.nawforce.pkgforce.modifiers._
import com.nawforce.pkgforce.names.{Name, TypeName}
import com.nawforce.pkgforce.parsers.{ApexNode, Nature, PROPERTY_NATURE}
import com.nawforce.pkgforce.path.Location
import com.nawforce.runtime.parsers.CodeParser
import io.github.apexdevtools.apexparser.ApexParser.{
PropertyBlockContext,
PropertyDeclarationContext
}

import scala.collection.immutable.ArraySeq

Expand Down
Loading
Loading