Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
731c5903
Commit
731c5903
authored
Apr 20, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache the source lines when running analyze (#3436)
parent
112f2cc3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
analyze.dart
packages/flutter_tools/lib/src/commands/analyze.dart
+20
-1
No files found.
packages/flutter_tools/lib/src/commands/analyze.dart
View file @
731c5903
...
...
@@ -367,6 +367,8 @@ class AnalyzeCommand extends FlutterCommand {
Set
<
String
>
changedFiles
=
new
Set
<
String
>();
// files about which we've complained that they changed
_SourceCache
cache
=
new
_SourceCache
(
10
);
int
membersMissingDocumentation
=
0
;
List
<
String
>
errorLines
=
output
.
toString
().
split
(
'
\n
'
);
for
(
String
errorLine
in
errorLines
)
{
...
...
@@ -380,7 +382,7 @@ class AnalyzeCommand extends FlutterCommand {
int
colNumber
=
int
.
parse
(
groups
[
5
]);
try
{
File
source
=
new
File
(
filename
);
List
<
String
>
sourceLines
=
source
.
readAsLinesSync
(
);
List
<
String
>
sourceLines
=
cache
.
getSourceFor
(
source
);
if
(
lineNumber
>
sourceLines
.
length
)
throw
new
FileChanged
();
String
sourceLine
=
sourceLines
[
lineNumber
-
1
];
...
...
@@ -801,3 +803,20 @@ class AnalysisError implements Comparable<AnalysisError> {
return
'
${severity.toLowerCase().padLeft(7)}
$sep
$message
$sep
$relativePath
:
$startLine
:
$startColumn
'
;
}
}
class
_SourceCache
{
_SourceCache
(
this
.
cacheSize
);
final
int
cacheSize
;
final
Map
<
String
,
List
<
String
>>
_lines
=
new
LinkedHashMap
<
String
,
List
<
String
>>();
List
<
String
>
getSourceFor
(
File
file
)
{
if
(!
_lines
.
containsKey
(
file
.
path
))
{
if
(
_lines
.
length
>=
cacheSize
)
_lines
.
remove
(
_lines
.
keys
.
first
);
_lines
[
file
.
path
]
=
file
.
readAsLinesSync
();
}
return
_lines
[
file
.
path
];
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment