mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
initial attempt to support type variable arguments in methods
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @typedef {Map<string,JavaType>} TypeMap
|
||||
*/
|
||||
const { JavaType, PrimitiveType, ArrayType, CEIType } = require('java-mti');
|
||||
const { JavaType, PrimitiveType, ArrayType, CEIType, MethodBase } = require('java-mti');
|
||||
const { ResolvedImport } = require('./import-resolver');
|
||||
const ResolvedType = require('./parsetypes/resolved-type');
|
||||
|
||||
@@ -260,16 +260,25 @@ function resolveTypeIdents(types, fully_qualified_scope, resolved_imports, typem
|
||||
/**
|
||||
*
|
||||
* @param {string} ident
|
||||
* @param {CEIType} scoped_type
|
||||
* @param {CEIType|MethodBase} scope
|
||||
* @param {ResolvedImport[]} imports
|
||||
* @param {Map<string,JavaType>} typemap
|
||||
*/
|
||||
function resolveTypeOrPackage(ident, scoped_type, imports, typemap) {
|
||||
function resolveTypeOrPackage(ident, scope, imports, typemap) {
|
||||
const types = [];
|
||||
let package_name = '';
|
||||
|
||||
// is it an enclosed type of the currently scoped type or any outer type
|
||||
if (scoped_type) {
|
||||
if (scope instanceof MethodBase) {
|
||||
// is it a type variable in the current scope
|
||||
const tv = scope.typeVariables.find(tv => tv.name === ident);
|
||||
if (tv) {
|
||||
types.push(tv.type);
|
||||
}
|
||||
}
|
||||
|
||||
if (scope) {
|
||||
// is it an enclosed type of the currently scoped type or any outer type
|
||||
const scoped_type = scope instanceof CEIType ? scope : scope.owner;
|
||||
const scopes = scoped_type.shortSignature.split('$');
|
||||
while (scopes.length) {
|
||||
const enc_type = typemap.get(`${scopes.join('$')}$${ident}`);
|
||||
@@ -281,6 +290,14 @@ function resolveTypeOrPackage(ident, scoped_type, imports, typemap) {
|
||||
}
|
||||
}
|
||||
|
||||
if (scope instanceof CEIType) {
|
||||
// is it a type variable of the currently scoped type
|
||||
const tv = scope.typeVariables.find(tv => tv.name === ident);
|
||||
if (tv) {
|
||||
types.push(tv.type);
|
||||
}
|
||||
}
|
||||
|
||||
if (!types[0]) {
|
||||
// is it a top-level type from the imports
|
||||
const top_level_type = '/' + ident;
|
||||
|
||||
Reference in New Issue
Block a user