add support for static member imports

This commit is contained in:
Dave Holoway
2020-06-16 20:22:19 +01:00
parent bccc29251c
commit 198317a5c2
3 changed files with 55 additions and 10 deletions

View File

@@ -14,10 +14,11 @@ const { ImportBlock } = require('../parser9');
/**
* @param {ImportBlock} import_decl
* @param {RegExpMatchArray} matches
* @param {string} static_ident
* @param {Map<string,CEIType>} typemap
* @param {'owner-package'|'import'|'implicit-import'} import_kind
*/
constructor(import_decl, matches, typemap, import_kind) {
constructor(import_decl, matches, static_ident, typemap, import_kind) {
/**
* The associated import declaration.
* - this value is null for owner-package and implicit-imports
@@ -34,6 +35,15 @@ const { ImportBlock } = require('../parser9');
*/
this.types = new Map(matches.map(name => [name, typemap.get(name)]));
this.members = [];
if (static_ident) {
const type = typemap.get(matches[0]);
if (type) {
type.fields.forEach(f => f.modifiers.includes('static') && (static_ident === '*' || static_ident === f.name) && this.members.push(f));
type.methods.forEach(m => m.modifiers.includes('static') && (static_ident === '*' || static_ident === m.name) && this.members.push(m));
}
}
/**
* What kind of import this is:
* - `"owner-package"`: types that are implicitly imported from the same package as the declared module