forked from eclipse-lemminx/lemminx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Report telemetry events for text document services.
- Resolves eclipse-lemminx#1066 - Report file extensions for didOpen & didClose Signed-off-by: Roland Grunberg <[email protected]>
- Loading branch information
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...rg/eclipse/lemminx/extensions/contentmodel/participants/DocumentTelemetryParticipant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.extensions.contentmodel.participants; | ||
|
||
import org.eclipse.lemminx.dom.DOMDocument; | ||
import org.eclipse.lemminx.services.extensions.IDocumentLifecycleParticipant; | ||
import org.eclipse.lemminx.telemetry.TelemetryManager; | ||
|
||
public class DocumentTelemetryParticipant implements IDocumentLifecycleParticipant { | ||
|
||
private TelemetryManager telemetryManager; | ||
|
||
public DocumentTelemetryParticipant(TelemetryManager telemetryManager) { | ||
this.telemetryManager = telemetryManager; | ||
} | ||
|
||
@Override | ||
public void didOpen(DOMDocument document) { | ||
telemetryManager.onDidOpen(document); | ||
} | ||
|
||
@Override | ||
public void didChange(DOMDocument document) {} | ||
|
||
@Override | ||
public void didSave(DOMDocument document) {} | ||
|
||
@Override | ||
public void didClose(DOMDocument document) { | ||
telemetryManager.onDidClose(document); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/telemetry/DocumentTelemetryInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.telemetry; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.lemminx.dom.DOMDocument; | ||
|
||
public class DocumentTelemetryInfo { | ||
|
||
private static final String DOC_PROP_EXT = "extension"; | ||
|
||
public static Map<String, Object> getDocumentTelemetryInfo (DOMDocument doc) { | ||
String uri = doc.getDocumentURI(); | ||
int index = uri.lastIndexOf('.'); | ||
String fileExtension = uri.substring(index + 1, uri.length()); | ||
HashMap<String, Object> props = new HashMap<>(); | ||
props.put(DOC_PROP_EXT, fileExtension); | ||
return props; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters