Skip to content

Commit

Permalink
all: support lsp 3.15.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zchee committed Feb 13, 2021
1 parent be98efe commit f5e54a0
Show file tree
Hide file tree
Showing 40 changed files with 7,383 additions and 571 deletions.
176 changes: 116 additions & 60 deletions basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ type Diagnostic struct {
// Message is the diagnostic's message.
Message string `json:"message"`

// Tags is the additional metadata about the diagnostic.
//
// @since 3.15.0.
Tags []DiagnosticTag `json:"tags,omitempty"`

// RelatedInformation an array of related diagnostic information, e.g. when symbol-names within
// a scope collide all definitions can be marked via this property.
RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
Expand Down Expand Up @@ -133,6 +138,37 @@ func (d DiagnosticSeverity) String() string {
}
}

// DiagnosticTag is the diagnostic tags.
//
// @since 3.15.0.
type DiagnosticTag float64

// list of DiagnosticTag.
const (
// DiagnosticUnnecessary unused or unnecessary code.
//
// Clients are allowed to render diagnostics with this tag faded out instead of having
// an error squiggle.
DiagnosticUnnecessary DiagnosticTag = 1

// DiagnosticDeprecated deprecated or obsolete code.
//
// Clients are allowed to rendered diagnostics with this tag strike through.
DiagnosticDeprecated DiagnosticTag = 2
)

// String implements fmt.Stringer.
func (d DiagnosticTag) String() string {
switch d {
case DiagnosticUnnecessary:
return "Unnecessary"
case DiagnosticDeprecated:
return "Deprecated"
default:
return strconv.FormatFloat(float64(d), 'f', -10, 64)
}
}

// DiagnosticRelatedInformation represents a related message and source code location for a diagnostic.
//
// This should be used to point to code locations that cause or related to a diagnostics, e.g when duplicating
Expand Down Expand Up @@ -312,6 +348,9 @@ type TextDocumentItem struct {
type LanguageIdentifier string

const (
// ABAPLanguage ABAP Language.
ABAPLanguage LanguageIdentifier = "abap"

// BatLanguage Windows Bat Language.
BatLanguage LanguageIdentifier = "bat"

Expand All @@ -321,8 +360,8 @@ const (
// ClojureLanguage Clojure Language.
ClojureLanguage LanguageIdentifier = "clojure"

// CoffeescriptLanguage Coffeescript Language.
CoffeescriptLanguage LanguageIdentifier = "coffeescript"
// CoffeescriptLanguage CoffeeScript Language.
CoffeeScriptLanguage LanguageIdentifier = "coffeescript"

// CLanguage C Language.
CLanguage LanguageIdentifier = "c"
Expand All @@ -345,6 +384,12 @@ const (
// DockerfileLanguage Dockerfile Language.
DockerfileLanguage LanguageIdentifier = "dockerfile"

// ElixirLanguage Elixir Language.
ElixirLanguage LanguageIdentifier = "elixir"

// ErlangLanguage Erlang Language.
ErlangLanguage LanguageIdentifier = "erlang"

// FsharpLanguage F# Language.
FsharpLanguage LanguageIdentifier = "fsharp"

Expand Down Expand Up @@ -375,6 +420,9 @@ const (
// JavaScriptLanguage JavaScript Language.
JavaScriptLanguage LanguageIdentifier = "javascript"

// JavaScriptReactLanguage JavaScript React Language.
JavaScriptReactLanguage LanguageIdentifier = "javascriptreact"

// JSONLanguage JSON Language.
JSONLanguage LanguageIdentifier = "json"

Expand Down Expand Up @@ -429,11 +477,11 @@ const (
// RustLanguage Rust Language.
RustLanguage LanguageIdentifier = "rust"

// ScssLanguage Sass Language.
ScssLanguage LanguageIdentifier = "scss"
// SCSSLanguage SCSS Languages syntax using curly brackets.
SCSSLanguage LanguageIdentifier = "scss"

// SassLanguage Sass Language.
SassLanguage LanguageIdentifier = "sass"
// SASSLanguage SCSS Languages indented syntax.
SASSLanguage LanguageIdentifier = "sass"

// ScalaLanguage Scala Language.
ScalaLanguage LanguageIdentifier = "scala"
Expand All @@ -453,8 +501,11 @@ const (
// TypeScriptLanguage TypeScript Language.
TypeScriptLanguage LanguageIdentifier = "typescript"

// TexLanguage TeX Language.
TexLanguage LanguageIdentifier = "tex"
// TypeScriptReactLanguage TypeScript React Language.
TypeScriptReactLanguage LanguageIdentifier = "typescriptreact"

// TeXLanguage TeX Language.
TeXLanguage LanguageIdentifier = "tex"

// VBLanguage Visual Basic Language.
VBLanguage LanguageIdentifier = "vb"
Expand All @@ -471,58 +522,63 @@ const (

// languageIdentifierMap map of LanguageIdentifiers.
var languageIdentifierMap = map[string]LanguageIdentifier{
"bat": BatLanguage,
"bibtex": BibtexLanguage,
"clojure": ClojureLanguage,
"coffeescript": CoffeescriptLanguage,
"c": CLanguage,
"cpp": CppLanguage,
"csharp": CsharpLanguage,
"css": CSSLanguage,
"diff": DiffLanguage,
"dart": DartLanguage,
"dockerfile": DockerfileLanguage,
"fsharp": FsharpLanguage,
"git-commit": GitCommitLanguage,
"git-rebase": GitRebaseLanguage,
"go": GoLanguage,
"groovy": GroovyLanguage,
"handlebars": HandlebarsLanguage,
"html": HTMLLanguage,
"ini": IniLanguage,
"java": JavaLanguage,
"javascript": JavaScriptLanguage,
"json": JSONLanguage,
"latex": LatexLanguage,
"less": LessLanguage,
"lua": LuaLanguage,
"makefile": MakefileLanguage,
"markdown": MarkdownLanguage,
"objective-c": ObjectiveCLanguage,
"objective-cpp": ObjectiveCppLanguage,
"perl": PerlLanguage,
"perl6": Perl6Language,
"php": PHPLanguage,
"powershell": PowershellLanguage,
"jade": JadeLanguage,
"python": PythonLanguage,
"r": RLanguage,
"razor": RazorLanguage,
"ruby": RubyLanguage,
"rust": RustLanguage,
"scss": ScssLanguage,
"sass": SassLanguage,
"scala": ScalaLanguage,
"shaderlab": ShaderlabLanguage,
"shellscript": ShellscriptLanguage,
"sql": SQLLanguage,
"swift": SwiftLanguage,
"typescript": TypeScriptLanguage,
"tex": TexLanguage,
"vb": VBLanguage,
"xml": XMLLanguage,
"xsl": XslLanguage,
"yaml": YamlLanguage,
"abap": ABAPLanguage,
"bat": BatLanguage,
"bibtex": BibtexLanguage,
"clojure": ClojureLanguage,
"coffeescript": CoffeeScriptLanguage,
"c": CLanguage,
"cpp": CppLanguage,
"csharp": CsharpLanguage,
"css": CSSLanguage,
"diff": DiffLanguage,
"dart": DartLanguage,
"dockerfile": DockerfileLanguage,
"elixir": ElixirLanguage,
"erlang": ErlangLanguage,
"fsharp": FsharpLanguage,
"git-commit": GitCommitLanguage,
"git-rebase": GitRebaseLanguage,
"go": GoLanguage,
"groovy": GroovyLanguage,
"handlebars": HandlebarsLanguage,
"html": HTMLLanguage,
"ini": IniLanguage,
"java": JavaLanguage,
"javascript": JavaScriptLanguage,
"javascriptreact": JavaScriptReactLanguage,
"json": JSONLanguage,
"latex": LatexLanguage,
"less": LessLanguage,
"lua": LuaLanguage,
"makefile": MakefileLanguage,
"markdown": MarkdownLanguage,
"objective-c": ObjectiveCLanguage,
"objective-cpp": ObjectiveCppLanguage,
"perl": PerlLanguage,
"perl6": Perl6Language,
"php": PHPLanguage,
"powershell": PowershellLanguage,
"jade": JadeLanguage,
"python": PythonLanguage,
"r": RLanguage,
"razor": RazorLanguage,
"ruby": RubyLanguage,
"rust": RustLanguage,
"scss": SCSSLanguage,
"sass": SASSLanguage,
"scala": ScalaLanguage,
"shaderlab": ShaderlabLanguage,
"shellscript": ShellscriptLanguage,
"sql": SQLLanguage,
"swift": SwiftLanguage,
"typescript": TypeScriptLanguage,
"typescriptreact": TypeScriptReactLanguage,
"tex": TeXLanguage,
"vb": VBLanguage,
"xml": XMLLanguage,
"xsl": XslLanguage,
"yaml": YamlLanguage,
}

// ToLanguageIdentifier converts ft to LanguageIdentifier.
Expand Down
65 changes: 63 additions & 2 deletions basic_gojay.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ var (
_ gojay.UnmarshalerJSONObject = (*Position)(nil)
)

// Positions represents a slice of Position.
type Positions []Position

// MarshalJSONArray implements gojay.MarshalerJSONArray.
func (v Positions) MarshalJSONArray(enc *gojay.Encoder) {
for i := range v {
enc.Object(&v[i])
}
}

// IsNil implements gojay.MarshalerJSONArray.
func (v Positions) IsNil() bool { return len(v) == 0 }

// UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.
func (v *Positions) UnmarshalJSONArray(dec *gojay.Decoder) error {
value := Position{}
if err := dec.Object(&value); err != nil {
return err
}
*v = append(*v, value)
return nil
}

// compile time check whether the Positions implements a gojay.MarshalerJSONArray and gojay.UnmarshalerJSONArray interfaces.
var (
_ gojay.MarshalerJSONArray = (*Positions)(nil)
_ gojay.UnmarshalerJSONArray = (*Positions)(nil)
)

// MarshalJSONObject implements gojay.MarshalerJSONObject.
func (v *Range) MarshalJSONObject(enc *gojay.Encoder) {
enc.ObjectKey(keyStart, &v.Start)
Expand Down Expand Up @@ -144,6 +173,7 @@ func (v *Diagnostic) MarshalJSONObject(enc *gojay.Encoder) {
enc.AddInterfaceKeyOmitEmpty(keyCode, v.Code)
enc.StringKeyOmitEmpty(keySource, v.Source)
enc.StringKey(keyMessage, v.Message)
enc.ArrayKeyOmitEmpty(keyTags, DiagnosticTags(v.Tags))
enc.ArrayKeyOmitEmpty(keyRelatedInformation, DiagnosticRelatedInformations(v.RelatedInformation))
}

Expand All @@ -163,6 +193,8 @@ func (v *Diagnostic) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
return dec.String(&v.Source)
case keyMessage:
return dec.String(&v.Message)
case keyTags:
return dec.Array((*DiagnosticTags)(&v.Tags))
case keyRelatedInformation:
values := DiagnosticRelatedInformations{}
err := dec.Array(&values)
Expand All @@ -175,14 +207,43 @@ func (v *Diagnostic) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
}

// NKeys returns the number of keys to unmarshal.
func (v *Diagnostic) NKeys() int { return 6 }
func (v *Diagnostic) NKeys() int { return 7 }

// compile time check whether the Diagnostic implements a gojay.MarshalerJSONObject and gojay.UnmarshalerJSONObject interfaces.
var (
_ gojay.MarshalerJSONObject = (*Diagnostic)(nil)
_ gojay.UnmarshalerJSONObject = (*Diagnostic)(nil)
)

// DiagnosticTags represents a slice of DiagnosticTag.
type DiagnosticTags []DiagnosticTag

// MarshalJSONArray implements gojay.MarshalerJSONArray.
func (v DiagnosticTags) MarshalJSONArray(enc *gojay.Encoder) {
for i := range v {
enc.Float64(float64(v[i]))
}
}

// IsNil implements gojay.MarshalerJSONArray.
func (v DiagnosticTags) IsNil() bool { return len(v) == 0 }

// UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.
func (v *DiagnosticTags) UnmarshalJSONArray(dec *gojay.Decoder) error {
var value DiagnosticTag
if err := dec.Float64((*float64)(&value)); err != nil {
return err
}
*v = append(*v, value)
return nil
}

// compile time check whether the CodeActionKinds implements a gojay.MarshalerJSONArray and gojay.UnmarshalerJSONArray interfaces.
var (
_ gojay.MarshalerJSONArray = (*DiagnosticTags)(nil)
_ gojay.UnmarshalerJSONArray = (*DiagnosticTags)(nil)
)

// MarshalJSONObject implements gojay.MarshalerJSONObject.
func (v *DiagnosticRelatedInformation) MarshalJSONObject(enc *gojay.Encoder) {
enc.ObjectKey(keyLocation, &v.Location)
Expand Down Expand Up @@ -718,7 +779,7 @@ var (
func (v *VersionedTextDocumentIdentifier) MarshalJSONObject(enc *gojay.Encoder) {
enc.StringKey(keyURI, string(v.URI))
if v.Version == nil {
v.Version = Uint64Ptr(0)
v.Version = NewVersion(0)
}
enc.Uint64KeyNullEmpty(keyVersion, *v.Version)
}
Expand Down
Loading

0 comments on commit f5e54a0

Please sign in to comment.