Skip to content

Commit

Permalink
Add IXMLExtension doSave and ResourceToDeploy documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Zegray <ryan.zegray@ibm.com>
  • Loading branch information
rzgry authored and angelozerr committed Sep 2, 2020
1 parent a308a1b commit 5bc3ed7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Expand Up @@ -42,6 +42,13 @@ public interface IXMLExtension {
*/
void stop(XMLExtensionsRegistry registry);

/**
* Called when the Settings or a Document have been saved.
* context.getType() can be used to determine what type was saved.
* doSave is called on extension start up with a settings context to
* provide the xml settings to the extension.
* @param context
*/
default void doSave(ISaveContext context) {

}
Expand Down
Expand Up @@ -60,26 +60,51 @@ class ResourceInfo {

}

/**
* Classpath resource to deploy into the lemminx cache
*/
public static class ResourceToDeploy {

private final Path resourceCachePath;
private final String resourceFromClasspath;

/**
* @param resourceURI - used to compute the path to deploy the
* resource to in the lemminx cache. Generally this
* is the URL to the resource. Ex.
* https://www.w3.org/2007/schema-for-xslt20.xsd
* @param resourceFromClasspath - the classpath location of the resource to
* deploy to the lemminx cache
*/
public ResourceToDeploy(String resourceURI, String resourceFromClasspath) {
this(URI.create(resourceURI), resourceFromClasspath);
}

/**
* @param resourceURI - used to compute the path to deploy the
* resource to in the lemminx cache. Generally this
* is the URL to the resource. Ex.
* https://www.w3.org/2007/schema-for-xslt20.xsd
* @param resourceFromClasspath - the classpath location of the resource to
* deploy to the lemminx cache
*/
public ResourceToDeploy(URI resourceURI, String resourceFromClasspath) {
this.resourceCachePath = Paths.get(CACHE_PATH, resourceURI.getScheme(), resourceURI.getHost(),
resourceURI.getPath());
this.resourceFromClasspath = resourceFromClasspath.startsWith("/") ? resourceFromClasspath
: "/" + resourceFromClasspath;
}

/**
* @return The computed path in the lemmix cache that the resource will be stored at
*/
public Path getDeployedPath() throws IOException {
return FilesUtils.getDeployedPath(resourceCachePath);
}

/**
* @return The path to the resource on the classpath
*/
public String getResourceFromClasspath() {
return resourceFromClasspath;
}
Expand Down

0 comments on commit 5bc3ed7

Please sign in to comment.