mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 14:53:37 +00:00
Send errors notification without delay.
Update 'analysis.updateContent' integration test. This might be OK from performance POV - errors are cheaper to send than for example navigation. And this satisfies the goal of 'analyzing' notification - that new errors are to be expected. R=brianwilkerson@google.com, paulberry@google.com BUG= Review-Url: https://codereview.chromium.org/2567113003 .
This commit is contained in:
parent
fa25fdd72d
commit
d564b0aaab
|
@ -1832,9 +1832,7 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
result.unit != null) {
|
||||
analysisServer.priorityFileResults[result.path] = result;
|
||||
}
|
||||
_runDelayed(() {
|
||||
new_sendErrorNotification(analysisServer, result);
|
||||
});
|
||||
new_sendErrorNotification(analysisServer, result);
|
||||
String path = result.path;
|
||||
CompilationUnit unit = result.unit;
|
||||
if (unit != null) {
|
||||
|
|
|
@ -16,54 +16,48 @@ main() {
|
|||
}
|
||||
|
||||
class AbstractUpdateContentTest extends AbstractAnalysisServerIntegrationTest {
|
||||
test_updateContent() {
|
||||
String pathname = sourcePath('test.dart');
|
||||
test_updateContent() async {
|
||||
String path = sourcePath('test.dart');
|
||||
String goodText = r'''
|
||||
main() {
|
||||
print("Hello, world!");
|
||||
}''';
|
||||
|
||||
String badText = goodText.replaceAll(';', '');
|
||||
writeFile(pathname, badText);
|
||||
writeFile(path, badText);
|
||||
standardAnalysisSetup();
|
||||
return analysisFinished
|
||||
.then((_) {
|
||||
// The contents on disk (badText) are missing a semicolon.
|
||||
expect(currentAnalysisErrors[pathname], isNotEmpty);
|
||||
})
|
||||
.then((_) => sendAnalysisUpdateContent(
|
||||
{pathname: new AddContentOverlay(goodText)}))
|
||||
.then((result) => analysisFinished)
|
||||
.then((_) {
|
||||
// There should be no errors now because the contents on disk have been
|
||||
// overridden with goodText.
|
||||
expect(currentAnalysisErrors[pathname], isEmpty);
|
||||
return sendAnalysisUpdateContent({
|
||||
pathname: new ChangeContentOverlay(
|
||||
[new SourceEdit(goodText.indexOf(';'), 1, '')])
|
||||
});
|
||||
})
|
||||
.then((result) => analysisFinished)
|
||||
.then((_) {
|
||||
// There should be errors now because we've removed the semicolon.
|
||||
expect(currentAnalysisErrors[pathname], isNotEmpty);
|
||||
return sendAnalysisUpdateContent({
|
||||
pathname: new ChangeContentOverlay(
|
||||
[new SourceEdit(goodText.indexOf(';'), 0, ';')])
|
||||
});
|
||||
})
|
||||
.then((result) => analysisFinished)
|
||||
.then((_) {
|
||||
// There should be no errors now because we've added the semicolon back.
|
||||
expect(currentAnalysisErrors[pathname], isEmpty);
|
||||
return sendAnalysisUpdateContent(
|
||||
{pathname: new RemoveContentOverlay()});
|
||||
})
|
||||
.then((result) => analysisFinished)
|
||||
.then((_) {
|
||||
// Now there should be errors again, because the contents on disk are no
|
||||
// longer overridden.
|
||||
expect(currentAnalysisErrors[pathname], isNotEmpty);
|
||||
});
|
||||
|
||||
// The contents on disk (badText) are missing a semicolon.
|
||||
await analysisFinished;
|
||||
expect(currentAnalysisErrors[path], isNotEmpty);
|
||||
|
||||
// There should be no errors now because the contents on disk have been
|
||||
// overridden with goodText.
|
||||
sendAnalysisUpdateContent({path: new AddContentOverlay(goodText)});
|
||||
await analysisFinished;
|
||||
expect(currentAnalysisErrors[path], isEmpty);
|
||||
|
||||
// There should be errors now because we've removed the semicolon.
|
||||
sendAnalysisUpdateContent({
|
||||
path: new ChangeContentOverlay(
|
||||
[new SourceEdit(goodText.indexOf(';'), 1, '')])
|
||||
});
|
||||
await analysisFinished;
|
||||
expect(currentAnalysisErrors[path], isNotEmpty);
|
||||
|
||||
// There should be no errors now because we've added the semicolon back.
|
||||
sendAnalysisUpdateContent({
|
||||
path: new ChangeContentOverlay(
|
||||
[new SourceEdit(goodText.indexOf(';'), 0, ';')])
|
||||
});
|
||||
await analysisFinished;
|
||||
expect(currentAnalysisErrors[path], isEmpty);
|
||||
|
||||
// Now there should be errors again, because the contents on disk are no
|
||||
// longer overridden.
|
||||
sendAnalysisUpdateContent({path: new RemoveContentOverlay()});
|
||||
await analysisFinished;
|
||||
expect(currentAnalysisErrors[path], isNotEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,11 +68,4 @@ class UpdateContentTest extends AbstractUpdateContentTest {}
|
|||
class UpdateContentTest_Driver extends AbstractUpdateContentTest {
|
||||
@override
|
||||
bool get enableNewAnalysisDriver => true;
|
||||
|
||||
@failingTest
|
||||
test_updateContent() {
|
||||
// Expected: non-empty
|
||||
// Actual: []
|
||||
return super.test_updateContent();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue