Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion doesn't use file cache for included XML schema. #570

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,32 @@ public boolean dependsOnGrammar(DOMDocument document, String grammarURI) {
private CMDocument findCMDocument(String uri, String publicId, String systemId,
ContentModelProvider modelProvider) {
// Resolve the XML Schema/DTD uri (file, http, etc)
String key = resolverManager.resolve(uri, publicId, systemId);
if (key == null) {
String resolvedUri = resolverManager.resolve(uri, publicId, systemId);
if (resolvedUri == null) {
return null;
}
// the XML Schema, DTD can be resolved
if (modelProvider == null) {
// the model provider cannot be get with standard mean (xsi:schemaLocation,
// xsi:noNamespaceSchemaLocation, doctype)
// try to get it by using extension (ex: .xsd, .dtd)
modelProvider = getModelProviderByURI(key);
modelProvider = getModelProviderByURI(resolvedUri);
}
if (modelProvider == null) {
return null;
}
// Try to get the document from the cache
CMDocument cmDocument = getCMDocumentFromCache(key);
CMDocument cmDocument = getCMDocumentFromCache(resolvedUri);
if (cmDocument != null) {
return cmDocument;
}
boolean isFileResource = URIUtils.isFileResource(uri);
boolean isFileResource = URIUtils.isFileResource(resolvedUri);
if (!isFileResource && cacheResolverExtension.isUseCache()) {
// The DTD/XML Schema comes from http://, ftp:// etc and cache manager is
// activated
// Try to load the DTD/XML Schema with the cache manager
try {
Path file = cacheResolverExtension.getCachedResource(key);
Path file = cacheResolverExtension.getCachedResource(resolvedUri);
if (file != null) {
cmDocument = modelProvider.createCMDocument(file.toFile().getPath());
}
Expand All @@ -151,14 +151,14 @@ private CMDocument findCMDocument(String uri, String publicId, String systemId,
return null;
} catch (Exception e) {
// other error like network which is not available
cmDocument = modelProvider.createCMDocument(key);
cmDocument = modelProvider.createCMDocument(resolvedUri);
}
} else {
cmDocument = modelProvider.createCMDocument(key);
cmDocument = modelProvider.createCMDocument(resolvedUri);
}
// Cache the document
if (cmDocument != null) {
cache(key, cmDocument);
cache(resolvedUri, cmDocument);
}
return cmDocument;
}
Expand Down