@@ -42,7 +42,7 @@ index d82646afb1..3d507b5fe3 100644
42
42
import org.openide.util.Lookup;
43
43
44
44
/**
45
- @@ -55,130 +58,164 @@ import org.openide.util.Lookup;
45
+ @@ -55,130 +58,171 @@ import org.openide.util.Lookup;
46
46
*/
47
47
public class LspServerTelemetryManager {
48
48
@@ -63,7 +63,7 @@ index d82646afb1..3d507b5fe3 100644
63
63
- public synchronized void connect(LanguageClient client, Future<Void> future) {
64
64
- clients.put(client, future);
65
65
- lspServerIntiailizationTime = System.currentTimeMillis();
66
- + private static enum ProjectType {
66
+ + public static enum ProjectType {
67
67
+ standalone,
68
68
+ maven,
69
69
+ gradle;
@@ -188,12 +188,12 @@ index d82646afb1..3d507b5fe3 100644
188
188
-
189
189
- // In future if different JDK is used for different project then this can be updated
190
190
- obj.addProperty("javaVersion", System.getProperty("java.version"));
191
- -
192
- - if (mp.containsKey(prjPath)) {
193
- - Project prj = mp.get(prjPath);
194
191
+ String javaVersion = getProjectJavaVersion();
195
192
+ obj.addProperty("javaVersion", javaVersion);
196
-
193
+
194
+ - if (mp.containsKey(prjPath)) {
195
+ - Project prj = mp.get(prjPath);
196
+ -
197
197
- ProjectManager.Result r = ProjectManager.getDefault().isProject2(prj.getProjectDirectory());
198
198
- String projectType = r.getProjectType();
199
199
- obj.addProperty("buildTool", (projectType.contains("maven") ? "MavenProject" : "GradleProject"));
@@ -220,7 +220,7 @@ index d82646afb1..3d507b5fe3 100644
220
220
+ obj.addProperty("isOpenedWithProblems", ProjectProblems.isBroken(prj));
221
221
}
222
222
+ obj.addProperty("buildTool", projectType.name());
223
- + boolean isPreviewFlagEnabled = isPreviewEnabled(projectDirectory, projectType);
223
+ + boolean isPreviewFlagEnabled = isPreviewEnabled(projectDirectory, projectType, client );
224
224
+ obj.addProperty("isPreviewEnabled", isPreviewFlagEnabled);
225
225
226
226
prjProps.add(obj);
@@ -236,26 +236,35 @@ index d82646afb1..3d507b5fe3 100644
236
236
237
237
- properties.add("prjsInfo", prjProps);
238
238
+ properties.add("projectInfo", prjProps);
239
-
240
- - properties.addProperty("timeToOpenPrjs", timeToOpenPrjs);
241
- - properties.addProperty("numOfPrjsOpened", workspaceClientFolders.size());
242
- - properties.addProperty("lspServerInitializationTime", System.currentTimeMillis() - this.lspServerIntiailizationTime);
239
+ +
243
240
+ properties.addProperty("projInitTimeTaken", timeToOpenProjects);
244
241
+ properties.addProperty("numProjects", workspaceClientFolders.size());
245
242
+ properties.addProperty("lspInitTimeTaken", System.currentTimeMillis() - this.lspServerIntializationTime);
246
243
247
- - this.sendTelemetry(client, new TelemetryEvent(MessageType.Info.toString(), this.WORKSPACE_INFO_EVT, properties));
244
+ - properties.addProperty("timeToOpenPrjs", timeToOpenPrjs);
245
+ - properties.addProperty("numOfPrjsOpened", workspaceClientFolders.size());
246
+ - properties.addProperty("lspServerInitializationTime", System.currentTimeMillis() - this.lspServerIntiailizationTime);
248
247
+ this.sendTelemetry(client, new TelemetryEvent(MessageType.Info.toString(), LspServerTelemetryManager.WORKSPACE_INFO_EVT, properties));
248
+ + }
249
+
250
+ - this.sendTelemetry(client, new TelemetryEvent(MessageType.Info.toString(), this.WORKSPACE_INFO_EVT, properties));
251
+ + public boolean isPreviewEnabled(FileObject source, ProjectType prjType) {
252
+ + return isPreviewEnabled(source, prjType, null);
249
253
}
250
254
-
251
255
- private boolean isEnablePreivew(FileObject source, String prjType) {
252
256
- if (prjType.equals(this.STANDALONE_PRJ)) {
257
+ - NbCodeLanguageClient client = Lookup.getDefault().lookup(NbCodeLanguageClient.class);
253
258
+
254
- + private boolean isPreviewEnabled(FileObject source, ProjectType prjType) {
259
+ + public boolean isPreviewEnabled(FileObject source, ProjectType prjType, LanguageClient languageClient ) {
255
260
+ if (prjType == ProjectType.standalone) {
256
- NbCodeLanguageClient client = Lookup.getDefault().lookup( NbCodeLanguageClient.class) ;
261
+ + NbCodeLanguageClient client = languageClient instanceof NbCodeLanguageClient ? ( NbCodeLanguageClient) languageClient : null ;
257
262
if (client == null) {
258
- return false;
263
+ - return false;
264
+ + client = Lookup.getDefault().lookup(NbCodeLanguageClient.class);
265
+ + if (client == null) {
266
+ + return false;
267
+ + }
259
268
}
260
269
- AtomicBoolean isEnablePreviewSet = new AtomicBoolean(false);
261
270
+ boolean[] isEnablePreviewSet = {false};
@@ -283,7 +292,7 @@ index d82646afb1..3d507b5fe3 100644
283
292
}
284
293
285
294
private String getPrjId(String prjPath) throws NoSuchAlgorithmException {
286
- @@ -187,15 +224 ,50 @@ public class LspServerTelemetryManager {
295
+ @@ -187,15 +231 ,50 @@ public class LspServerTelemetryManager {
287
296
288
297
BigInteger number = new BigInteger(1, hash);
289
298
@@ -331,7 +340,7 @@ index d82646afb1..3d507b5fe3 100644
331
340
+ return propertyLookup.apply("java.vm.name");
332
341
+ }
333
342
+
334
- + private ProjectType getProjectType(Project prj) {
343
+ + public ProjectType getProjectType(Project prj) {
335
344
+ ProjectManager.Result r = ProjectManager.getDefault().isProject2(prj.getProjectDirectory());
336
345
+ String projectType = r == null ? null : r.getProjectType();
337
346
+ return projectType != null && projectType.contains(ProjectType.maven.name()) ? ProjectType.maven : ProjectType.gradle;
@@ -358,7 +367,7 @@ index 9134992f5f..f070fec320 100644
358
367
}
359
368
360
369
+ public boolean wantsTelemetryEnabled() {
361
- + return wantsTelemetryEnabled;
370
+ + return wantsTelemetryEnabled == Boolean.TRUE ;
362
371
+ }
363
372
+
364
373
private NbCodeClientCapabilities withCapabilities(ClientCapabilities caps) {
0 commit comments