Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 98e6e54

Browse files
author
Dart CI
committed
Version 2.12.0-265.0.dev
Merge commit '934980be801c8007189500ee6980fd81b9eca079' into 'dev'
2 parents c0c5298 + 934980b commit 98e6e54

35 files changed

+1404
-865
lines changed

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,9 +1324,6 @@ class ContextManagerImpl implements ContextManager {
13241324
if (info.excludes(path)) {
13251325
return;
13261326
}
1327-
if (info.ignored(path)) {
1328-
return;
1329-
}
13301327
// handle the change
13311328
switch (type) {
13321329
case ChangeType.ADD:

pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class LibraryMemberContributor extends DartCompletionContributor {
6262
} else {
6363
if (element is ClassElement ||
6464
element is ExtensionElement ||
65-
element is FunctionTypeAliasElement) {
65+
element is TypeAliasElement) {
6666
builder.suggestElement(element,
6767
kind: CompletionSuggestionKind.INVOCATION);
6868
} else if (!typesOnly &&

pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
9696
@override
9797
void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
9898
if (opType.includeTypeNameSuggestions) {
99-
builder.suggestFunctionTypeAlias(element, prefix: prefix);
99+
builder.suggestTypeAlias(element, prefix: prefix);
100100
}
101101
}
102102

@@ -126,6 +126,13 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
126126
}
127127
}
128128

129+
@override
130+
void visitTypeAliasElement(TypeAliasElement element) {
131+
if (opType.includeTypeNameSuggestions) {
132+
builder.suggestTypeAlias(element, prefix: prefix);
133+
}
134+
}
135+
129136
/// Add constructor suggestions for the given class.
130137
void _addConstructorSuggestions(ClassElement classElem) {
131138
for (var constructor in classElem.constructors) {

pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,14 @@ class _LocalVisitor extends LocalDeclarationVisitor {
310310
@override
311311
void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
312312
if (opType.includeTypeNameSuggestions) {
313-
builder.suggestFunctionTypeAlias(declaration.declaredElement,
314-
kind: _defaultKind);
313+
builder.suggestTypeAlias(declaration.declaredElement, kind: _defaultKind);
315314
}
316315
}
317316

318317
@override
319318
void declaredGenericTypeAlias(GenericTypeAlias declaration) {
320319
if (opType.includeTypeNameSuggestions) {
321-
builder.suggestFunctionTypeAlias(declaration.declaredElement,
322-
kind: _defaultKind);
320+
builder.suggestTypeAlias(declaration.declaredElement, kind: _defaultKind);
323321
}
324322
}
325323

pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,11 @@ class SuggestionBuilder {
382382
} else if (element is FunctionElement &&
383383
element.enclosingElement is CompilationUnitElement) {
384384
suggestTopLevelFunction(element, kind: kind);
385-
} else if (element is FunctionTypeAliasElement) {
386-
suggestFunctionTypeAlias(element, kind: kind);
387385
} else if (element is PropertyAccessorElement &&
388386
element.enclosingElement is CompilationUnitElement) {
389387
suggestTopLevelPropertyAccessor(element, kind: kind);
388+
} else if (element is TypeAliasElement) {
389+
suggestTypeAlias(element, kind: kind);
390390
} else {
391391
throw ArgumentError('Cannot suggest a ${element.runtimeType}');
392392
}
@@ -487,19 +487,6 @@ class SuggestionBuilder {
487487
));
488488
}
489489

490-
/// Add a suggestion for a [functionTypeAlias]. If a [kind] is provided it
491-
/// will be used as the kind for the suggestion. If the alias can only be
492-
/// referenced using a prefix, then the [prefix] should be provided.
493-
void suggestFunctionTypeAlias(FunctionTypeAliasElement functionTypeAlias,
494-
{CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
495-
String prefix}) {
496-
var relevance = _computeTopLevelRelevance(functionTypeAlias,
497-
defaultRelevance: 750,
498-
elementType: _instantiateFunctionTypeAlias(functionTypeAlias));
499-
_add(_createSuggestion(functionTypeAlias,
500-
kind: kind, prefix: prefix, relevance: relevance));
501-
}
502-
503490
/// Add a suggestion for a [keyword]. The [offset] is the offset from the
504491
/// beginning of the keyword where the cursor will be left.
505492
void suggestKeyword(String keyword, {int offset}) {
@@ -863,6 +850,18 @@ class SuggestionBuilder {
863850
kind: kind, prefix: prefix, relevance: relevance));
864851
}
865852

853+
/// Add a suggestion for a [typeAlias]. If a [kind] is provided it
854+
/// will be used as the kind for the suggestion. If the alias can only be
855+
/// referenced using a prefix, then the [prefix] should be provided.
856+
void suggestTypeAlias(TypeAliasElement typeAlias,
857+
{CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
858+
String prefix}) {
859+
var relevance = _computeTopLevelRelevance(typeAlias,
860+
defaultRelevance: 750, elementType: _instantiateTypeAlias(typeAlias));
861+
_add(_createSuggestion(typeAlias,
862+
kind: kind, prefix: prefix, relevance: relevance));
863+
}
864+
866865
/// Add a suggestion for a type [parameter].
867866
void suggestTypeParameter(TypeParameterElement parameter) {
868867
var elementKind = _computeElementKind(parameter);
@@ -1083,7 +1082,7 @@ class SuggestionBuilder {
10831082
);
10841083
}
10851084

1086-
FunctionType _instantiateFunctionTypeAlias(FunctionTypeAliasElement element) {
1085+
DartType _instantiateTypeAlias(TypeAliasElement element) {
10871086
var typeParameters = element.typeParameters;
10881087
var typeArguments = const <DartType>[];
10891088
if (typeParameters.isNotEmpty) {

pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ RefactoringStatus validateFunctionName(String name) {
4242
return _validateLowerCamelCase(name, 'Function', allowBuiltIn: true);
4343
}
4444

45-
/// Returns the [RefactoringStatus] with severity:
46-
/// - OK if the name is valid;
47-
/// - WARNING if the name is discouraged;
48-
/// - FATAL if the name is illegal.
49-
RefactoringStatus validateFunctionTypeAliasName(String name) {
50-
return _validateUpperCamelCase(name, 'Function type alias');
51-
}
52-
5345
/// Returns the [RefactoringStatus] with severity:
5446
/// - OK if the name is valid;
5547
/// - WARNING if the name is discouraged;
@@ -120,6 +112,14 @@ RefactoringStatus validateParameterName(String name) {
120112
return _validateLowerCamelCase(name, 'Parameter', allowBuiltIn: true);
121113
}
122114

115+
/// Returns the [RefactoringStatus] with severity:
116+
/// - OK if the name is valid;
117+
/// - WARNING if the name is discouraged;
118+
/// - FATAL if the name is illegal.
119+
RefactoringStatus validateTypeAliasName(String name) {
120+
return _validateUpperCamelCase(name, 'Type alias');
121+
}
122+
123123
/// Returns the [RefactoringStatus] with severity:
124124
/// - OK if the name is valid;
125125
/// - WARNING if the name is discouraged;

pkg/analysis_server/lib/src/services/refactoring/rename_unit_member.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ class RenameUnitMemberRefactoringImpl extends RenameRefactoringImpl {
5454
if (element is FunctionElement) {
5555
return 'Rename Top-Level Function';
5656
}
57-
if (element is FunctionTypeAliasElement) {
58-
return 'Rename Function Type Alias';
59-
}
6057
if (element is TopLevelVariableElement) {
6158
return 'Rename Top-Level Variable';
6259
}
60+
if (element is TypeAliasElement) {
61+
return 'Rename Type Alias';
62+
}
6363
return 'Rename Class';
6464
}
6565

@@ -94,8 +94,8 @@ class RenameUnitMemberRefactoringImpl extends RenameRefactoringImpl {
9494
if (element is FunctionElement) {
9595
result.addStatus(validateFunctionName(newName));
9696
}
97-
if (element is FunctionTypeAliasElement) {
98-
result.addStatus(validateFunctionTypeAliasName(newName));
97+
if (element is TypeAliasElement) {
98+
result.addStatus(validateTypeAliasName(newName));
9999
}
100100
if (element is ClassElement) {
101101
result.addStatus(validateClassName(newName));

pkg/analysis_server/test/abstract_context.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ mixin WithNonFunctionTypeAliasesMixin on AbstractContextTest {
282282
@override
283283
String get testPackageLanguageVersion => null;
284284

285-
@nonVirtual
286285
@override
287286
void setUp() {
288287
super.setUp();

pkg/analysis_server/test/context_manager_test.dart

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -227,32 +227,6 @@ sky_engine:lib/''');
227227
});
228228
}
229229

230-
Future<void> test_path_filter() async {
231-
// Setup context.
232-
var root = newFolder(projPath);
233-
manager.setRoots(<String>[projPath], <String>[]);
234-
expect(callbacks.currentFilePaths, isEmpty);
235-
// Set ignore patterns for context.
236-
var rootInfo = manager.getContextInfoFor(root);
237-
manager.setIgnorePatternsForContext(
238-
rootInfo, ['sdk_ext/**', 'lib/ignoreme.dart']);
239-
// Start creating files.
240-
newFile('$projPath/${ContextManagerImpl.PUBSPEC_NAME}');
241-
var libPath = '$projPath/${ContextManagerTest.LIB_NAME}';
242-
newFile('$libPath/main.dart');
243-
newFile('$libPath/ignoreme.dart');
244-
var sdkExtPath = '$projPath/sdk_ext';
245-
newFile('$sdkExtPath/entry.dart');
246-
var sdkExtSrcPath = '$projPath/sdk_ext/src';
247-
newFile('$sdkExtSrcPath/part.dart');
248-
// Pump event loop so new files are discovered and added to context.
249-
await pumpEventQueue();
250-
// Verify that ignored files were ignored.
251-
var filePaths = callbacks.currentFilePaths;
252-
expect(filePaths, hasLength(1));
253-
expect(filePaths, contains(convertPath('/my/proj/lib/main.dart')));
254-
}
255-
256230
Future<void> test_refresh_folder_with_packagespec() {
257231
// create a context with a .packages file
258232
var packagespecFile = join(projPath, '.packages');

pkg/analysis_server/test/domain_analysis_test.dart

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,18 @@ class AnalysisDomainHandlerTest extends AbstractAnalysisTest {
305305
class AnalysisDomainTest extends AbstractAnalysisTest {
306306
Map<String, List<AnalysisError>> filesErrors = {};
307307

308+
void assertHasErrors(String path) {
309+
expect(filesErrors[path], isNotEmpty);
310+
}
311+
312+
void assertNoErrors(String path) {
313+
expect(filesErrors[path], isEmpty);
314+
}
315+
316+
void assertNoErrorsNotification(String path) {
317+
expect(filesErrors[path], isNull);
318+
}
319+
308320
@override
309321
void processNotification(Notification notification) {
310322
if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) {
@@ -313,6 +325,117 @@ class AnalysisDomainTest extends AbstractAnalysisTest {
313325
}
314326
}
315327

328+
Future<void> test_fileSystem_addFile_excluded() async {
329+
var a_path = convertPath('$projectPath/lib/a.dart');
330+
var b_path = convertPath('$projectPath/lib/b.dart');
331+
332+
newFile('$projectPath/analysis_options.yaml', content: r'''
333+
analyzer:
334+
exclude:
335+
- "**/a.dart"
336+
''');
337+
338+
newFile(b_path, content: r'''
339+
import 'a.dart';
340+
void f(A a) {}
341+
''');
342+
343+
createProject();
344+
await pumpEventQueue();
345+
await server.onAnalysisComplete;
346+
347+
// We don't have a.dart, so the import cannot be resolved.
348+
assertHasErrors(b_path);
349+
350+
newFile(a_path, content: r'''
351+
class A {}
352+
''');
353+
await pumpEventQueue();
354+
await server.onAnalysisComplete;
355+
356+
// We excluded 'a.dart' from analysis, no errors notification for it.
357+
assertNoErrorsNotification(a_path);
358+
359+
// We added a.dart with `A`, so no errors.
360+
assertNoErrors(b_path);
361+
}
362+
363+
Future<void> test_fileSystem_changeFile_excluded() async {
364+
var a_path = convertPath('$projectPath/lib/a.dart');
365+
var b_path = convertPath('$projectPath/lib/b.dart');
366+
367+
newFile('$projectPath/analysis_options.yaml', content: r'''
368+
analyzer:
369+
exclude:
370+
- "**/a.dart"
371+
''');
372+
373+
newFile(a_path, content: r'''
374+
class B {}
375+
''');
376+
377+
newFile(b_path, content: r'''
378+
import 'a.dart';
379+
void f(A a) {}
380+
''');
381+
382+
createProject();
383+
await pumpEventQueue();
384+
await server.onAnalysisComplete;
385+
386+
// We excluded 'a.dart' from analysis, no errors notification for it.
387+
assertNoErrorsNotification(a_path);
388+
389+
// We have `B`, not `A`, in a.dart, so has errors.
390+
assertHasErrors(b_path);
391+
392+
newFile(a_path, content: r'''
393+
class A {}
394+
''');
395+
await pumpEventQueue();
396+
await server.onAnalysisComplete;
397+
398+
// We changed a.dart, to have `A`, so no errors.
399+
assertNoErrors(b_path);
400+
}
401+
402+
Future<void> test_fileSystem_deleteFile_excluded() async {
403+
var a_path = convertPath('$projectPath/lib/a.dart');
404+
var b_path = convertPath('$projectPath/lib/b.dart');
405+
406+
newFile('$projectPath/analysis_options.yaml', content: r'''
407+
analyzer:
408+
exclude:
409+
- "**/a.dart"
410+
''');
411+
412+
newFile(a_path, content: r'''
413+
class A {}
414+
''');
415+
416+
newFile(b_path, content: r'''
417+
import 'a.dart';
418+
void f(A a) {}
419+
''');
420+
421+
createProject();
422+
await pumpEventQueue();
423+
await server.onAnalysisComplete;
424+
425+
// We excluded 'a.dart' from analysis, no errors notification for it.
426+
assertNoErrorsNotification(a_path);
427+
428+
// We have `A` in a.dart, so no errors.
429+
assertNoErrors(b_path);
430+
431+
deleteFile(a_path);
432+
await pumpEventQueue();
433+
await server.onAnalysisComplete;
434+
435+
// We deleted a.dart, so `A` cannot be resolved.
436+
assertHasErrors(b_path);
437+
}
438+
316439
Future<void> test_setRoots_packages() {
317440
// prepare package
318441
var pkgFile = newFile('/packages/pkgA/libA.dart', content: '''

0 commit comments

Comments
 (0)