From 939cce78b9d1895e31e6cc86a60736c8a11c243e Mon Sep 17 00:00:00 2001 From: Ari Aye Date: Wed, 24 Jul 2019 23:15:39 +0000 Subject: [PATCH] Create analysis server flag --completion-model This flag will take a path to a folder where completion language model files can be located. Omitting this flag will signal to analysis server that it should not use ML ranking for code completion, and the plan is for this capability to initially be opt-in / disabled by default. Change-Id: Ied18cd1e378c11607778fc116a7e0c3d72091e44 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110401 Reviewed-by: Brian Wilkerson Commit-Queue: Ari Aye --- pkg/analysis_server/lib/src/analysis_server.dart | 3 +++ pkg/analysis_server/lib/src/server/driver.dart | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart index 472ebad39d08..6f3daf6ca7b8 100644 --- a/pkg/analysis_server/lib/src/analysis_server.dart +++ b/pkg/analysis_server/lib/src/analysis_server.dart @@ -744,6 +744,9 @@ class AnalysisServerOptions { /// Whether to use the Language Server Protocol. bool useLanguageServerProtocol = false; + /// Base path to locate trained completion language model files. + String completionModelFolder; + /// Whether to enable parsing via the Fasta parser. bool useFastaParser = true; diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart index 606d1813bd74..1b63da2d8b6f 100644 --- a/pkg/analysis_server/lib/src/server/driver.dart +++ b/pkg/analysis_server/lib/src/server/driver.dart @@ -284,6 +284,12 @@ class Driver implements ServerStarter { */ static const String USE_LSP = "lsp"; + /** + * The path on disk to a directory containing language model files for smart + * code completion. + */ + static const String COMPLETION_MODEL_FOLDER = "completion-model"; + /** * The name of the flag to use summary2. */ @@ -339,6 +345,8 @@ class Driver implements ServerStarter { analysisServerOptions.cacheFolder = results[CACHE_FOLDER]; analysisServerOptions.useFastaParser = results[USE_FASTA_PARSER]; analysisServerOptions.useLanguageServerProtocol = results[USE_LSP]; + analysisServerOptions.completionModelFolder = + results[COMPLETION_MODEL_FOLDER]; AnalysisDriver.useSummary2 = results[USE_SUMMARY2]; bool disableAnalyticsForSession = results[SUPPRESS_ANALYTICS_FLAG]; @@ -722,6 +730,8 @@ class Driver implements ServerStarter { help: "Whether to enable parsing via the Fasta parser"); parser.addFlag(USE_LSP, defaultsTo: false, help: "Whether to use the Language Server Protocol"); + parser.addOption(COMPLETION_MODEL_FOLDER, + help: "[path] path to the location of a code completion model"); parser.addFlag(USE_SUMMARY2, defaultsTo: false, help: "Whether to use summary2"); parser.addOption(TRAIN_USING,