diff --git a/langserver/document.js b/langserver/document.js index e94c61e..dcda3a9 100644 --- a/langserver/document.js +++ b/langserver/document.js @@ -61,6 +61,54 @@ function positionAt(index, content) { } } +/** + * A specialised Map to allow for case-insensitive fileURIs on Windows. + * + * For cs-filesystems, this should work as a normal map. + * For ci-filesystems, if a file URI case changes, it should be picked up + * by the lowercase map + */ +class FileURIMap extends Map { + lowerMap = new Map(); + + /** + * @param {string} key + */ + get(key) { + return super.get(key) || this.lowerMap.get(key.toLowerCase()); + } + + /** + * @param {string} key + */ + has(key) { + return super.has(key) || this.lowerMap.has(key.toLowerCase()); + } + + /** + * @param {string} key + * @param {*} value + */ + set(key, value) { + super.set(key, value); + this.lowerMap.set(key.toLowerCase(), value); + return this; + } + + /** + * @param {string} key + */ + delete(key) { + this.lowerMap.delete(key.toLowerCase()); + return super.delete(key); + } + + clear() { + super.clear(); + this.lowerMap.clear(); + } +} + /** * Class for storing data about Java source files */ @@ -376,6 +424,7 @@ async function loadWorkingFileList(src_folder) { exports.indexAt = indexAt; exports.positionAt = positionAt; +exports.FileURIMap = FileURIMap; exports.JavaDocInfo = JavaDocInfo; exports.ParsedInfo = ParsedInfo; exports.reparse = reparse; diff --git a/langserver/server.js b/langserver/server.js index 8f1ce5c..d57224f 100644 --- a/langserver/server.js +++ b/langserver/server.js @@ -16,7 +16,7 @@ const { Settings } = require('./settings'); const { trace } = require('./logging'); const { getCompletionItems, resolveCompletionItem } = require('./completions'); const { getSignatureHelp } = require('./method-signatures'); -const { getAppSourceRootFolder, JavaDocInfo, indexAt, reparse, rescanSourceFolders } = require('./document'); +const { getAppSourceRootFolder, FileURIMap, JavaDocInfo, indexAt, reparse, rescanSourceFolders } = require('./document'); /** * The global map of Android system types @@ -29,7 +29,7 @@ let androidLibrary = null; * The list of loaded Java documents * @type {Map} */ -const liveParsers = new Map(); +const liveParsers = new FileURIMap(); let hasConfigurationCapability = false; let hasWorkspaceFolderCapability = false;