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

Commit aa5b0ed

Browse files
committed
revert: Changed the supported analyzer version to ^2.1.0.
1 parent f6739aa commit aa5b0ed

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.2.0-dev.4
4+
5+
* Revert: Changed the supported `analyzer` version to `^2.1.0`.
6+
37
## 4.2.0-dev.3
48

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

lib/src/analyzer_plugin/analyzer_plugin.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ class MetricsAnalyzerPlugin extends ServerPlugin {
9797
runZonedGuarded(
9898
() {
9999
dartDriver.results.listen((analysisResult) {
100-
if (analysisResult is ResolvedUnitResult) {
101-
_processResult(dartDriver, analysisResult);
102-
}
100+
_processResult(dartDriver, analysisResult);
103101
});
104102
},
105103
(e, stackTrace) {
@@ -171,19 +169,22 @@ class MetricsAnalyzerPlugin extends ServerPlugin {
171169
ResolvedUnitResult analysisResult,
172170
) {
173171
try {
174-
if (driver.analysisContext?.contextRoot.isAnalyzed(analysisResult.path) ??
175-
false) {
172+
final path = analysisResult.path;
173+
if (analysisResult.unit != null &&
174+
path != null &&
175+
(driver.analysisContext?.contextRoot.isAnalyzed(path) ?? false)) {
176176
final fixes = _check(driver, analysisResult);
177177

178178
channel.sendNotification(
179179
plugin.AnalysisErrorsParams(
180-
analysisResult.path,
180+
path,
181181
fixes.map((fix) => fix.error).toList(),
182182
).toNotification(),
183183
);
184184
} else {
185185
channel.sendNotification(
186-
plugin.AnalysisErrorsParams(analysisResult.path, []).toNotification(),
186+
plugin.AnalysisErrorsParams(analysisResult.path!, [])
187+
.toNotification(),
187188
);
188189
}
189190
} on Exception catch (e, stackTrace) {

lib/src/analyzers/lint_analyzer/lint_analyzer.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class LintAnalyzer {
105105
filePaths.intersection(context.contextRoot.analyzedFiles().toSet());
106106

107107
for (final filePath in analyzedFiles) {
108-
final unit = await context.currentSession.getResolvedUnit(filePath);
108+
final unit = await context.currentSession.getResolvedUnit2(filePath);
109109
if (unit is ResolvedUnitResult) {
110110
final result = _runAnalysisForFile(
111111
unit,
@@ -130,14 +130,19 @@ class LintAnalyzer {
130130
String rootFolder, {
131131
String? filePath,
132132
}) {
133-
if (result.state == ResultState.VALID &&
133+
final unit = result.unit;
134+
final content = result.content;
135+
136+
if (unit != null &&
137+
content != null &&
138+
result.state == ResultState.VALID &&
134139
filePath != null &&
135140
_isSupported(result)) {
136-
final ignores = Suppression(result.content, result.lineInfo);
141+
final ignores = Suppression(content, result.lineInfo);
137142
final internalResult = InternalResolvedUnitResult(
138143
filePath,
139-
result.content,
140-
result.unit,
144+
content,
145+
unit,
141146
result.lineInfo,
142147
);
143148
final relativePath = relative(filePath, from: rootFolder);
@@ -433,5 +438,7 @@ class LintAnalyzer {
433438
}
434439

435440
bool _isSupported(AnalysisResult result) =>
436-
result.path.endsWith('.dart') && !result.path.endsWith('.g.dart');
441+
result.path != null &&
442+
result.path!.endsWith('.dart') &&
443+
!result.path!.endsWith('.g.dart');
437444
}

lib/src/analyzers/unused_files_analyzer/unused_files_analyzer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class UnusedFilesAnalyzer {
6767
filePaths.intersection(context.contextRoot.analyzedFiles().toSet());
6868

6969
for (final filePath in analyzedFiles) {
70-
final unit = await context.currentSession.getResolvedUnit(filePath);
70+
final unit = await context.currentSession.getResolvedUnit2(filePath);
7171
unusedFiles.removeAll(_analyzeFile(filePath, unit));
7272
}
7373

@@ -95,7 +95,7 @@ class UnusedFilesAnalyzer {
9595
Iterable<String> _analyzeFile(String filePath, SomeResolvedUnitResult unit) {
9696
if (unit is ResolvedUnitResult) {
9797
final visitor = UnusedFilesVisitor(filePath);
98-
unit.unit.visitChildren(visitor);
98+
unit.unit?.visitChildren(visitor);
9999

100100
return visitor.paths;
101101
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ environment:
99
sdk: ">=2.12.0 <3.0.0"
1010

1111
dependencies:
12-
analyzer: ^2.1.0
12+
analyzer: 2.0.0
1313
analyzer_plugin: ^0.7.0
1414
ansicolor: ^2.0.1
1515
args: ^2.0.0

test/helpers/file_resolver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class FileResolver {
2828

2929
return InternalResolvedUnitResult(
3030
path,
31-
parseResult.content,
32-
parseResult.unit,
31+
parseResult.content!,
32+
parseResult.unit!,
3333
parseResult.lineInfo,
3434
);
3535
}

0 commit comments

Comments
 (0)