-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added hovering capabilities for properties of action types specifically.
- Loading branch information
Showing
17 changed files
with
186 additions
and
20 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/main/scala/io/smartdatalake/completion/SDLBCompletionEngineImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.smartdatalake.hover | ||
|
||
import io.smartdatalake.context.SDLBContext | ||
import org.eclipse.lsp4j.Hover | ||
|
||
trait SDLBHoverEngine: | ||
def generateHoveringInformation(context: SDLBContext): Hover |
28 changes: 28 additions & 0 deletions
28
src/main/scala/io/smartdatalake/hover/SDLBHoverEngineImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.smartdatalake.hover | ||
import io.smartdatalake.context.SDLBContext | ||
import io.smartdatalake.schema.{SchemaReader, SchemaReaderImpl} | ||
import org.eclipse.lsp4j.{Hover, MarkupContent, MarkupKind} | ||
|
||
import scala.util.{Failure, Success, Try} | ||
|
||
class SDLBHoverEngineImpl extends SDLBHoverEngine: | ||
|
||
val schemaReader: SchemaReader = new SchemaReaderImpl("sdl-schema/sdl-schema-2.5.0.json") //TODO should be retrieved from a service keeping its state, object for example | ||
|
||
|
||
override def generateHoveringInformation(context: SDLBContext): Hover = | ||
val markupContent = new MarkupContent() | ||
markupContent.setKind(MarkupKind.MARKDOWN) | ||
markupContent.setValue(retrieveSchemaDescription(context)) | ||
new Hover(markupContent) | ||
|
||
private def retrieveSchemaDescription(context: SDLBContext): String = | ||
context.parentPath match | ||
case path if path.startsWith("actions") && path.count(_ == '.') == 1 => | ||
val tActionType: Try[String] = Try(context.textContext.config.getString(context.parentPath + ".type")) | ||
tActionType match | ||
case Success(actionType) => schemaReader.retrieveActionPropertyDescription(actionType, context.word) | ||
case Failure(_) => "" | ||
|
||
case _ => "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...datalake/completion/schema/ItemType.scala → ...la/io/smartdatalake/schema/ItemType.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...talake/completion/schema/SchemaItem.scala → .../io/smartdatalake/schema/SchemaItem.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package io.smartdatalake.completion.schema | ||
package io.smartdatalake.schema | ||
|
||
case class SchemaItem(name: String, itemType: ItemType, description: String, required: Boolean) |
4 changes: 3 additions & 1 deletion
4
...lake/completion/schema/SchemaReader.scala → ...o/smartdatalake/schema/SchemaReader.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package io.smartdatalake.completion.schema | ||
package io.smartdatalake.schema | ||
|
||
trait SchemaReader: | ||
def retrieveActionProperties(typeName: String): Iterable[SchemaItem] | ||
|
||
def retrieveActionPropertyDescription(typeName: String, propertyName: String): String | ||
|
||
def retrieveActionTypesWithRequiredAttributes(): Iterable[(String, Iterable[SchemaItem])] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/scala/io/smartdatalake/hover/SDLBHoverEngineSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.smartdatalake.hover | ||
|
||
import io.smartdatalake.UnitSpec | ||
import io.smartdatalake.context.SDLBContext | ||
import ujson.* | ||
|
||
import scala.io.Source | ||
import scala.util.Using | ||
|
||
class SDLBHoverEngineSpec extends UnitSpec { | ||
|
||
val hoveringEngine = new SDLBHoverEngineImpl | ||
|
||
"SDLB Completion engine" should "retrieve all the properties of copyAction" in { | ||
val context = SDLBContext.fromText(loadFile("fixture/hocon/with-multi-lines-flattened-example.conf")) | ||
.withCaretPosition(6, 4) | ||
val expected = | ||
"""Configuration of a custom Spark-DataFrame transformation between many inputs and many outputs (n:m). | ||
|Define a transform function which receives a map of input DataObjectIds with DataFrames and a map of options and has | ||
|to return a map of output DataObjectIds with DataFrames, see also trait[[CustomDfsTransformer]] .""".stripMargin | ||
//hoveringEngine.generateHoveringInformation(context).getContents.getRight.getValue shouldBe expected | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters