Skip to content

Commit d408fcf

Browse files
authored
Merge pull request #332 from viperproject/presentation-mode
Add beginner mode
2 parents 41adee8 + c493934 commit d408fcf

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ lazy val server = (project in file("."))
1818
// General settings
1919
name := "ViperServer",
2020
organization := "viper",
21-
version := "3.0.0", // has to be a proper semver
21+
version := "3.1.0", // has to be a proper semver
2222

2323
// Fork test to a different JVM than SBT's, avoiding SBT's classpath interfering with
2424
// classpath used by Scala's reflection.

src/main/scala/viper/server/ViperConfig.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class ViperConfig(args: Seq[String]) extends ScallopConf(args) {
5353
hidden = false
5454
)
5555

56+
val beginnerMode: ScallopOption[Boolean] = opt[Boolean]("beginnerMode",
57+
descr = "Enables beginner mode, which disables some advanced features that can be confusing for new users.",
58+
default = Some(false),
59+
noshort = true,
60+
hidden = false
61+
)
62+
5663
val SERVER_MODE_LSP = "LSP"
5764
val SERVER_MODE_HTTP = "HTTP"
5865
private val server_modes = Array(SERVER_MODE_LSP, SERVER_MODE_HTTP)

src/main/scala/viper/server/frontends/lsp/Receiver.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ trait LanguageReceiver extends StandardReceiver with LanguageServer {
9090
capabilities.setCodeActionProvider(true)
9191
// Document Color: [N/A]
9292
// Color Presentation: [N/A]
93-
// Formatting: TODO
94-
// capabilities.setDocumentFormattingProvider(true)
93+
// Formatting: TODO?
94+
capabilities.setDocumentFormattingProvider(true)
9595
// Range Formatting: TODO
9696
// On type Formatting: [N/A]
9797
// Rename & Prepare Rename:
@@ -103,8 +103,6 @@ trait LanguageReceiver extends StandardReceiver with LanguageServer {
103103
// automatically cause all references to be renamed. This would probably be too annoying.
104104
capabilities.setLinkedEditingRangeProvider(false)
105105

106-
capabilities.setDocumentFormattingProvider(true)
107-
108106
CompletableFuture.completedFuture(new InitializeResult(capabilities))
109107
}
110108

src/main/scala/viper/server/frontends/lsp/ast/ParseAstLsp.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ object HasFoldingRanges {
6464
}
6565

6666
object HasInlayHints {
67-
def apply(p: PProgram): Seq[InlayHint] = p.deepCollect({
68-
case n: PCall => PLspCall.getInlayHints(n)
67+
def apply(p: PProgram, beginnerMode: Boolean): Seq[InlayHint] = p.deepCollect({
68+
case n: PCall if !beginnerMode => PLspCall.getInlayHints(n)
6969
case n: PLet => PLspLet.getInlayHints(n)
7070
}).flatten.distinctBy(h => (h.position, h.label.map(_.value)))
7171
}

src/main/scala/viper/server/frontends/lsp/file/RelayActor.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,14 @@ class RelayActor(task: MessageHandler, backendClassName: Option[String]) extends
129129
task.resetContainers(true)
130130
task.lastPhase = Some(phase)
131131

132+
val beginnerMode = coordinator.server.config.beginnerMode()
132133
task.addCodeLens(true)(HasCodeLens(pProgram))
133134
task.addDocumentSymbol(true)(HasDocumentSymbol(pProgram).toSeq)
134135
task.addHoverHint(true)(HasHoverHints(pProgram))
135136
task.addGotoDefinition(true)(HasGotoDefinitions(pProgram))
136137
task.addFindReferences(true)(HasReferenceTos(pProgram))
137138
task.addFoldingRange(true)(HasFoldingRanges(pProgram))
138-
task.addInlayHint(true)(HasInlayHints(pProgram))
139+
task.addInlayHint(true)(HasInlayHints(pProgram, beginnerMode))
139140
task.addSemanticHighlight(true)(HasSemanticHighlights(pProgram))
140141
task.addSignatureHelp(true)(HasSignatureHelps(pProgram))
141142
task.addSuggestionScopeRange(true)(HasSuggestionScopeRanges(pProgram))

0 commit comments

Comments
 (0)