Skip to content

Commit

Permalink
Add custom XSD completions (to implement with xsi:) (see #163)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Nov 3, 2018
1 parent deb4197 commit 5c8bb41
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2018 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <[email protected]> - initial API and implementation
*/
package org.eclipse.lsp4xml.extensions.xsd;

import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4xml.services.extensions.CompletionParticipantAdapter;
import org.eclipse.lsp4xml.services.extensions.ICompletionRequest;
import org.eclipse.lsp4xml.services.extensions.ICompletionResponse;

/**
* XSD completion for xs:
*
*/
public class XSDCompletionParticipant extends CompletionParticipantAdapter {

@Override
public void onAttributeName(boolean generateValue, Range fullRange, ICompletionRequest request,
ICompletionResponse response) throws Exception {
// TODO: manage xsi: completions
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.eclipse.lsp4xml.extensions.xsd;

import org.eclipse.lsp4j.InitializeParams;
import org.eclipse.lsp4xml.services.extensions.ICompletionParticipant;
import org.eclipse.lsp4xml.services.extensions.IXMLExtension;
import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry;
import org.eclipse.lsp4xml.uriresolver.URIResolverExtensionManager;
Expand All @@ -20,8 +21,13 @@
*/
public class XSDPlugin implements IXMLExtension {

private final ICompletionParticipant completionParticipant;

private XSDURIResolverExtension uiResolver;

public XSDPlugin() {
completionParticipant = new XSDCompletionParticipant();
}
@Override
public void updateSettings(Object settings) {

Expand All @@ -31,10 +37,12 @@ public void updateSettings(Object settings) {
public void start(InitializeParams params, XMLExtensionsRegistry registry) {
uiResolver = new XSDURIResolverExtension(registry.getDocumentProvider());
URIResolverExtensionManager.getInstance().registerResolver(uiResolver);
registry.registerCompletionParticipant(completionParticipant);
}

@Override
public void stop(XMLExtensionsRegistry registry) {
URIResolverExtensionManager.getInstance().unregisterResolver(uiResolver);
registry.unregisterCompletionParticipant(completionParticipant);
}
}

0 comments on commit 5c8bb41

Please sign in to comment.