mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
[LSP] minor improvements in error handling
This commit is contained in:
parent
9f39754cba
commit
22c8d64437
5 changed files with 23 additions and 17 deletions
|
@ -22,12 +22,13 @@ import org.eclipse.xtext.resource.impl.ResourceDescriptionsData
|
|||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import org.eclipse.xtext.validation.Issue
|
||||
import org.eclipse.xtext.workspace.IWorkspaceConfig
|
||||
import org.eclipse.xtext.util.internal.Log
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
class WorkspaceManager {
|
||||
@Log class WorkspaceManager {
|
||||
|
||||
@Inject Provider<ProjectManager> projectManagerProvider
|
||||
@Inject IWorkspaceConfigFactory workspaceConfigFactory
|
||||
|
@ -119,6 +120,10 @@ class WorkspaceManager {
|
|||
}
|
||||
|
||||
def didChange(URI uri, int version, Iterable<TextEdit> changes, CancelIndicator cancelIndicator) {
|
||||
if (!openDocuments.containsKey(uri)) {
|
||||
LOG.error("The document "+uri+" has not been opened.")
|
||||
return;
|
||||
}
|
||||
val contents = openDocuments.get(uri)
|
||||
openDocuments.put(uri, contents.applyChanges(changes))
|
||||
doBuild(#[uri], newArrayList, cancelIndicator)
|
||||
|
|
|
@ -7,18 +7,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.signatureHelp;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import io.typefox.lsapi.SignatureHelp;
|
||||
import io.typefox.lsapi.impl.SignatureHelpImpl;
|
||||
import io.typefox.lsapi.impl.SignatureInformationImpl;
|
||||
import io.typefox.lsapi.builders.SignatureHelpBuilder;
|
||||
|
||||
/**
|
||||
* Representation of a service for getting the {@link SignatureHelp signature
|
||||
|
@ -32,14 +27,7 @@ public interface SignatureHelpService {
|
|||
/**
|
||||
* Shared, immutable empty instance.
|
||||
*/
|
||||
SignatureHelp EMPTY = new SignatureHelpImpl() {
|
||||
|
||||
@Override
|
||||
public List<SignatureInformationImpl> getSignatures() {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
};
|
||||
SignatureHelp EMPTY = new SignatureHelpBuilder().build();
|
||||
|
||||
/**
|
||||
* Returns with a {@link SignatureHelp signature help} instance for a
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.resource.URIConverter;
|
||||
|
@ -36,6 +37,7 @@ import org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions;
|
|||
import org.eclipse.xtext.resource.impl.ProjectDescription;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsData;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.util.internal.Log;
|
||||
import org.eclipse.xtext.validation.Issue;
|
||||
import org.eclipse.xtext.workspace.IProjectConfig;
|
||||
import org.eclipse.xtext.workspace.IWorkspaceConfig;
|
||||
|
@ -47,6 +49,7 @@ import org.eclipse.xtext.xbase.lib.Procedures.Procedure2;
|
|||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@Log
|
||||
@SuppressWarnings("all")
|
||||
public class WorkspaceManager {
|
||||
@Inject
|
||||
|
@ -174,6 +177,12 @@ public class WorkspaceManager {
|
|||
}
|
||||
|
||||
public void didChange(final URI uri, final int version, final Iterable<TextEdit> changes, final CancelIndicator cancelIndicator) {
|
||||
boolean _containsKey = this.openDocuments.containsKey(uri);
|
||||
boolean _not = (!_containsKey);
|
||||
if (_not) {
|
||||
WorkspaceManager.LOG.error((("The document " + uri) + " has not been opened."));
|
||||
return;
|
||||
}
|
||||
final Document contents = this.openDocuments.get(uri);
|
||||
Document _applyChanges = contents.applyChanges(changes);
|
||||
this.openDocuments.put(uri, _applyChanges);
|
||||
|
@ -239,4 +248,6 @@ public class WorkspaceManager {
|
|||
|
||||
public <T extends Object> void doWrite(final URI uri, final Function2<? super Document, ? super XtextResource, ? extends T> work) {
|
||||
}
|
||||
|
||||
private final static Logger LOG = Logger.getLogger(WorkspaceManager.class);
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ abstract class AbstractLanguageServerTest implements Consumer<PublishDiagnostics
|
|||
].build);
|
||||
|
||||
val actualSignatureHelp = signatureHelps.get.toExpectation
|
||||
assertEquals(expectedSignatureHelp, actualSignatureHelp)
|
||||
assertEquals(expectedSignatureHelp.trim, actualSignatureHelp.trim)
|
||||
}
|
||||
|
||||
protected def void testDocumentSymbol((DocumentSymbolConfiguraiton)=>void configurator) {
|
||||
|
|
|
@ -662,7 +662,9 @@ public abstract class AbstractLanguageServerTest implements Consumer<PublishDiag
|
|||
SignatureHelp _get = signatureHelps.get();
|
||||
final String actualSignatureHelp = this.toExpectation(_get);
|
||||
String _expectedSignatureHelp = configuration.getExpectedSignatureHelp();
|
||||
this.assertEquals(_expectedSignatureHelp, actualSignatureHelp);
|
||||
String _trim = _expectedSignatureHelp.trim();
|
||||
String _trim_1 = actualSignatureHelp.trim();
|
||||
this.assertEquals(_trim, _trim_1);
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue