Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1758)

Unified Diff: pkg/analyzer/lib/src/dart/analysis/file_state.dart

Issue 2541793005: Return only public top-level declarations. (Closed)
Patch Set: after commit Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/file_state.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 9381aa264841a98ad2a004f0ba0b366ed7c57946..6592d5d6e1cd62e4fb83a86340c1532470f7b87f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -174,47 +174,48 @@ class FileState {
Set<String> get referencedNames => _referencedNames;
/**
- * Return top-level declarations declared in the file.
+ * Return public top-level declarations declared in the file.
*/
List<TopLevelDeclaration> get topLevelDeclarations {
if (_topLevelDeclarations == null) {
_topLevelDeclarations = <TopLevelDeclaration>[];
+
+ void addDeclaration(TopLevelDeclarationKind kind, String name) {
+ if (!name.startsWith('_')) {
+ _topLevelDeclarations.add(new TopLevelDeclaration(kind, name));
+ }
+ }
+
// Add types.
for (UnlinkedClass type in unlinked.classes) {
- _topLevelDeclarations.add(
- new TopLevelDeclaration(TopLevelDeclarationKind.type, type.name));
+ addDeclaration(TopLevelDeclarationKind.type, type.name);
}
for (UnlinkedEnum type in unlinked.enums) {
- _topLevelDeclarations.add(
- new TopLevelDeclaration(TopLevelDeclarationKind.type, type.name));
+ addDeclaration(TopLevelDeclarationKind.type, type.name);
}
for (UnlinkedTypedef type in unlinked.typedefs) {
- _topLevelDeclarations.add(
- new TopLevelDeclaration(TopLevelDeclarationKind.type, type.name));
+ addDeclaration(TopLevelDeclarationKind.type, type.name);
}
// Add functions and variables.
Set<String> addedVariableNames = new Set<String>();
for (UnlinkedExecutable executable in unlinked.executables) {
String name = executable.name;
if (executable.kind == UnlinkedExecutableKind.functionOrMethod) {
- _topLevelDeclarations.add(
- new TopLevelDeclaration(TopLevelDeclarationKind.function, name));
+ addDeclaration(TopLevelDeclarationKind.function, name);
} else if (executable.kind == UnlinkedExecutableKind.getter ||
executable.kind == UnlinkedExecutableKind.setter) {
if (executable.kind == UnlinkedExecutableKind.setter) {
name = name.substring(0, name.length - 1);
}
if (addedVariableNames.add(name)) {
- _topLevelDeclarations.add(new TopLevelDeclaration(
- TopLevelDeclarationKind.variable, name));
+ addDeclaration(TopLevelDeclarationKind.variable, name);
}
}
}
for (UnlinkedVariable variable in unlinked.variables) {
String name = variable.name;
if (addedVariableNames.add(name)) {
- _topLevelDeclarations.add(
- new TopLevelDeclaration(TopLevelDeclarationKind.variable, name));
+ addDeclaration(TopLevelDeclarationKind.variable, name);
}
}
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698