From 8b71037a58f0e89f3967da9165d52dbcfe875dc7 Mon Sep 17 00:00:00 2001 From: Dave Holoway Date: Tue, 16 Jun 2020 15:05:17 +0100 Subject: [PATCH] include enclosing types in identifier search --- langserver/java/body-parser3.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/langserver/java/body-parser3.js b/langserver/java/body-parser3.js index 1720d4b..f144942 100644 --- a/langserver/java/body-parser3.js +++ b/langserver/java/body-parser3.js @@ -2003,11 +2003,18 @@ function findIdentifier(ident, mdecls, scope, imports, typemap) { if (local || param) { matches.variables = [local || param]; } else { - // is it a field, method or enum value in the current type (or any of the superclasses) + // is it a field, method or enum value in the current type (or any of the outer types or superclasses) const scoped_type = scope instanceof SourceType ? scope : scope.owner; - const types = getTypeInheritanceList(scoped_type); + const outer_types = []; + for (let m, t = scoped_type._rawShortSignature;; ) { + m = t.match(/(.+)[$][^$]+$/); + if (!m) break; + const enctype = typemap.get(t = m[1]); + enctype && outer_types.push(enctype); + } + const inherited_types = getTypeInheritanceList(scoped_type); const method_sigs = new Set(); - types.forEach(type => { + [...inherited_types, ...outer_types].forEach(type => { if (!matches.variables[0]) { const field = type.fields.find(f => f.name === ident); if (field) {