Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: pkg/analysis_server/test/integration/protocol_matchers.dart

Issue 482573004: Change analysis server protocol to omit empty lists when optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/integration/protocol_matchers.dart
diff --git a/pkg/analysis_server/test/integration/protocol_matchers.dart b/pkg/analysis_server/test/integration/protocol_matchers.dart
index 7443db940c50167b593639c73e067a9c97dd5935..30a5195c38eea140e6558180ab3137ee54a5c4e2 100644
--- a/pkg/analysis_server/test/integration/protocol_matchers.dart
+++ b/pkg/analysis_server/test/integration/protocol_matchers.dart
@@ -47,11 +47,11 @@ final Matcher isServerShutdownResult = isNull;
* server.setSubscriptions params
*
* {
- * "subscriptions": List<ServerService>
+ * "subscriptions": optional List<ServerService>
* }
*/
final Matcher isServerSetSubscriptionsParams = new LazyMatcher(() => new MatchesJsonObject(
- "server.setSubscriptions params", {
+ "server.setSubscriptions params", null, optionalFields: {
"subscriptions": isListOf(isServerService)
}));
@@ -109,11 +109,11 @@ final Matcher isAnalysisGetErrorsParams = new LazyMatcher(() => new MatchesJsonO
* analysis.getErrors result
*
* {
- * "errors": List<AnalysisError>
+ * "errors": optional List<AnalysisError>
* }
*/
final Matcher isAnalysisGetErrorsResult = new LazyMatcher(() => new MatchesJsonObject(
- "analysis.getErrors result", {
+ "analysis.getErrors result", null, optionalFields: {
"errors": isListOf(isAnalysisError)
}));
@@ -135,11 +135,11 @@ final Matcher isAnalysisGetHoverParams = new LazyMatcher(() => new MatchesJsonOb
* analysis.getHover result
*
* {
- * "hovers": List<HoverInformation>
+ * "hovers": optional List<HoverInformation>
* }
*/
final Matcher isAnalysisGetHoverResult = new LazyMatcher(() => new MatchesJsonObject(
- "analysis.getHover result", {
+ "analysis.getHover result", null, optionalFields: {
"hovers": isListOf(isHoverInformation)
}));
@@ -157,12 +157,12 @@ final Matcher isAnalysisReanalyzeResult = isNull;
* analysis.setAnalysisRoots params
*
* {
- * "included": List<FilePath>
- * "excluded": List<FilePath>
+ * "included": optional List<FilePath>
+ * "excluded": optional List<FilePath>
* }
*/
final Matcher isAnalysisSetAnalysisRootsParams = new LazyMatcher(() => new MatchesJsonObject(
- "analysis.setAnalysisRoots params", {
+ "analysis.setAnalysisRoots params", null, optionalFields: {
"included": isListOf(isFilePath),
"excluded": isListOf(isFilePath)
}));
@@ -176,11 +176,11 @@ final Matcher isAnalysisSetAnalysisRootsResult = isNull;
* analysis.setPriorityFiles params
*
* {
- * "files": List<FilePath>
+ * "files": optional List<FilePath>
* }
*/
final Matcher isAnalysisSetPriorityFilesParams = new LazyMatcher(() => new MatchesJsonObject(
- "analysis.setPriorityFiles params", {
+ "analysis.setPriorityFiles params", null, optionalFields: {
"files": isListOf(isFilePath)
}));
@@ -245,12 +245,13 @@ final Matcher isAnalysisUpdateOptionsResult = isNull;
*
* {
* "file": FilePath
- * "errors": List<AnalysisError>
+ * "errors": optional List<AnalysisError>
* }
*/
final Matcher isAnalysisErrorsParams = new LazyMatcher(() => new MatchesJsonObject(
"analysis.errors params", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"errors": isListOf(isAnalysisError)
}));
@@ -258,11 +259,11 @@ final Matcher isAnalysisErrorsParams = new LazyMatcher(() => new MatchesJsonObje
* analysis.flushResults params
*
* {
- * "files": List<FilePath>
+ * "files": optional List<FilePath>
* }
*/
final Matcher isAnalysisFlushResultsParams = new LazyMatcher(() => new MatchesJsonObject(
- "analysis.flushResults params", {
+ "analysis.flushResults params", null, optionalFields: {
"files": isListOf(isFilePath)
}));
@@ -271,12 +272,13 @@ final Matcher isAnalysisFlushResultsParams = new LazyMatcher(() => new MatchesJs
*
* {
* "file": FilePath
- * "regions": List<FoldingRegion>
+ * "regions": optional List<FoldingRegion>
* }
*/
final Matcher isAnalysisFoldingParams = new LazyMatcher(() => new MatchesJsonObject(
"analysis.folding params", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"regions": isListOf(isFoldingRegion)
}));
@@ -285,12 +287,13 @@ final Matcher isAnalysisFoldingParams = new LazyMatcher(() => new MatchesJsonObj
*
* {
* "file": FilePath
- * "regions": List<HighlightRegion>
+ * "regions": optional List<HighlightRegion>
* }
*/
final Matcher isAnalysisHighlightsParams = new LazyMatcher(() => new MatchesJsonObject(
"analysis.highlights params", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"regions": isListOf(isHighlightRegion)
}));
@@ -299,12 +302,13 @@ final Matcher isAnalysisHighlightsParams = new LazyMatcher(() => new MatchesJson
*
* {
* "file": FilePath
- * "regions": List<NavigationRegion>
+ * "regions": optional List<NavigationRegion>
* }
*/
final Matcher isAnalysisNavigationParams = new LazyMatcher(() => new MatchesJsonObject(
"analysis.navigation params", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"regions": isListOf(isNavigationRegion)
}));
@@ -313,12 +317,13 @@ final Matcher isAnalysisNavigationParams = new LazyMatcher(() => new MatchesJson
*
* {
* "file": FilePath
- * "occurrences": List<Occurrences>
+ * "occurrences": optional List<Occurrences>
* }
*/
final Matcher isAnalysisOccurrencesParams = new LazyMatcher(() => new MatchesJsonObject(
"analysis.occurrences params", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"occurrences": isListOf(isOccurrences)
}));
@@ -341,12 +346,13 @@ final Matcher isAnalysisOutlineParams = new LazyMatcher(() => new MatchesJsonObj
*
* {
* "file": FilePath
- * "overrides": List<Override>
+ * "overrides": optional List<Override>
* }
*/
final Matcher isAnalysisOverridesParams = new LazyMatcher(() => new MatchesJsonObject(
"analysis.overrides params", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"overrides": isListOf(isOverride)
}));
@@ -383,7 +389,7 @@ final Matcher isCompletionGetSuggestionsResult = new LazyMatcher(() => new Match
* "id": CompletionId
* "replacementOffset": int
* "replacementLength": int
- * "results": List<CompletionSuggestion>
+ * "results": optional List<CompletionSuggestion>
* "last": bool
* }
*/
@@ -392,8 +398,9 @@ final Matcher isCompletionResultsParams = new LazyMatcher(() => new MatchesJsonO
"id": isCompletionId,
"replacementOffset": isInt,
"replacementLength": isInt,
- "results": isListOf(isCompletionSuggestion),
"last": isBool
+ }, optionalFields: {
+ "results": isListOf(isCompletionSuggestion)
}));
/**
@@ -530,15 +537,16 @@ final Matcher isSearchGetTypeHierarchyResult = new LazyMatcher(() => new Matches
*
* {
* "id": SearchId
- * "results": List<SearchResult>
+ * "results": optional List<SearchResult>
* "last": bool
* }
*/
final Matcher isSearchResultsParams = new LazyMatcher(() => new MatchesJsonObject(
"search.results params", {
"id": isSearchId,
- "results": isListOf(isSearchResult),
"last": isBool
+ }, optionalFields: {
+ "results": isListOf(isSearchResult)
}));
/**
@@ -561,11 +569,11 @@ final Matcher isEditGetAssistsParams = new LazyMatcher(() => new MatchesJsonObje
* edit.getAssists result
*
* {
- * "assists": List<SourceChange>
+ * "assists": optional List<SourceChange>
* }
*/
final Matcher isEditGetAssistsResult = new LazyMatcher(() => new MatchesJsonObject(
- "edit.getAssists result", {
+ "edit.getAssists result", null, optionalFields: {
"assists": isListOf(isSourceChange)
}));
@@ -589,11 +597,11 @@ final Matcher isEditGetAvailableRefactoringsParams = new LazyMatcher(() => new M
* edit.getAvailableRefactorings result
*
* {
- * "kinds": List<RefactoringKind>
+ * "kinds": optional List<RefactoringKind>
* }
*/
final Matcher isEditGetAvailableRefactoringsResult = new LazyMatcher(() => new MatchesJsonObject(
- "edit.getAvailableRefactorings result", {
+ "edit.getAvailableRefactorings result", null, optionalFields: {
"kinds": isListOf(isRefactoringKind)
}));
@@ -615,11 +623,11 @@ final Matcher isEditGetFixesParams = new LazyMatcher(() => new MatchesJsonObject
* edit.getFixes result
*
* {
- * "fixes": List<ErrorFixes>
+ * "fixes": optional List<ErrorFixes>
* }
*/
final Matcher isEditGetFixesResult = new LazyMatcher(() => new MatchesJsonObject(
- "edit.getFixes result", {
+ "edit.getFixes result", null, optionalFields: {
"fixes": isListOf(isErrorFixes)
}));
@@ -650,16 +658,15 @@ final Matcher isEditGetRefactoringParams = new LazyMatcher(() => new MatchesJson
* edit.getRefactoring result
*
* {
- * "status": List<RefactoringProblem>
+ * "status": optional List<RefactoringProblem>
* "feedback": optional object
* "change": optional SourceChange
* "potentialEdits": optional List<String>
* }
*/
final Matcher isEditGetRefactoringResult = new LazyMatcher(() => new MatchesJsonObject(
- "edit.getRefactoring result", {
- "status": isListOf(isRefactoringProblem)
- }, optionalFields: {
+ "edit.getRefactoring result", null, optionalFields: {
+ "status": isListOf(isRefactoringProblem),
"feedback": isObject,
"change": isSourceChange,
"potentialEdits": isListOf(isString)
@@ -741,11 +748,11 @@ final Matcher isDebugMapUriResult = new LazyMatcher(() => new MatchesJsonObject(
* debug.setSubscriptions params
*
* {
- * "subscriptions": List<DebugService>
+ * "subscriptions": optional List<DebugService>
* }
*/
final Matcher isDebugSetSubscriptionsParams = new LazyMatcher(() => new MatchesJsonObject(
- "debug.setSubscriptions params", {
+ "debug.setSubscriptions params", null, optionalFields: {
"subscriptions": isListOf(isDebugService)
}));
@@ -758,16 +765,17 @@ final Matcher isDebugSetSubscriptionsResult = isNull;
* debug.launchData params
*
* {
- * "executables": List<ExecutableFile>
+ * "executables": optional List<ExecutableFile>
* "dartToHtml": Map<FilePath, List<FilePath>>
* "htmlToDart": Map<FilePath, List<FilePath>>
* }
*/
final Matcher isDebugLaunchDataParams = new LazyMatcher(() => new MatchesJsonObject(
"debug.launchData params", {
- "executables": isListOf(isExecutableFile),
"dartToHtml": isMapOf(isFilePath, isListOf(isFilePath)),
"htmlToDart": isMapOf(isFilePath, isListOf(isFilePath))
+ }, optionalFields: {
+ "executables": isListOf(isExecutableFile)
}));
/**
@@ -866,12 +874,13 @@ final Matcher isAnalysisStatus = new LazyMatcher(() => new MatchesJsonObject(
*
* {
* "type": "change"
- * "edits": List<SourceEdit>
+ * "edits": optional List<SourceEdit>
* }
*/
final Matcher isChangeContentOverlay = new LazyMatcher(() => new MatchesJsonObject(
"ChangeContentOverlay", {
- "type": equals("change"),
+ "type": equals("change")
+ }, optionalFields: {
"edits": isListOf(isSourceEdit)
}));
@@ -1099,12 +1108,13 @@ final Matcher isError = new LazyMatcher(() => new MatchesJsonObject(
*
* {
* "error": AnalysisError
- * "fixes": List<SourceChange>
+ * "fixes": optional List<SourceChange>
* }
*/
final Matcher isErrorFixes = new LazyMatcher(() => new MatchesJsonObject(
"ErrorFixes", {
- "error": isAnalysisError,
+ "error": isAnalysisError
+ }, optionalFields: {
"fixes": isListOf(isSourceChange)
}));
@@ -1345,15 +1355,16 @@ final Matcher isHoverInformation = new LazyMatcher(() => new MatchesJsonObject(
* LinkedEditGroup
*
* {
- * "positions": List<Position>
+ * "positions": optional List<Position>
* "length": int
- * "suggestions": List<LinkedEditSuggestion>
+ * "suggestions": optional List<LinkedEditSuggestion>
* }
*/
final Matcher isLinkedEditGroup = new LazyMatcher(() => new MatchesJsonObject(
"LinkedEditGroup", {
+ "length": isInt
+ }, optionalFields: {
"positions": isListOf(isPosition),
- "length": isInt,
"suggestions": isListOf(isLinkedEditSuggestion)
}));
@@ -1414,13 +1425,14 @@ final Matcher isLocation = new LazyMatcher(() => new MatchesJsonObject(
* {
* "offset": int
* "length": int
- * "targets": List<Element>
+ * "targets": optional List<Element>
* }
*/
final Matcher isNavigationRegion = new LazyMatcher(() => new MatchesJsonObject(
"NavigationRegion", {
"offset": isInt,
- "length": isInt,
+ "length": isInt
+ }, optionalFields: {
"targets": isListOf(isElement)
}));
@@ -1429,15 +1441,16 @@ final Matcher isNavigationRegion = new LazyMatcher(() => new MatchesJsonObject(
*
* {
* "element": Element
- * "offsets": List<int>
+ * "offsets": optional List<int>
* "length": int
* }
*/
final Matcher isOccurrences = new LazyMatcher(() => new MatchesJsonObject(
"Occurrences", {
"element": isElement,
- "offsets": isListOf(isInt),
"length": isInt
+ }, optionalFields: {
+ "offsets": isListOf(isInt)
}));
/**
@@ -1625,14 +1638,15 @@ final Matcher isSearchId = isString;
* "location": Location
* "kind": SearchResultKind
* "isPotential": bool
- * "path": List<Element>
+ * "path": optional List<Element>
* }
*/
final Matcher isSearchResult = new LazyMatcher(() => new MatchesJsonObject(
"SearchResult", {
"location": isLocation,
"kind": isSearchResultKind,
- "isPotential": isBool,
+ "isPotential": isBool
+ }, optionalFields: {
"path": isListOf(isElement)
}));
@@ -1675,17 +1689,17 @@ final Matcher isServerService = new MatchesEnum("ServerService", [
*
* {
* "message": String
- * "edits": List<SourceFileEdit>
- * "linkedEditGroups": List<LinkedEditGroup>
+ * "edits": optional List<SourceFileEdit>
+ * "linkedEditGroups": optional List<LinkedEditGroup>
* "selection": optional Position
* }
*/
final Matcher isSourceChange = new LazyMatcher(() => new MatchesJsonObject(
"SourceChange", {
- "message": isString,
- "edits": isListOf(isSourceFileEdit),
- "linkedEditGroups": isListOf(isLinkedEditGroup)
+ "message": isString
}, optionalFields: {
+ "edits": isListOf(isSourceFileEdit),
+ "linkedEditGroups": isListOf(isLinkedEditGroup),
"selection": isPosition
}));
@@ -1713,12 +1727,13 @@ final Matcher isSourceEdit = new LazyMatcher(() => new MatchesJsonObject(
*
* {
* "file": FilePath
- * "edits": List<SourceEdit>
+ * "edits": optional List<SourceEdit>
* }
*/
final Matcher isSourceFileEdit = new LazyMatcher(() => new MatchesJsonObject(
"SourceFileEdit", {
- "file": isFilePath,
+ "file": isFilePath
+ }, optionalFields: {
"edits": isListOf(isSourceEdit)
}));
@@ -1730,21 +1745,21 @@ final Matcher isSourceFileEdit = new LazyMatcher(() => new MatchesJsonObject(
* "displayName": optional String
* "memberElement": optional Element
* "superclass": optional int
- * "interfaces": List<int>
- * "mixins": List<int>
- * "subclasses": List<int>
+ * "interfaces": optional List<int>
+ * "mixins": optional List<int>
+ * "subclasses": optional List<int>
* }
*/
final Matcher isTypeHierarchyItem = new LazyMatcher(() => new MatchesJsonObject(
"TypeHierarchyItem", {
- "classElement": isElement,
- "interfaces": isListOf(isInt),
- "mixins": isListOf(isInt),
- "subclasses": isListOf(isInt)
+ "classElement": isElement
}, optionalFields: {
"displayName": isString,
"memberElement": isElement,
- "superclass": isInt
+ "superclass": isInt,
+ "interfaces": isListOf(isInt),
+ "mixins": isListOf(isInt),
+ "subclasses": isListOf(isInt)
}));
/**
@@ -1771,13 +1786,13 @@ final Matcher isConvertMethodToGetterOptions = isNull;
* extractLocalVariable feedback
*
* {
- * "names": List<String>
- * "offsets": List<int>
- * "lengths": List<int>
+ * "names": optional List<String>
+ * "offsets": optional List<int>
+ * "lengths": optional List<int>
* }
*/
final Matcher isExtractLocalVariableFeedback = new LazyMatcher(() => new MatchesJsonObject(
- "extractLocalVariable feedback", {
+ "extractLocalVariable feedback", null, optionalFields: {
"names": isListOf(isString),
"offsets": isListOf(isInt),
"lengths": isListOf(isInt)
@@ -1804,12 +1819,12 @@ final Matcher isExtractLocalVariableOptions = new LazyMatcher(() => new MatchesJ
* "offset": int
* "length": int
* "returnType": String
- * "names": List<String>
+ * "names": optional List<String>
* "canCreateGetter": bool
- * "parameters": List<RefactoringMethodParameter>
+ * "parameters": optional List<RefactoringMethodParameter>
* "occurrences": int
- * "offsets": List<int>
- * "lengths": List<int>
+ * "offsets": optional List<int>
+ * "lengths": optional List<int>
* }
*/
final Matcher isExtractMethodFeedback = new LazyMatcher(() => new MatchesJsonObject(
@@ -1817,10 +1832,11 @@ final Matcher isExtractMethodFeedback = new LazyMatcher(() => new MatchesJsonObj
"offset": isInt,
"length": isInt,
"returnType": isString,
- "names": isListOf(isString),
"canCreateGetter": isBool,
+ "occurrences": isInt
+ }, optionalFields: {
+ "names": isListOf(isString),
"parameters": isListOf(isRefactoringMethodParameter),
- "occurrences": isInt,
"offsets": isListOf(isInt),
"lengths": isListOf(isInt)
}));
@@ -1832,7 +1848,7 @@ final Matcher isExtractMethodFeedback = new LazyMatcher(() => new MatchesJsonObj
* "returnType": String
* "createGetter": bool
* "name": String
- * "parameters": List<RefactoringMethodParameter>
+ * "parameters": optional List<RefactoringMethodParameter>
* "extractAll": bool
* }
*/
@@ -1841,8 +1857,9 @@ final Matcher isExtractMethodOptions = new LazyMatcher(() => new MatchesJsonObje
"returnType": isString,
"createGetter": isBool,
"name": isString,
- "parameters": isListOf(isRefactoringMethodParameter),
"extractAll": isBool
+ }, optionalFields: {
+ "parameters": isListOf(isRefactoringMethodParameter)
}));
/**

Powered by Google App Engine
This is Rietveld 408576698