mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
Support for analyzing parts with front-end based resolution.
R=brianwilkerson@google.com Bug: Change-Id: I9695254e8fe013073f732651c4448c3987df06a8 Reviewed-on: https://dart-review.googlesource.com/22661 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
5186182eb4
commit
5fb49a27f5
2 changed files with 62 additions and 172 deletions
|
@ -178,11 +178,6 @@ class LibraryAnalyzer {
|
|||
units[part] = _parse(part);
|
||||
}
|
||||
|
||||
if (units.length != 1) {
|
||||
// TODO(scheglov) Handle this case.
|
||||
throw new UnimplementedError('Multiple units in a library');
|
||||
}
|
||||
|
||||
// Resolve URIs in directives to corresponding sources.
|
||||
units.forEach((file, unit) {
|
||||
_resolveUriBasedDirectives(file, unit);
|
||||
|
@ -194,17 +189,8 @@ class LibraryAnalyzer {
|
|||
|
||||
_resolveDirectives(units);
|
||||
|
||||
units.forEach((file, unit) {
|
||||
CompilationUnitElement unitElement = unit.element;
|
||||
new DeclarationResolver(
|
||||
enableKernelDriver: _enableKernelDriver,
|
||||
applyKernelTypes: _enableKernelDriver)
|
||||
.resolve(unit, unitElement);
|
||||
// _resolveFile(file, unit);
|
||||
// _computePendingMissingRequiredParameters(file, unit);
|
||||
});
|
||||
|
||||
// TODO(scheglov) Improve.
|
||||
ValidatingResolutionApplier applier;
|
||||
{
|
||||
AnalyzerTarget analyzerTarget;
|
||||
await _kernelDriver.compileLibrary(
|
||||
|
@ -222,60 +208,14 @@ class LibraryAnalyzer {
|
|||
astTypes.add(astType);
|
||||
}
|
||||
|
||||
var unit = units.values.single;
|
||||
var applier = new ValidatingResolutionApplier(
|
||||
applier = new ValidatingResolutionApplier(
|
||||
astTypes, analyzerTarget.typeOffsets);
|
||||
for (var declaration in unit.declarations) {
|
||||
if (declaration is ClassDeclaration) {
|
||||
for (var member in declaration.members) {
|
||||
if (member is ConstructorDeclaration) {
|
||||
member.body.accept(applier);
|
||||
} else if (member is FieldDeclaration) {
|
||||
if (member.fields.variables.length != 1) {
|
||||
// TODO(scheglov) Handle this case.
|
||||
throw new UnimplementedError('Multiple field');
|
||||
}
|
||||
member.fields.variables[0].initializer?.accept(applier);
|
||||
} else if (member is MethodDeclaration) {
|
||||
member.body.accept(applier);
|
||||
} else {
|
||||
// TODO(scheglov) Handle more cases.
|
||||
throw new UnimplementedError('${member.runtimeType}');
|
||||
}
|
||||
}
|
||||
} else if (declaration is FunctionDeclaration) {
|
||||
declaration.functionExpression.body.accept(applier);
|
||||
} else if (declaration is TopLevelVariableDeclaration) {
|
||||
if (declaration.variables.variables.length != 1) {
|
||||
// TODO(scheglov) Handle this case.
|
||||
throw new UnimplementedError('Multiple variables');
|
||||
}
|
||||
declaration.variables.variables[0].initializer?.accept(applier);
|
||||
} else {
|
||||
// TODO(scheglov) Handle more cases.
|
||||
throw new UnimplementedError('${declaration.runtimeType}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
units.forEach((file, unit) {
|
||||
//
|
||||
// Find constants to compute.
|
||||
//
|
||||
{
|
||||
ConstantFinder constantFinder = new ConstantFinder();
|
||||
unit.accept(constantFinder);
|
||||
_constants.addAll(constantFinder.constantsToCompute);
|
||||
}
|
||||
|
||||
//
|
||||
// Find constant dependencies to compute.
|
||||
//
|
||||
{
|
||||
var finder = new ConstantExpressionsDependenciesFinder();
|
||||
unit.accept(finder);
|
||||
_constants.addAll(finder.dependencies);
|
||||
}
|
||||
_resolveFile2(file, unit, applier);
|
||||
// TODO(scheglov) Restore.
|
||||
// _computePendingMissingRequiredParameters(file, unit);
|
||||
});
|
||||
|
||||
_computeConstants();
|
||||
|
@ -768,6 +708,63 @@ class LibraryAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
void _resolveFile2(FileState file, CompilationUnit unit,
|
||||
ValidatingResolutionApplier applier) {
|
||||
CompilationUnitElement unitElement = unit.element;
|
||||
new DeclarationResolver(enableKernelDriver: true, applyKernelTypes: true)
|
||||
.resolve(unit, unitElement);
|
||||
|
||||
for (var declaration in unit.declarations) {
|
||||
if (declaration is ClassDeclaration) {
|
||||
for (var member in declaration.members) {
|
||||
if (member is ConstructorDeclaration) {
|
||||
member.body.accept(applier);
|
||||
} else if (member is FieldDeclaration) {
|
||||
if (member.fields.variables.length != 1) {
|
||||
// TODO(scheglov) Handle this case.
|
||||
throw new UnimplementedError('Multiple field');
|
||||
}
|
||||
member.fields.variables[0].initializer?.accept(applier);
|
||||
} else if (member is MethodDeclaration) {
|
||||
member.body.accept(applier);
|
||||
} else {
|
||||
// TODO(scheglov) Handle more cases.
|
||||
throw new UnimplementedError('${member.runtimeType}');
|
||||
}
|
||||
}
|
||||
} else if (declaration is FunctionDeclaration) {
|
||||
declaration.functionExpression.body.accept(applier);
|
||||
} else if (declaration is TopLevelVariableDeclaration) {
|
||||
if (declaration.variables.variables.length != 1) {
|
||||
// TODO(scheglov) Handle this case.
|
||||
throw new UnimplementedError('Multiple variables');
|
||||
}
|
||||
declaration.variables.variables[0].initializer?.accept(applier);
|
||||
} else {
|
||||
// TODO(scheglov) Handle more cases.
|
||||
throw new UnimplementedError('${declaration.runtimeType}');
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Find constants to compute.
|
||||
//
|
||||
{
|
||||
ConstantFinder constantFinder = new ConstantFinder();
|
||||
unit.accept(constantFinder);
|
||||
_constants.addAll(constantFinder.constantsToCompute);
|
||||
}
|
||||
|
||||
//
|
||||
// Find constant dependencies to compute.
|
||||
//
|
||||
{
|
||||
var finder = new ConstantExpressionsDependenciesFinder();
|
||||
unit.accept(finder);
|
||||
_constants.addAll(finder.dependencies);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result of resolve the given [uriContent], reporting errors
|
||||
* against the [uriLiteral].
|
||||
|
|
|
@ -32,43 +32,6 @@ class AnalysisDriverTest_Kernel extends AnalysisDriverTest {
|
|||
await super.test_addFile_shouldRefresh();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_analyze_resolveDirectives() async {
|
||||
await super.test_analyze_resolveDirectives();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_analyze_resolveDirectives_error_missingLibraryDirective() async {
|
||||
await super.test_analyze_resolveDirectives_error_missingLibraryDirective();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_analyze_resolveDirectives_error_partOfDifferentLibrary_byName() async {
|
||||
await super
|
||||
.test_analyze_resolveDirectives_error_partOfDifferentLibrary_byName();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_analyze_resolveDirectives_error_partOfDifferentLibrary_byUri() async {
|
||||
await super
|
||||
.test_analyze_resolveDirectives_error_partOfDifferentLibrary_byUri();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_analyze_resolveDirectives_error_partOfNonPart() async {
|
||||
await super.test_analyze_resolveDirectives_error_partOfNonPart();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
|
@ -311,48 +274,6 @@ void main() {
|
|||
await super.test_getResult_selfConsistent();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_hermetic_modifyLibraryFile_resolvePart() async {
|
||||
await super.test_hermetic_modifyLibraryFile_resolvePart();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_hermetic_overlayOnly_part() async {
|
||||
await super.test_hermetic_overlayOnly_part();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_getErrors_afterLibrary() async {
|
||||
await super.test_part_getErrors_afterLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_getErrors_beforeLibrary() async {
|
||||
await super.test_part_getErrors_beforeLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_getResult_afterLibrary() async {
|
||||
await super.test_part_getResult_afterLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_getResult_beforeLibrary() async {
|
||||
await super.test_part_getResult_beforeLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@FastaProblem('https://github.com/dart-lang/sdk/issues/30959')
|
||||
@override
|
||||
|
@ -360,13 +281,6 @@ void main() {
|
|||
await super.test_part_getResult_noLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_getUnitElement_afterLibrary() async {
|
||||
await super.test_part_getUnitElement_afterLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@FastaProblem('https://github.com/dart-lang/sdk/issues/30959')
|
||||
@override
|
||||
|
@ -375,13 +289,6 @@ void main() {
|
|||
await super.test_part_getUnitElement_noLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_getUnitElementSignature() async {
|
||||
await super.test_part_getUnitElementSignature();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@FastaProblem('https://github.com/dart-lang/sdk/issues/30959')
|
||||
@override
|
||||
|
@ -389,13 +296,6 @@ void main() {
|
|||
await super.test_part_results_afterLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_results_beforeLibrary() async {
|
||||
await super.test_part_results_beforeLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@FastaProblem('https://github.com/dart-lang/sdk/issues/30959')
|
||||
@override
|
||||
|
@ -403,13 +303,6 @@ void main() {
|
|||
await super.test_part_results_noLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_part_results_priority_beforeLibrary() async {
|
||||
await super.test_part_results_priority_beforeLibrary();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue