mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:39:49 +00:00
Exclude files from analysis when using AnalysisDriver
R=scheglov@google.com Review URL: https://codereview.chromium.org/2536303002 .
This commit is contained in:
parent
38635ec91e
commit
37387de83a
|
@ -675,6 +675,65 @@ class ContextManagerImpl implements ContextManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process [options] for the given context [info].
|
||||
*/
|
||||
void processOptionsForDriver(ContextInfo info, Map<String, Object> options,
|
||||
{bool optionsRemoved: false}) {
|
||||
if (options == null && !optionsRemoved) {
|
||||
return;
|
||||
}
|
||||
AnalysisOptions analysisOptions = info.analysisDriver.analysisOptions;
|
||||
|
||||
// In case options files are removed, revert to defaults.
|
||||
if (optionsRemoved) {
|
||||
// Start with defaults.
|
||||
analysisOptions.resetToDefaults();
|
||||
|
||||
// Apply inherited options.
|
||||
options = _toStringMap(_getEmbeddedOptions(info));
|
||||
if (options != null) {
|
||||
applyToAnalysisOptions(analysisOptions, options);
|
||||
}
|
||||
} else {
|
||||
// Check for embedded options.
|
||||
Map embeddedOptions = _getEmbeddedOptions(info);
|
||||
if (embeddedOptions != null) {
|
||||
options = _toStringMap(new Merger().merge(embeddedOptions, options));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(brianwilkerson) Figure out what to do here.
|
||||
// // Notify options processors.
|
||||
// AnalysisEngine.instance.optionsPlugin.optionsProcessors
|
||||
// .forEach((OptionsProcessor p) {
|
||||
// try {
|
||||
// p.optionsProcessed(info.context, options);
|
||||
// } catch (e, stacktrace) {
|
||||
// AnalysisEngine.instance.logger.logError(
|
||||
// 'Error processing analysis options',
|
||||
// new CaughtException(e, stacktrace));
|
||||
// }
|
||||
// });
|
||||
|
||||
applyToAnalysisOptions(analysisOptions, options);
|
||||
|
||||
// Nothing more to do.
|
||||
if (options == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var analyzer = options[AnalyzerOptions.analyzer];
|
||||
if (analyzer is Map) {
|
||||
// Set ignore patterns.
|
||||
YamlList exclude = analyzer[AnalyzerOptions.exclude];
|
||||
List<String> excludeList = toStringList(exclude);
|
||||
if (excludeList != null) {
|
||||
setIgnorePatternsForContext(info, excludeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the options from the analysis options file in the given [folder]
|
||||
* if exists, or in one of the parent folders, or `null` if no analysis
|
||||
|
@ -1105,7 +1164,7 @@ class ContextManagerImpl implements ContextManager {
|
|||
}
|
||||
|
||||
if (enableNewAnalysisDriver) {
|
||||
// TODO(scheglov) implement for the new analysis driver
|
||||
processOptionsForDriver(info, optionMap);
|
||||
} else {
|
||||
processOptionsForContext(info, optionMap);
|
||||
}
|
||||
|
|
|
@ -1259,6 +1259,11 @@ abstract class AnalysisOptions {
|
|||
*/
|
||||
List<int> encodeCrossContextOptions();
|
||||
|
||||
/**
|
||||
* Reset the state of this set of analysis options to its original state.
|
||||
*/
|
||||
void resetToDefaults();
|
||||
|
||||
/**
|
||||
* Set the values of the cross-context options to match those in the given set
|
||||
* of [options].
|
||||
|
@ -1582,6 +1587,38 @@ class AnalysisOptionsImpl implements AnalysisOptions {
|
|||
return <int>[flags, patchPlatform];
|
||||
}
|
||||
|
||||
@override
|
||||
void resetToDefaults() {
|
||||
dart2jsHint = false;
|
||||
disableCacheFlushing = false;
|
||||
enableAssertInitializer = false;
|
||||
enableAssertMessage = false;
|
||||
enableLazyAssignmentOperators = false;
|
||||
enableStrictCallChecks = false;
|
||||
enableSuperMixins = false;
|
||||
enableTiming = false;
|
||||
enableUriInPartOf = false;
|
||||
_errorProcessors = null;
|
||||
_excludePatterns = null;
|
||||
finerGrainedInvalidation = false;
|
||||
generateImplicitErrors = true;
|
||||
generateSdkErrors = false;
|
||||
hint = true;
|
||||
implicitCasts = true;
|
||||
implicitDynamic = true;
|
||||
incremental = false;
|
||||
incrementalApi = false;
|
||||
incrementalValidation = false;
|
||||
lint = false;
|
||||
_lintRules = null;
|
||||
nonnullableTypes = NONNULLABLE_TYPES;
|
||||
patchPlatform = 0;
|
||||
preserveComments = true;
|
||||
strongMode = false;
|
||||
strongModeHints = false;
|
||||
trackCacheDependencies = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void setCrossContextOptionsFrom(AnalysisOptions options) {
|
||||
enableAssertMessage = options.enableAssertMessage;
|
||||
|
|
|
@ -28,10 +28,80 @@ import 'package:typed_mock/typed_mock.dart';
|
|||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(AnalysisOptionsImplTest);
|
||||
defineReflectiveTests(SourcesChangedEventTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class AnalysisOptionsImplTest {
|
||||
test_resetToDefaults() {
|
||||
// Note that this only tests options visible from the interface.
|
||||
AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
|
||||
AnalysisOptionsImpl modifiedOptions = new AnalysisOptionsImpl();
|
||||
modifiedOptions.dart2jsHint = true;
|
||||
modifiedOptions.disableCacheFlushing = true;
|
||||
modifiedOptions.enableAssertInitializer = true;
|
||||
modifiedOptions.enableAssertMessage = true;
|
||||
modifiedOptions.enableLazyAssignmentOperators = true;
|
||||
modifiedOptions.enableStrictCallChecks = true;
|
||||
modifiedOptions.enableSuperMixins = true;
|
||||
modifiedOptions.enableTiming = true;
|
||||
modifiedOptions.enableUriInPartOf = true;
|
||||
modifiedOptions.errorProcessors = [null];
|
||||
modifiedOptions.excludePatterns = ['a'];
|
||||
modifiedOptions.finerGrainedInvalidation = true;
|
||||
modifiedOptions.generateImplicitErrors = false;
|
||||
modifiedOptions.generateSdkErrors = true;
|
||||
modifiedOptions.hint = false;
|
||||
modifiedOptions.incremental = true;
|
||||
modifiedOptions.incrementalApi = true;
|
||||
modifiedOptions.incrementalValidation = true;
|
||||
modifiedOptions.lint = true;
|
||||
modifiedOptions.lintRules = [null];
|
||||
modifiedOptions.patchPlatform = 3;
|
||||
modifiedOptions.preserveComments = false;
|
||||
modifiedOptions.strongMode = true;
|
||||
modifiedOptions.trackCacheDependencies = false;
|
||||
|
||||
modifiedOptions.resetToDefaults();
|
||||
|
||||
expect(modifiedOptions.dart2jsHint, defaultOptions.dart2jsHint);
|
||||
expect(modifiedOptions.disableCacheFlushing,
|
||||
defaultOptions.disableCacheFlushing);
|
||||
expect(modifiedOptions.enableAssertInitializer,
|
||||
defaultOptions.enableAssertInitializer);
|
||||
expect(modifiedOptions.enableAssertMessage,
|
||||
defaultOptions.enableAssertMessage);
|
||||
expect(modifiedOptions.enableLazyAssignmentOperators,
|
||||
defaultOptions.enableLazyAssignmentOperators);
|
||||
expect(modifiedOptions.enableStrictCallChecks,
|
||||
defaultOptions.enableStrictCallChecks);
|
||||
expect(modifiedOptions.enableSuperMixins, defaultOptions.enableSuperMixins);
|
||||
expect(modifiedOptions.enableTiming, defaultOptions.enableTiming);
|
||||
expect(modifiedOptions.enableUriInPartOf, defaultOptions.enableUriInPartOf);
|
||||
expect(modifiedOptions.errorProcessors, defaultOptions.errorProcessors);
|
||||
expect(modifiedOptions.excludePatterns, defaultOptions.excludePatterns);
|
||||
expect(modifiedOptions.finerGrainedInvalidation,
|
||||
defaultOptions.finerGrainedInvalidation);
|
||||
expect(modifiedOptions.generateImplicitErrors,
|
||||
defaultOptions.generateImplicitErrors);
|
||||
expect(modifiedOptions.generateSdkErrors, defaultOptions.generateSdkErrors);
|
||||
expect(modifiedOptions.hint, defaultOptions.hint);
|
||||
expect(modifiedOptions.incremental, defaultOptions.incremental);
|
||||
expect(modifiedOptions.incrementalApi, defaultOptions.incrementalApi);
|
||||
expect(modifiedOptions.incrementalValidation,
|
||||
defaultOptions.incrementalValidation);
|
||||
expect(modifiedOptions.lint, defaultOptions.lint);
|
||||
expect(modifiedOptions.lintRules, defaultOptions.lintRules);
|
||||
expect(modifiedOptions.patchPlatform, defaultOptions.patchPlatform);
|
||||
expect(modifiedOptions.preserveComments, defaultOptions.preserveComments);
|
||||
expect(modifiedOptions.strongMode, defaultOptions.strongMode);
|
||||
expect(modifiedOptions.trackCacheDependencies,
|
||||
defaultOptions.trackCacheDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A listener used to gather the [ImplicitAnalysisEvent]s that are produced
|
||||
* during analysis.
|
||||
|
|
Loading…
Reference in a new issue