mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Use 'useCFE' flag to turn on CFE in AnalysisDriver.
R=brianwilkerson@google.com Change-Id: If0aa7d10bc46f1dd408d0be8128fc25538758359 Reviewed-on: https://dart-review.googlesource.com/68720 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
98cf15cf5b
commit
80e08e0913
10 changed files with 55 additions and 88 deletions
|
@ -155,8 +155,8 @@ class _IsTestGroup {
|
|||
new ContextRoot(resourceProvider.convertPath('/project'), [],
|
||||
pathContext: resourceProvider.pathContext),
|
||||
sourceFactory,
|
||||
new AnalysisOptionsImpl(),
|
||||
enableKernelDriver: useCFE);
|
||||
new AnalysisOptionsImpl()..useFastaParser = useCFE,
|
||||
useCFE: useCFE);
|
||||
scheduler.start();
|
||||
AnalysisEngine.instance.logger = PrintLogger.instance;
|
||||
}
|
||||
|
|
|
@ -300,6 +300,10 @@ ex(e) {
|
|||
class _ControlFlowCompletionTest_UseCfe extends _ControlFlowCompletionTest {
|
||||
@override
|
||||
bool get useCFE => true;
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_ifNoBlock() => super.test_ifNoBlock();
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
|
@ -838,6 +842,18 @@ main() {
|
|||
class _ExpressionCompletionTest_UseCfe extends _ExpressionCompletionTest {
|
||||
@override
|
||||
bool get useCFE => true;
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_listAssign() => super.test_listAssign();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_listAssignMultiLine() => super.test_listAssignMultiLine();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_stringAssign() => super.test_stringAssign();
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
|
@ -1642,6 +1658,10 @@ main() {
|
|||
class _SimpleCompletionTest_UseCfe extends _SimpleCompletionTest {
|
||||
@override
|
||||
bool get useCFE => true;
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_semicolonVar() => super.test_semicolonVar();
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
|
|
|
@ -6315,49 +6315,11 @@ class AssistProcessorTest_UseCFE extends AssistProcessorTest {
|
|||
@override
|
||||
bool get useCFE => true;
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_addTypeAnnotation_parameter_BAD_hasExplicitType() =>
|
||||
super.test_addTypeAnnotation_parameter_BAD_hasExplicitType();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_addTypeAnnotation_parameter_BAD_noPropagatedType() =>
|
||||
super.test_addTypeAnnotation_parameter_BAD_noPropagatedType();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_addTypeAnnotation_parameter_OK() =>
|
||||
super.test_addTypeAnnotation_parameter_OK();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_convertToFinalField_OK_hasOverride() =>
|
||||
super.test_convertToFinalField_OK_hasOverride();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_convertToFunctionSyntax_BAD_functionTypedParameter_insideParameterList() =>
|
||||
super
|
||||
.test_convertToFunctionSyntax_BAD_functionTypedParameter_insideParameterList();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_convertToFunctionSyntax_BAD_functionTypedParameter_noParameterTypes() =>
|
||||
super
|
||||
.test_convertToFunctionSyntax_BAD_functionTypedParameter_noParameterTypes();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_convertToFunctionSyntax_OK_functionTypedParameter_noReturnType_noTypeParameters() =>
|
||||
super
|
||||
.test_convertToFunctionSyntax_OK_functionTypedParameter_noReturnType_noTypeParameters();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_convertToFunctionSyntax_OK_functionTypedParameter_returnType() =>
|
||||
super.test_convertToFunctionSyntax_OK_functionTypedParameter_returnType();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_convertToGetter_OK() => super.test_convertToGetter_OK();
|
||||
|
@ -6609,11 +6571,6 @@ class AssistProcessorTest_UseCFE extends AssistProcessorTest {
|
|||
@override
|
||||
test_importAddShow_BAD_unresolvedUri() =>
|
||||
super.test_importAddShow_BAD_unresolvedUri();
|
||||
|
||||
@failingTest
|
||||
@override
|
||||
test_removeTypeAnnotation_topLevelVariable_BAD_syntheticName() =>
|
||||
super.test_removeTypeAnnotation_topLevelVariable_BAD_syntheticName();
|
||||
}
|
||||
|
||||
class _DartAssistContextForValues implements DartAssistContext {
|
||||
|
|
|
@ -200,7 +200,7 @@ class ContextBuilder {
|
|||
contextRoot,
|
||||
sf,
|
||||
options,
|
||||
enableKernelDriver: useCFE,
|
||||
useCFE: useCFE,
|
||||
kernelPlatformFolder: kernelPlatformFolder);
|
||||
// temporary plugin support:
|
||||
if (onCreateAnalysisDriver != null) {
|
||||
|
|
|
@ -105,7 +105,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
/**
|
||||
* Whether kernel should be used to resynthesize elements.
|
||||
*/
|
||||
final bool enableKernelDriver;
|
||||
final bool _useCFE;
|
||||
|
||||
/**
|
||||
* The [Folder] with the `vm_platform.dill` file.
|
||||
|
@ -113,7 +113,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
* We use `vm_platform.dill`, because loading patches is not yet implemented,
|
||||
* and patches are not a part of SDK distribution.
|
||||
*/
|
||||
final Folder kernelPlatformFolder;
|
||||
final Folder _kernelPlatformFolder;
|
||||
|
||||
/**
|
||||
* The scheduler that schedules analysis work in this, and possibly other
|
||||
|
@ -351,15 +351,17 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
this.contextRoot,
|
||||
SourceFactory sourceFactory,
|
||||
this._analysisOptions,
|
||||
{this.enableKernelDriver: false,
|
||||
this.kernelPlatformFolder,
|
||||
{bool useCFE: false,
|
||||
Folder kernelPlatformFolder,
|
||||
PackageBundle sdkBundle,
|
||||
this.disableChangesAndCacheAllResults: false,
|
||||
SummaryDataStore externalSummaries})
|
||||
: _logger = logger,
|
||||
_sourceFactory = sourceFactory.clone(),
|
||||
_sdkBundle = sdkBundle,
|
||||
_externalSummaries = externalSummaries {
|
||||
_externalSummaries = externalSummaries,
|
||||
_useCFE = useCFE,
|
||||
_kernelPlatformFolder = kernelPlatformFolder {
|
||||
_createNewSession();
|
||||
_onResults = _resultController.stream.asBroadcastStream();
|
||||
_testView = new AnalysisDriverTestView(this);
|
||||
|
@ -1246,7 +1248,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
_testView.numOfAnalyzedLibraries++;
|
||||
|
||||
LibraryAnalyzer analyzer;
|
||||
if (enableKernelDriver) {
|
||||
if (_useCFE) {
|
||||
kernelContext = await _createKernelContext(library);
|
||||
analyzer = new LibraryAnalyzer(
|
||||
_logger,
|
||||
|
@ -1257,8 +1259,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
kernelContext.analysisContext,
|
||||
kernelContext.resynthesizer,
|
||||
library,
|
||||
enableKernelDriver: true,
|
||||
useCFE: _analysisOptions.useFastaParser,
|
||||
useCFE: true,
|
||||
frontEndCompiler: _frontEndCompiler);
|
||||
} else {
|
||||
if (!_fsState.getFileForUri(Uri.parse('dart:core')).exists) {
|
||||
|
@ -1348,7 +1349,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
}
|
||||
}
|
||||
|
||||
if (enableKernelDriver) {
|
||||
if (_useCFE) {
|
||||
var kernelContext = await _createKernelContext(library);
|
||||
try {
|
||||
CompilationUnitElement element =
|
||||
|
@ -1425,12 +1426,12 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
* changes.
|
||||
*/
|
||||
void _createKernelDriver() {
|
||||
if (enableKernelDriver) {
|
||||
if (_useCFE) {
|
||||
_frontEndCompiler = new FrontEndCompiler(
|
||||
_logger,
|
||||
_byteStore,
|
||||
analysisOptions,
|
||||
kernelPlatformFolder,
|
||||
_kernelPlatformFolder,
|
||||
sourceFactory,
|
||||
fsState,
|
||||
_resourceProvider.pathContext);
|
||||
|
|
|
@ -52,7 +52,6 @@ class LibraryAnalyzer {
|
|||
final SourceFactory _sourceFactory;
|
||||
final FileState _library;
|
||||
|
||||
final bool _enableKernelDriver;
|
||||
final bool _useCFE;
|
||||
final FrontEndCompiler _frontEndCompiler;
|
||||
|
||||
|
@ -82,11 +81,9 @@ class LibraryAnalyzer {
|
|||
this._context,
|
||||
this._resynthesizer,
|
||||
this._library,
|
||||
{bool enableKernelDriver: false,
|
||||
bool useCFE: false,
|
||||
{bool useCFE: false,
|
||||
FrontEndCompiler frontEndCompiler})
|
||||
: _typeProvider = _context.typeProvider,
|
||||
_enableKernelDriver = enableKernelDriver,
|
||||
_useCFE = useCFE,
|
||||
_frontEndCompiler = frontEndCompiler;
|
||||
|
||||
|
@ -556,7 +553,7 @@ class LibraryAnalyzer {
|
|||
definingCompilationUnit.element = _libraryElement.definingCompilationUnit;
|
||||
|
||||
bool matchNodeElement(Directive node, Element element) {
|
||||
if (_enableKernelDriver) {
|
||||
if (_useCFE) {
|
||||
return node.keyword.offset == element.nameOffset;
|
||||
} else {
|
||||
return node.offset == element.nameOffset;
|
||||
|
@ -567,7 +564,7 @@ class LibraryAnalyzer {
|
|||
|
||||
void reportErrorReportedByFrontEnd(
|
||||
ErrorCode errorCode, AstNode node, List<Object> arguments) {
|
||||
if (!_enableKernelDriver) {
|
||||
if (!_useCFE) {
|
||||
libraryErrorReporter.reportErrorForNode(errorCode, node, arguments);
|
||||
}
|
||||
}
|
||||
|
@ -701,8 +698,7 @@ class LibraryAnalyzer {
|
|||
}
|
||||
}
|
||||
|
||||
new DeclarationResolver(enableKernelDriver: _enableKernelDriver)
|
||||
.resolve(unit, unitElement);
|
||||
new DeclarationResolver().resolve(unit, unitElement);
|
||||
|
||||
if (_libraryElement.context.analysisOptions.previewDart2) {
|
||||
unit.accept(new AstRewriteVisitor(_context.typeSystem, _libraryElement,
|
||||
|
@ -737,8 +733,7 @@ class LibraryAnalyzer {
|
|||
void _resolveFile2(FileState file, CompilationUnitImpl unit,
|
||||
CollectedResolution resolution) {
|
||||
CompilationUnitElement unitElement = unit.declaredElement;
|
||||
new DeclarationResolver(enableKernelDriver: true, applyKernelTypes: true)
|
||||
.resolve(unit, unitElement);
|
||||
new DeclarationResolver(useCFE: true).resolve(unit, unitElement);
|
||||
|
||||
var applierContext = new _ResolutionApplierContext(_resynthesizer,
|
||||
_typeProvider, _libraryElement, resolution, unit.localDeclarations);
|
||||
|
|
|
@ -27,8 +27,7 @@ import 'package:analyzer/src/generated/resolver.dart';
|
|||
* any more complete than a [COMPILATION_UNIT_ELEMENT].
|
||||
*/
|
||||
class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
||||
final bool _enableKernelDriver;
|
||||
final bool _applyKernelTypes;
|
||||
final bool _useCFE;
|
||||
|
||||
/**
|
||||
* The compilation unit containing the AST nodes being visited.
|
||||
|
@ -51,10 +50,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
*/
|
||||
ElementWalker _walker;
|
||||
|
||||
DeclarationResolver(
|
||||
{bool enableKernelDriver: false, bool applyKernelTypes: false})
|
||||
: _enableKernelDriver = enableKernelDriver,
|
||||
_applyKernelTypes = applyKernelTypes;
|
||||
DeclarationResolver({bool useCFE: false}) : _useCFE = useCFE;
|
||||
|
||||
/**
|
||||
* Resolve the declarations within the given compilation [unit] to the
|
||||
|
@ -107,7 +103,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
@override
|
||||
Object visitClassDeclaration(ClassDeclaration node) {
|
||||
ClassElement element = _match(node.name, _walker.getClass());
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
node.name.staticType = _typeProvider.typeType;
|
||||
}
|
||||
_walk(new ElementWalker.forClass(element), () {
|
||||
|
@ -120,7 +116,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
@override
|
||||
Object visitClassTypeAlias(ClassTypeAlias node) {
|
||||
ClassElement element = _match(node.name, _walker.getClass());
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
node.name.staticType = _typeProvider.typeType;
|
||||
}
|
||||
_walk(new ElementWalker.forClass(element), () {
|
||||
|
@ -139,7 +135,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
super.visitConstructorDeclaration(node);
|
||||
});
|
||||
resolveMetadata(node, node.metadata, element);
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
_applyTypeToIdentifier(node.returnType, element.returnType);
|
||||
node.name?.staticType = element.type;
|
||||
}
|
||||
|
@ -189,7 +185,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
@override
|
||||
Object visitEnumDeclaration(EnumDeclaration node) {
|
||||
ClassElement element = _match(node.name, _walker.getEnum());
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
node.name.staticType = _typeProvider.typeType;
|
||||
for (var constant in node.constants) {
|
||||
SimpleIdentifier name = constant.name;
|
||||
|
@ -266,7 +262,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
|
||||
@override
|
||||
Object visitFormalParameterList(FormalParameterList node) {
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
applyParameters(_enclosingLibrary, _walker._parameters, node);
|
||||
_walker.consumeParameters();
|
||||
return null;
|
||||
|
@ -293,7 +289,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
elementName: functionName.name + '=');
|
||||
}
|
||||
}
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
if (node.isGetter) {
|
||||
node.name.staticType = element.returnType;
|
||||
} else if (node.isSetter) {
|
||||
|
@ -438,7 +434,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
elementName: nameOfMethod + '=');
|
||||
}
|
||||
}
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
if (node.isGetter) {
|
||||
node.name.staticType = element.returnType;
|
||||
} else if (node.isSetter) {
|
||||
|
@ -517,8 +513,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
|
||||
@override
|
||||
Object visitTypeParameter(TypeParameter node) {
|
||||
if (node.parent.parent is FunctionTypedFormalParameter &&
|
||||
!_enableKernelDriver) {
|
||||
if (node.parent.parent is FunctionTypedFormalParameter && !_useCFE) {
|
||||
// Work around dartbug.com/28515.
|
||||
// TODO(paulberry): remove this once dartbug.com/28515 is fixed.
|
||||
var element = new TypeParameterElementImpl.forNode(node.name);
|
||||
|
@ -537,7 +532,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
@override
|
||||
Object visitVariableDeclaration(VariableDeclaration node) {
|
||||
VariableElement element = _match(node.name, _walker.getVariable());
|
||||
if (_applyKernelTypes) {
|
||||
if (_useCFE) {
|
||||
node.name.staticType = element.type;
|
||||
}
|
||||
Expression initializer = node.initializer;
|
||||
|
|
|
@ -699,7 +699,7 @@ class ResolverTestCase extends EngineTestCase {
|
|||
null,
|
||||
sourceFactory,
|
||||
options,
|
||||
enableKernelDriver: enableKernelDriver);
|
||||
useCFE: enableKernelDriver);
|
||||
scheduler.start();
|
||||
} else {
|
||||
if (packages != null) {
|
||||
|
|
|
@ -106,7 +106,7 @@ class BaseAnalysisDriverTest {
|
|||
createAnalysisOptions(),
|
||||
disableChangesAndCacheAllResults: disableChangesAndCacheAllResults,
|
||||
externalSummaries: externalSummaries,
|
||||
enableKernelDriver: useCFE);
|
||||
useCFE: useCFE);
|
||||
}
|
||||
|
||||
AnalysisOptionsImpl createAnalysisOptions() =>
|
||||
|
|
|
@ -617,9 +617,8 @@ class Driver extends Object with HasContextMixin implements CommandLineStarter {
|
|||
PerformanceLog log = new PerformanceLog(null);
|
||||
AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log);
|
||||
|
||||
bool enableKernelDriver = options.useCFE;
|
||||
file_system.Folder kernelPlatformBinariesFolder;
|
||||
if (enableKernelDriver && options.dartSdkPlatformBinariesPath != null) {
|
||||
if (options.useCFE && options.dartSdkPlatformBinariesPath != null) {
|
||||
kernelPlatformBinariesFolder =
|
||||
resourceProvider.getFolder(options.dartSdkPlatformBinariesPath);
|
||||
}
|
||||
|
@ -633,7 +632,7 @@ class Driver extends Object with HasContextMixin implements CommandLineStarter {
|
|||
null,
|
||||
sourceFactory,
|
||||
analysisOptions,
|
||||
enableKernelDriver: enableKernelDriver,
|
||||
useCFE: options.useCFE,
|
||||
kernelPlatformFolder: kernelPlatformBinariesFolder);
|
||||
analysisDriver.results.listen((_) {});
|
||||
analysisDriver.exceptions.listen((_) {});
|
||||
|
|
Loading…
Reference in a new issue