remove unused field from ResolvedImport

This commit is contained in:
Dave Holoway
2020-06-29 15:49:04 +01:00
parent 61397dab95
commit cd1c360ef0
2 changed files with 6 additions and 14 deletions

View File

@@ -39,14 +39,14 @@ function resolveSingleImport(typemap, dotted_name, is_static, on_demand, import_
// import all static members - the dotted name must be an exact type
const matches = fetchImportedTypes(typenames, dotted_name, false);
if (matches) {
return new ResolvedImport(null, matches, '*', typemap, import_kind);
return new ResolvedImport(matches, '*', typemap, import_kind);
}
} else if (dotted_name.includes('.')) {
// the final ident is the static member - the rest is the exact type
const split_name = dotted_name.match(/(.+)\.([^.]+)$/);
const matches = fetchImportedTypes(typenames, split_name[1], false);
if (matches) {
const i = new ResolvedImport(null, matches, split_name[2], typemap, import_kind);
const i = new ResolvedImport(matches, split_name[2], typemap, import_kind);
// if there's no matching member, treat it as an invalid import
if (i.members.length > 0) {
return i;
@@ -56,7 +56,7 @@ function resolveSingleImport(typemap, dotted_name, is_static, on_demand, import_
} else {
const matches = fetchImportedTypes(typenames, dotted_name, on_demand);
if (matches) {
return new ResolvedImport(null, matches, null, typemap, import_kind);
return new ResolvedImport(matches, null, typemap, import_kind);
}
}
return null;
@@ -86,14 +86,14 @@ function resolveImports(typemap, package_name, implicitPackages = ['java.lang'])
if (package_name) {
const matches = fetchImportedTypes(typenames, package_name, true);
if (matches)
resolved.push(new ResolvedImport(null, matches, null, typemap, 'owner-package'));
resolved.push(new ResolvedImport(matches, null, typemap, 'owner-package'));
}
// import types from the implicit packages
implicitPackages.forEach(package_name => {
const matches = fetchImportedTypes(typenames, package_name, true);
if (matches)
resolved.push(new ResolvedImport(null, matches, null, typemap, 'implicit-import'));
resolved.push(new ResolvedImport(matches, null, typemap, 'implicit-import'));
})
/**

View File

@@ -1,7 +1,6 @@
/**
* @typedef {import('java-mti').CEIType} CEIType
*/
const { ImportBlock } = require('../parser9');
/**
* Class representing a resolved import.
@@ -12,19 +11,12 @@ const { ImportBlock } = require('../parser9');
*/
class ResolvedImport {
/**
* @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, static_ident, typemap, import_kind) {
/**
* The associated import declaration.
* - this value is null for owner-package and implicit-imports
*/
this.import = import_decl;
constructor(matches, static_ident, typemap, import_kind) {
/**
* Array of fully qualified type names in JRE format resolved in this import
*/