mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-25 02:48:05 +00:00
updated validation to use new JavaTypes module instead of MTIs
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
const Declaration = require('./declaration');
|
||||
const ParseProblem = require('./parse-problem');
|
||||
const Token = require('./token');
|
||||
const TypeParameters = require('./type-parameters');
|
||||
|
||||
/**
|
||||
* @typedef {import('./modifier')} Modifier
|
||||
@@ -34,35 +32,6 @@ class ImportDeclaration extends Declaration {
|
||||
lastToken() {
|
||||
return this.semicolon || this.asterisk || this.nameparts.slice(-1)[0];
|
||||
}
|
||||
|
||||
validate() {
|
||||
const checkModifierIsStatic = () => {
|
||||
if (this.static_ && this.static_.text !== 'static') {
|
||||
return ParseProblem.syntaxError(this.static_);
|
||||
}
|
||||
}
|
||||
|
||||
const checkNoInvalidModifiers = () => {
|
||||
return this.modifiers.map(modifier => {
|
||||
if (modifier instanceof Token) {
|
||||
return ParseProblem.syntaxError(modifier);
|
||||
}
|
||||
if (modifier instanceof TypeParameters) {
|
||||
return ParseProblem.syntaxError(modifier.open);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** @type {ParseProblem[]} */
|
||||
const problems = [
|
||||
checkModifierIsStatic(),
|
||||
...ParseProblem.checkNonKeywordIdents(this.nameparts),
|
||||
ParseProblem.checkSemicolon(this),
|
||||
...checkNoInvalidModifiers(),
|
||||
];
|
||||
|
||||
return problems;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ImportDeclaration;
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
/**
|
||||
* @typedef {import('java-mti').JavaType} JavaType
|
||||
*/
|
||||
const { ImportBlock } = require('../parser9');
|
||||
|
||||
/**
|
||||
* Class representing a resolved import.
|
||||
*
|
||||
* Each instance holds an array of types that would be resolved by the specified import.
|
||||
* Each type is mapped to an MTI which lists the implementation details of the type (fields, methods, etc).
|
||||
* Each type is mapped to a JavaType which lists the implementation details of the type (fields, methods, etc).
|
||||
*
|
||||
*/
|
||||
class ResolvedImport {
|
||||
/**
|
||||
* @param {ImportBlock} import_decl
|
||||
* @param {RegExpMatchArray} matches
|
||||
* @param {Map<string,import('../mti').Type>} typemap
|
||||
* @param {Map<string,JavaType>} typemap
|
||||
* @param {'owner-package'|'import'|'implicit-import'} import_kind
|
||||
*/
|
||||
constructor(import_decl, matches, typemap, import_kind) {
|
||||
@@ -27,7 +30,7 @@ const { ImportBlock } = require('../parser9');
|
||||
this.fullyQualifiedNames = Array.from(matches);
|
||||
|
||||
/**
|
||||
* THe map of fully-qualified type names to MTIs
|
||||
* THe map of fully-qualified type names to JavaTypes
|
||||
*/
|
||||
this.types = new Map(matches.map(name => [name, typemap.get(name)]));
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @typedef {import('./token')} Token
|
||||
* @typedef {import('./type')} TypeDeclaration
|
||||
* @typedef {import('java-mti').JavaType} JavaType
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -78,8 +79,8 @@ class ResolvedType {
|
||||
error = '';
|
||||
|
||||
/**
|
||||
* The resolved MTIs that match this type. This will be an empty array if the type cannot be found.
|
||||
* @type {import('../mti').Type[]}
|
||||
* The resolved JavaTypes that match this type. This will be an empty array if the type cannot be found.
|
||||
* @type {JavaType[]}
|
||||
*/
|
||||
mtis = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user