Skip to content

Commit

Permalink
Version 3.4.0-43.0.dev
Browse files Browse the repository at this point in the history
Merge 4a7dd72 into dev
  • Loading branch information
Dart CI committed Jan 18, 2024
2 parents 0028439 + 4a7dd72 commit 40946a7
Show file tree
Hide file tree
Showing 48 changed files with 941 additions and 588 deletions.
13 changes: 3 additions & 10 deletions pkg/analysis_server/lib/src/analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ abstract class AnalysisServer {
/// analyzed.
void reportAnalysisAnalytics() {
var packagesFileMap = <String, File?>{};
var optionsFileMap = <String, File?>{};
var immediateFileCount = 0;
var immediateFileLineCount = 0;
var transitiveFileCount = 0;
Expand All @@ -752,7 +751,6 @@ abstract class AnalysisServer {
var contextRoot = driver.analysisContext?.contextRoot;
if (contextRoot != null) {
packagesFileMap[rootPath] = contextRoot.packagesFile;
optionsFileMap[rootPath] = contextRoot.optionsFile;
}
var fileSystemState = driver.fsState;
for (var fileState in fileSystemState.knownFiles) {
Expand All @@ -777,20 +775,15 @@ abstract class AnalysisServer {
var styleCounts = [
0, // neither
0, // only packages
0, // only options
0, // both
0, // only options -- (No longer incremented. Options files do not imply unique contexts.)
0, // both -- (No longer incremented. Options files do not imply unique contexts.)
];
var packagesFiles = <File>{};
var optionsFiles = <File>{};
for (var rootPath in rootPaths) {
var packagesFile = packagesFileMap[rootPath];
var hasUniquePackageFile =
packagesFile != null && packagesFiles.add(packagesFile);
var optionsFile = optionsFileMap[rootPath];
var hasUniqueOptionsFile =
optionsFile != null && optionsFiles.add(optionsFile);
var style =
(hasUniquePackageFile ? 1 : 0) + (hasUniqueOptionsFile ? 2 : 0);
var style = hasUniquePackageFile ? 1 : 0;
styleCounts[style]++;
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/analysis_server/lib/src/analytics/analytics_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class AnalyticsManager {
}
}

/// Record information about the number of files and the numer of lines of
/// Record information about the number of files and the number of lines of
/// code in those files, for both immediate files, transitive files, and the
/// number of unique transitive files.
void analysisComplete({
Expand Down Expand Up @@ -469,7 +469,7 @@ class AnalyticsManager {
requestData.responseTimes.addValue(responseTime);
}

/// Send information about the number of files and the numer of lines of code
/// Send information about the number of files and the number of lines of code
/// in those files.
Future<void> _sendAnalysisData() async {
var contextStructure = _contextStructure;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/computer/computer_hover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class DartUnitHoverComputer {
return node;
}

/// Returns information abtout the static type of [node].
/// Returns information about the static type of [node].
String? _typeDisplayString(AstNode node, Element? element) {
var parent = node.parent;
DartType? staticType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class EditGetFixesHandler extends LegacyHandler
var result = engine.ErrorsResultImpl(
session: session,
file: optionsFile,
content: content,
uri: optionsFile.toUri(),
lineInfo: lineInfo,
isAugmentation: false,
Expand Down Expand Up @@ -248,6 +249,7 @@ error.errorCode: ${error.errorCode}
var result = engine.ErrorsResultImpl(
session: session,
file: pubspecFile,
content: content,
uri: pubspecFile.toUri(),
lineInfo: lineInfo,
isAugmentation: false,
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/lsp/client_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class LspGlobalClientConfiguration extends LspResourceClientConfiguration {
bool get completeFunctionCalls =>
_settings['completeFunctionCalls'] as bool? ?? false;

/// A flag for enabling interaactive refactors flagged as experimental.
/// A flag for enabling interactive refactors flagged as experimental.
///
/// This flag is likely to be used by both analysis server developers (working
/// on new refactors) and users that want to test/provide feedback for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ abstract class AbstractCodeActionsProducer
return engine.ErrorsResultImpl(
session: session,
file: file,
content: file.readAsStringSync(),
uri: server.uriConverter.toClientUri(path),
lineInfo: lineInfo,
isAugmentation: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DocumentHighlightsHandler extends SharedMessageHandler<
/// Checks whether an Occurrence offset/length spans the requested
/// offset.
///
/// It's possible multiple occurences might match because some nodes
/// It's possible multiple occurrences might match because some nodes
/// such as object destructuring might match multiple elements (for
/// example the object getter and a declared variable).
bool spansRequestedPosition(int offset, int length) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/analysis_server/lib/src/lsp/mapping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1529,10 +1529,10 @@ typedef CompletionDetail = ({
/// native deprecated tag.
String detail,

/// Truncated parameters. Similate to [truncatedSignature] but does not
/// Truncated parameters. Similar to [truncatedSignature] but does not
/// include return types. Used in clients that cannot format signatures
/// differently and is appended immediately after the completion label. The
/// return type is ommitted to reduce noise because this text is not subtle.
/// return type is omitted to reduce noise because this text is not subtle.
String truncatedParams,

/// A signature with truncated params. Used for showing immediately after
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class FeatureRegistration {
}.toList();
}

/// Types of documents that loaded plugins are interetsed in.
/// Types of documents that loaded plugins are interested in.
List<TextDocumentFilterWithScheme> get pluginTypes => _context.pluginTypes;

/// Whether both the client, and this feature, support dynamic registration.
Expand Down Expand Up @@ -179,7 +179,7 @@ class RegistrationContext {
/// for. This information is derived from the [ClientCapabilities].
final ClientDynamicRegistrations clientDynamic;

/// Types of documents that loaded plugins are interetsed in.
/// Types of documents that loaded plugins are interested in.
final List<TextDocumentFilterWithScheme> pluginTypes;

/// The capabilities of the client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ final class KeywordSuggestion extends CandidateSuggestion {

/// Return a newly created candidate suggestion to suggest the [keyword]
/// followed by the [annotatedText]. The annotated text is used in cases where
/// there is boilerplace that always follows the keyword that should also be
/// there is boilerplate that always follows the keyword that should also be
/// suggested.
///
/// If the annotated text contains a caret (`^`), then the completion will use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'package:analyzer/src/dart/resolver/scope.dart';
/// declarations that are in scope at the completion location.
class DeclarationHelper {
/// The regular expression used to detect an unused identifier (a sequence of
/// one or more underscodes with no other characters).
/// one or more underscores with no other characters).
static final RegExp UnusedIdentifier = RegExp(r'^_+$');

/// The completion request being processed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
}
}

/// Add the suggestions that are approriate at the beginning of an annotation.
/// Add the suggestions that are appropriate at the beginning of an annotation.
void _forAnnotation(AstNode node) {
declarationHelper(mustBeConstant: true).addLexicalDeclarations(node);
}
Expand Down Expand Up @@ -2289,7 +2289,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
return false;
}
// Ideally we'd visit the preceding member in order to avoid duplicating
// code, but the offset will be past where the parser inserted sythetic
// code, but the offset will be past where the parser inserted synthetic
// tokens, preventing that from working.
switch (precedingMember) {
// TODO(brianwilkerson): Add support for other kinds of declarations.
Expand Down Expand Up @@ -2320,7 +2320,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
}
// Ideally we'd visit the preceding member in order to avoid
// duplicating code, but the offset will be past where the parser
// inserted sythetic tokens, preventing that from working.
// inserted synthetic tokens, preventing that from working.
switch (precedingStatement) {
// TODO(brianwilkerson): Add support for other kinds of declarations.
case IfStatement declaration:
Expand Down Expand Up @@ -2387,15 +2387,15 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
.addLexicalDeclarations(node);
}

/// Adds the suggestions that are approriate for the name of a pattern field.
/// Adds the suggestions that are appropriate for the name of a pattern field.
void _forPatternFieldName(PatternFieldName node) {
var pattern = node.parent?.parent;
if (pattern is DartPattern) {
_forPatternFieldNameInPattern(pattern);
}
}

/// Adds the suggestions that are approriate for the name of a pattern field.
/// Adds the suggestions that are appropriate for the name of a pattern field.
void _forPatternFieldNameInPattern(DartPattern? pattern) {
if (pattern is ObjectPattern) {
declarationHelper(mustBeNonVoid: true).addGetters(
Expand Down Expand Up @@ -2479,7 +2479,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
CompilationUnit unit, AstNode precedingMember) {
// Ideally we'd visit the preceding member in order to avoid duplicating
// code, but in some cases the offset will be past where the parser inserted
// sythetic tokens, preventing that from working.
// synthetic tokens, preventing that from working.
switch (precedingMember) {
// TODO(brianwilkerson): Add support for other kinds of declarations.
case ClassDeclaration declaration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/utilities/extensions/map.dart';
import 'package:analyzer/src/utilities/extensions/collection.dart';
import 'package:analyzer_plugin/utilities/assist/assist.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/range_factory.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class MoveDocCommentToLibraryDirective extends ResolvedCorrectionProducer {
///
/// A [Comment] can contain blank lines (even an end-of-line comment, and an
/// end-of-line doc comment). But for the purpose of this fix, we interpret
/// only the first "block" or "paragraph" of text as what was intented to be
/// only the first "block" or "paragraph" of text as what was intended to be
/// the library comment.
SourceRange _rangeOfFirstBlock(Comment comment, LineInfo lineInfo) {
for (var token in comment.tokens) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class UseCurlyBraces extends ParsedCorrectionProducer {

void _replaceLeftParenthesis(DartFileEditBuilder builder,
SyntacticEntity left, SyntacticEntity right, String indent) {
// Keep any comments preceeding right.
// Keep any comments preceding right.
if (right is AstNode) {
right = right.beginToken.precedingComments ?? right;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AnalysisOptionsFixGenerator {

var errorCode = error.errorCode;
// Check whether [errorCode] is within [codeWithFixes], which is (currently)
// the canonical list of analyis option error codes with fixes.
// the canonical list of analysis option error codes with fixes.
// If we move analysis option fixes to the style of correction producers,
// and a map from error codes to the correction producers that can fix
// violations, we won't need this check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class ImportOrganizer {
var comment = firstComment;
var nextComment = comment?.next;
// Don't connect comments that have a blank line between them if this is
// a psuedo-library directive.
// a pseudo-library directive.
while (isPseudoLibraryDirective && comment != null && nextComment != null) {
var currentLine = lineInfo.getLocation(comment.offset).lineNumber;
var nextLine = lineInfo.getLocation(nextComment.offset).lineNumber;
Expand Down
32 changes: 22 additions & 10 deletions pkg/analysis_server/lib/src/status/diagnostics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/context/source.dart';
import 'package:analyzer/src/dart/analysis/analysis_options_map.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
import 'package:analyzer/src/generated/source.dart';
Expand Down Expand Up @@ -159,6 +160,17 @@ String writeOption(String name, dynamic value) {
return '$name: <code>$value</code><br> ';
}

_CollectedOptionsData _collectOptionsData(AnalysisDriver driver) {
var collectedData = _CollectedOptionsData();
if (driver.analysisContext?.allAnalysisOptions case var allAnalysisOptions?) {
for (var analysisOptions in allAnalysisOptions) {
collectedData.lints.addAll(analysisOptions.lintRules.map((e) => e.name));
collectedData.plugins.addAll(analysisOptions.enabledPluginNames);
}
}
return collectedData;
}

class AnalyticsPage extends DiagnosticPageWithNav {
AnalyticsPage(DiagnosticsSite site)
: super(site, 'analytics', 'Analytics',
Expand Down Expand Up @@ -351,13 +363,9 @@ class CollectReportPage extends DiagnosticPage {
contextData['knownFiles'] = data.knownFiles.length;
uniqueKnownFiles.addAll(data.knownFiles);

contextData['lints'] =
// TODO(pq): migrate to *all* analysis options
// ignore: deprecated_member_use
data.analysisOptions.lintRules.map((e) => e.name).toList();
// TODO(pq): migrate to *all* analysis options
// ignore: deprecated_member_use
contextData['plugins'] = data.analysisOptions.enabledPluginNames.toList();
var collectedOptionsData = _collectOptionsData(data);
contextData['lints'] = collectedOptionsData.lints.toList();
contextData['plugins'] = collectedOptionsData.plugins.toList();
}
collectedData['uniqueKnownFiles'] = uniqueKnownFiles.length;

Expand Down Expand Up @@ -751,9 +759,8 @@ class ContextsPage extends DiagnosticPageWithNav {
buf.writeln('</div>');

h3('Plugins');
// TODO(pq): migrate to *all* analysis options
// ignore: deprecated_member_use
p(driver.analysisOptions.enabledPluginNames.join(', '));
var optionsData = _collectOptionsData(driver);
p(optionsData.plugins.toList().join(', '));

var priorityFiles = driver.priorityFiles;
var addedFiles = driver.addedFiles.toList();
Expand Down Expand Up @@ -1659,6 +1666,11 @@ class TimingPage extends DiagnosticPageWithNav with PerformanceChartMixin {
}
}

class _CollectedOptionsData {
final Set<String> lints = <String>{};
final Set<String> plugins = <String>{};
}

extension on String {
String get wordBreakOnSlashes => splitMapJoin('/', onMatch: (_) => '/<wbr>');
}
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/lsp/completion_dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,7 @@ void f() { }
@FailingTest(reason: 'https://github.com/Dart-Code/Dart-Code/issues/4794')
Future<void> test_prefixed_enumMember() async {
// If the first character of the enum member is typed (`self.MyEnum.o^`)
// this test passes. Without any charactres typed (`self.MyEnum.^`) the
// this test passes. Without any characters typed (`self.MyEnum.^`) the
// dotTarget on the completion is `null`. The containingNode is a
// ConstructorName.
final content = '''
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/lsp/document_changes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class Bar {
await pumpEventQueue(times: 5000);
expect(diagnostics[mainFilePath], isNotEmpty);

// Finally, expect deleteing the file clears the diagnostics.
// Finally, expect deleting the file clears the diagnostics.
deleteFile(mainFilePath);
await pumpEventQueue(times: 5000);
expect(diagnostics[mainFilePath], isEmpty);
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/lsp/initialization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ class InitializationTest extends AbstractLspAnalysisServerTest {

/// Verifies a workspace that contains non-file workspace folders is handled.
///
/// Related tests for didChangeWorkspcaeFolders are in
/// Related tests for didChangeWorkspaceFolders are in
/// [ChangeWorkspaceFoldersTest].
Future<void> test_nonFileScheme_workspaceFolders() async {
newPubspecYamlFile(projectFolderPath, '');
Expand Down
7 changes: 4 additions & 3 deletions pkg/analyzer/lib/dart/analysis/results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ abstract class ErrorsResult
///
/// Clients may not extend, implement or mix-in this class.
abstract class FileResult implements SomeFileResult, AnalysisResult {
/// The latest read content of [file], the same that was used to compute
/// other properties of this result.
String get content;

/// The file resource.
File get file;

Expand Down Expand Up @@ -210,9 +214,6 @@ abstract class ParsedLibraryResult
/// Clients may not extend, implement or mix-in this class.
abstract class ParsedUnitResult
implements SomeParsedUnitResult, AnalysisResultWithErrors {
/// The content of the file that was scanned and parsed.
String get content;

/// The parsed, unresolved compilation unit for the [content].
CompilationUnit get unit;
}
Expand Down
Loading

0 comments on commit 40946a7

Please sign in to comment.