hls-plugin-api-1.2.0.2: Haskell Language Server API for plugin communication
Safe HaskellNone
LanguageHaskell2010

Ide.Plugin.Properties

Synopsis

Documentation

data PropertyType Source #

Types properties may have

type family ToHsType (t :: PropertyType) where ... Source #

data MetaData (t :: PropertyType) where Source #

Metadata of a property

Constructors

MetaData 

Fields

EnumMetaData 

Fields

data PropertyKey Source #

Used at type level for name-type mapping in Properties

data KeyNameProxy (s :: Symbol) Source #

A proxy type in order to allow overloaded labels as properties' names at the call site

Constructors

KnownSymbol s => KeyNameProxy 

Instances

Instances details
(KnownSymbol s', s ~ s') => IsLabel s (KeyNameProxy s') Source # 
Instance details

Defined in Ide.Plugin.Properties

Methods

fromLabel :: KeyNameProxy s' #

data Properties (r :: [PropertyKey]) Source #

Properties is a partial implementation of json schema, without supporting union types and validation. In hls, it defines a set of properties which used in dedicated configuration of a plugin. A property is an immediate child of the json object in each plugin's "config" section. It was designed to be compatible with vscode's settings UI. Use emptyProperties and useProperty to create and consume Properties.

type HasProperty s k t r = (k ~ 'PropertyKey s t, Elem s r, FindByKeyName s r ~ t, KnownSymbol s) Source #

In row r, there is a PropertyKey k, which has name s and carries haskell type t

emptyProperties :: Properties '[] Source #

Creates a Properties that defines no property

Useful to start a definitions chain, for example: properties = emptyProperties & defineStringProperty #exampleString "Description of exampleString" Foo & defineNumberProperty #exampleNumber "Description of exampleNumber" 233

defineNumberProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r) 
=> KeyNameProxy s 
-> Text

description

-> Double

default value

-> Properties r 
-> Properties ('PropertyKey s 'TNumber ': r) 

Defines a number property

defineIntegerProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r) 
=> KeyNameProxy s 
-> Text

description

-> Int

default value

-> Properties r 
-> Properties ('PropertyKey s 'TInteger ': r) 

Defines an integer property

defineStringProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r) 
=> KeyNameProxy s 
-> Text

description

-> Text

default value

-> Properties r 
-> Properties ('PropertyKey s 'TString ': r) 

Defines a string property

defineBooleanProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r) 
=> KeyNameProxy s 
-> Text

description

-> Bool

default value

-> Properties r 
-> Properties ('PropertyKey s 'TBoolean ': r) 

Defines a boolean property

defineObjectProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) 
=> KeyNameProxy s 
-> Text

description

-> a

default value

-> Properties r 
-> Properties ('PropertyKey s ('TObject a) ': r) 

Defines an object property

defineArrayProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) 
=> KeyNameProxy s 
-> Text

description

-> [a]

default value

-> Properties r 
-> Properties ('PropertyKey s ('TArray a) ': r) 

Defines an array property

defineEnumProperty Source #

Arguments

:: (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a, Eq a, Show a) 
=> KeyNameProxy s 
-> Text

description

-> [(a, Text)]

valid enum members with each of description

-> a 
-> Properties r 
-> Properties ('PropertyKey s ('TEnum a) ': r) 

Defines an enum property

toDefaultJSON :: Properties r -> [Pair] Source #

Converts a properties definition into kv pairs with default values from MetaData

toVSCodeExtensionSchema :: Text -> Properties r -> [Pair] Source #

Converts a properties definition into kv pairs as vscode schema

usePropertyEither :: HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> Either String (ToHsType t) Source #

Given the name of a defined property, generates a JSON parser of plcConfig

useProperty :: HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> ToHsType t Source #

Like usePropertyEither but returns defaultValue on parse error

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

>>> 5 & (+1) & show
"6"

Since: base-4.8.0.0