Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
chore: update analyzer dependency (#429)
Browse files Browse the repository at this point in the history
* chore: update analyzer dependency

* build: update version
  • Loading branch information
dkrutskikh committed Aug 19, 2021
1 parent bb13514 commit f6739aa
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.2.0-dev.3

* Changed the supported `analyzer` version to `^2.1.0`.

## 4.2.0-dev.2

* Changed the supported `analyzer` version to `^2.0.0`.
Expand Down
15 changes: 7 additions & 8 deletions lib/src/analyzer_plugin/analyzer_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class MetricsAnalyzerPlugin extends ServerPlugin {
runZonedGuarded(
() {
dartDriver.results.listen((analysisResult) {
_processResult(dartDriver, analysisResult);
if (analysisResult is ResolvedUnitResult) {
_processResult(dartDriver, analysisResult);
}
});
},
(e, stackTrace) {
Expand Down Expand Up @@ -169,22 +171,19 @@ class MetricsAnalyzerPlugin extends ServerPlugin {
ResolvedUnitResult analysisResult,
) {
try {
final path = analysisResult.path;
if (analysisResult.unit != null &&
path != null &&
(driver.analysisContext?.contextRoot.isAnalyzed(path) ?? false)) {
if (driver.analysisContext?.contextRoot.isAnalyzed(analysisResult.path) ??
false) {
final fixes = _check(driver, analysisResult);

channel.sendNotification(
plugin.AnalysisErrorsParams(
path,
analysisResult.path,
fixes.map((fix) => fix.error).toList(),
).toNotification(),
);
} else {
channel.sendNotification(
plugin.AnalysisErrorsParams(analysisResult.path!, [])
.toNotification(),
plugin.AnalysisErrorsParams(analysisResult.path, []).toNotification(),
);
}
} on Exception catch (e, stackTrace) {
Expand Down
19 changes: 6 additions & 13 deletions lib/src/analyzers/lint_analyzer/lint_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class LintAnalyzer {
filePaths.intersection(context.contextRoot.analyzedFiles().toSet());

for (final filePath in analyzedFiles) {
final unit = await context.currentSession.getResolvedUnit2(filePath);
final unit = await context.currentSession.getResolvedUnit(filePath);
if (unit is ResolvedUnitResult) {
final result = _runAnalysisForFile(
unit,
Expand All @@ -130,19 +130,14 @@ class LintAnalyzer {
String rootFolder, {
String? filePath,
}) {
final unit = result.unit;
final content = result.content;

if (unit != null &&
content != null &&
result.state == ResultState.VALID &&
if (result.state == ResultState.VALID &&
filePath != null &&
_isSupported(result)) {
final ignores = Suppression(content, result.lineInfo);
final ignores = Suppression(result.content, result.lineInfo);
final internalResult = InternalResolvedUnitResult(
filePath,
content,
unit,
result.content,
result.unit,
result.lineInfo,
);
final relativePath = relative(filePath, from: rootFolder);
Expand Down Expand Up @@ -438,7 +433,5 @@ class LintAnalyzer {
}

bool _isSupported(AnalysisResult result) =>
result.path != null &&
result.path!.endsWith('.dart') &&
!result.path!.endsWith('.g.dart');
result.path.endsWith('.dart') && !result.path.endsWith('.g.dart');
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class UnusedFilesAnalyzer {
filePaths.intersection(context.contextRoot.analyzedFiles().toSet());

for (final filePath in analyzedFiles) {
final unit = await context.currentSession.getResolvedUnit2(filePath);
final unit = await context.currentSession.getResolvedUnit(filePath);
unusedFiles.removeAll(_analyzeFile(filePath, unit));
}

Expand Down Expand Up @@ -95,7 +95,7 @@ class UnusedFilesAnalyzer {
Iterable<String> _analyzeFile(String filePath, SomeResolvedUnitResult unit) {
if (unit is ResolvedUnitResult) {
final visitor = UnusedFilesVisitor(filePath);
unit.unit?.visitChildren(visitor);
unit.unit.visitChildren(visitor);

return visitor.paths;
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dart_code_metrics
version: 4.2.0-dev.2
version: 4.2.0-dev.3
description: Software analytics tool that helps developers analyse and improve software quality.
homepage: https://dartcodemetrics.dev
repository: https://github.com/dart-code-checker/dart-code-metrics
Expand All @@ -9,7 +9,7 @@ environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
analyzer: ^2.0.0
analyzer: ^2.1.0
analyzer_plugin: ^0.7.0
ansicolor: ^2.0.1
args: ^2.0.0
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/file_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class FileResolver {

return InternalResolvedUnitResult(
path,
parseResult.content!,
parseResult.unit!,
parseResult.content,
parseResult.unit,
parseResult.lineInfo,
);
}
Expand Down
4 changes: 2 additions & 2 deletions tools/analyzer_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: dart_code_metrics_plugin_loader
description: This pubspec determines the version of the analyzer plugin to load.
version: 4.2.0-dev.2
version: 4.2.0-dev.3

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
dart_code_metrics: ^4.2.0-dev.2
dart_code_metrics: ^4.2.0-dev.3

0 comments on commit f6739aa

Please sign in to comment.