TypeFox / yang-lsp

A Language Server for YANG
http://www.yang-central.org
Apache License 2.0
51 stars 13 forks source link

checkVersionConsistency in YangValidator provide wrong context to error() #82

Closed huyuwen closed 6 years ago

huyuwen commented 6 years ago

// A YANG version 1 module or submodule must not import a YANG version 1.1 module by revision.
if (moduleVersion == YANG_1) { substatementsOfType(Import).map[module].filterNull.filter[eResource !== null && !eIsProxy].filter [ yangVersion != moduleVersion ].forEach [ val message = '''Cannot import a version «yangVersion» submodule in a version «moduleVersion» module.'''; error(message, it, ABSTRACT_IMPORT__MODULE, BAD_IMPORT_YANG_VERSION); ]; } When the error() is invoked to report Version consistency issues, it always comes up with the IllegalAgumentException. I think that's due to it is wrongly used. at org.eclipse.xtext.validation.AbstractDeclarativeValidator.checkIsFromCurrentlyCheckedResource(AbstractDeclarativeValidator.java:571) at org.eclipse.xtext.validation.AbstractDeclarativeValidator.acceptError(AbstractDeclarativeValidator.java:554) at org.eclipse.xtext.validation.AbstractDeclarativeValidator.error(AbstractDeclarativeValidator.java:435) at io.typefox.yang.validation.YangValidator.lambda$checkVersionConsistency$8(YangValidator.java:203) at java.lang.Iterable.forEach(Iterable.java:75) at io.typefox.yang.validation.YangValidator.checkVersionConsistency(YangValidator.java:205)

JanKoehnlein commented 6 years ago

Good catch.

Fixed with https://github.com/theia-ide/yang-lsp/pull/85

JanKoehnlein commented 6 years ago

PR merged.