Skip to content

Commit

Permalink
Merge pull request #143 from galaxyproject/fix_diagnostics
Browse files Browse the repository at this point in the history
Clear diagnostics when the document is not valid
  • Loading branch information
davelopez authored Jun 3, 2021
2 parents e063a91 + e442ff9 commit d06e8aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/galaxyls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
)
from pygls.lsp.types import (
CompletionList,
CompletionOptions,
CompletionParams,
ConfigurationItem,
ConfigurationParams,
Diagnostic,
DidChangeConfigurationParams,
DidCloseTextDocumentParams,
DidOpenTextDocumentParams,
Expand All @@ -31,12 +33,11 @@
TextDocumentPositionParams,
TextEdit,
)
from pygls.lsp.types.language_features.completion import CompletionOptions
from pygls.server import LanguageServer
from pygls.workspace import Document

from galaxyls.config import CompletionMode, GalaxyToolsConfiguration
from galaxyls.constants import Commands, SERVER_NAME
from galaxyls.constants import SERVER_NAME, Commands
from galaxyls.services.language import GalaxyToolLanguageService
from galaxyls.services.validation import DocumentValidator
from galaxyls.services.xml.document import XmlDocument
Expand Down Expand Up @@ -218,11 +219,12 @@ def discover_tests_command(server: GalaxyToolsLanguageServer, params: TextDocume

def _validate(server: GalaxyToolsLanguageServer, params) -> None:
"""Validates the Galaxy tool and reports any problem found."""
diagnostics: List[Diagnostic] = []
document = _get_valid_document(server, params.text_document.uri)
if document:
xml_document = _get_xml_document(document)
diagnostics = server.service.get_diagnostics(xml_document)
server.publish_diagnostics(document.uri, diagnostics)
server.publish_diagnostics(params.text_document.uri, diagnostics)


def _get_valid_document(server: GalaxyToolsLanguageServer, uri: str) -> Optional[Document]:
Expand Down

0 comments on commit d06e8aa

Please sign in to comment.