Skip to content

Commit

Permalink
Revert revert changes for hover
Browse files Browse the repository at this point in the history
  • Loading branch information
7i6ht committed Feb 5, 2025
1 parent 5a3fc73 commit b64d9f9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/viper/silver/ast/pretty/PrettyPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ object FastPrettyPrinter extends FastPrettyPrinterBase with BracketPrettyPrinter
} else {
n.info.getUniqueInfo[AnnotationInfo] match {
case Some(ai) if ai.values.nonEmpty =>
val docs = ai.values.filter(v => v._1 != "expandedMacro").map(v => char('@') <> v._1 <> parens(ssep(v._2.map(v => text(s"\"${v}\"")), text(", ")))).toSeq
val docs = ai.values.map(v => char('@') <> v._1 <> parens(ssep(v._2.map(v => text(s"\"${v}\"")), text(", ")))).toSeq
Some(ssep(docs, if (breakLines) line else space))
case _ => None
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/viper/silver/parser/MacroExpander.scala
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ object MacroExpander {

// Return expanded macro's body wrapped inside annotation
bodyWithReplacedParams match {
case b: PExp => PAnnotatedExp(PAnnotation(new PSym.At(PSym.At)(pos),PRawString("expandedMacro")(pos),PGrouped.impliedParen(PDelimited.empty))(pos),b)(pos)
case b: PStmt => PAnnotatedStmt(PAnnotation(new PSym.At(PSym.At)(pos),PRawString("expandedMacro")(pos),PGrouped.impliedParen(PDelimited.empty))(pos),b)(pos)
case b: PExp => PExpandedMacroExp(b)(pos)
case b: PStmt => PExpandedMacroStmt(b)(pos)
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/scala/viper/silver/parser/ParseAst.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,15 @@ case class PSeqn(ss: PDelimited.Block[PStmt])(val pos: (Position, Position)) ext
override def pretty = ss.prettyLines
}

///////////////////////////////////////////////////////////////////////////
// Wrapper for expanded macros
trait PExpandedMacro
case class PExpandedMacroExp(exp: PExp)(val pos: (Position, Position)) extends PExp with PExpandedMacro {
override def typeSubstitutions: collection.Seq[PTypeSubstitution] = exp.typeSubstitutions
override def forceSubstitution(ts: PTypeSubstitution): Unit = exp.forceSubstitution(ts)
}
case class PExpandedMacroStmt(stmt: PStmt)(val pos: (Position, Position)) extends PStmt with PExpandedMacro

/**
* PSeqn representing the expanded body of a statement macro.
* Unlike a normal PSeqn, it does not represent its own scope.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/viper/silver/parser/Translator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ case class Translator(program: PProgram) {
ann.values.inner.toSeq.map(_.str)
}
(resPexp, innerMap.updated(ann.key.str, combinedValue))
case PExpandedMacroExp(e) => extractAnnotation(e)
case PExpandedMacroExp(s) => extractAnnotation(s)
case _ => (pexp, Map())
}
}
Expand Down

0 comments on commit b64d9f9

Please sign in to comment.