Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"env": {
"browser": false,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn"
}
}
"env": {
"browser": false,
"commonjs": true,
"es6": true,
"node": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 2020,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn"
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
node_modules
out
*.vsix
44 changes: 24 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ],
"stopOnEntry": false
}
]
}
"version": "0.2.0",
"configurations": [
{
"name": "Run Codealike Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
},
{
"name": "Codealike Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/test/suite/index"
]
}
]
}
8 changes: 6 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.vscode-test/**
test/**
.gitignore
jsconfig.json
.yarnrc
vsc-extension-quickstart.md
.eslintrc.json
**/jsconfig.json
**/*.map
**/.eslintrc.json
node_modules
../**
125 changes: 84 additions & 41 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,43 @@ function activate(context) {
statusBarItem.show();

// if there is a folder loaded, initialize codealike
if (vscode.workspace.rootPath) {
statusBarItem.text = "Codealike is initializing...";
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) {
const rootPath = vscode.workspace.workspaceFolders[0].uri.fsPath;

if (rootPath) {
statusBarItem.text = "Codealike is initializing...";

// initialize plugin for current client and version
Codealike.initialize('vscode', '0.0.24');
// initialize plugin for current client and version
Codealike.initialize('vscode', '0.0.27');

Codealike.registerStateSubscriber((state) => {
if (state.isTracking) {
if (state.networkStatus === 'OnLine') {
statusBarItem.text = "Codealike is tracking on-line";
Codealike.registerStateSubscriber((state) => {
if (state.isTracking) {
if (state.networkStatus === 'OnLine') {
statusBarItem.text = "Codealike is tracking on-line";
}
else {
statusBarItem.text = "Codealike is tracking off-line";
}
}
else {
statusBarItem.text = "Codealike is tracking off-line";
statusBarItem.text = "Click here to configure Codealike";
}
}
else {
statusBarItem.text = "Click here to configure Codealike";
}
});
});


// try to connect
Codealike.connect()
.then(
() => {
startTrackingProject();
},
() => {
stopTrackingProject();
}
);
// try to connect
Codealike.connect()
.then(
() => {
startTrackingProject();
},
() => {
stopTrackingProject();
}
);
}else{

}

}

Expand Down Expand Up @@ -115,7 +122,7 @@ function startTrackingProject() {

// start tracking project
Codealike
.configure(vscode.workspace.workspaceFolders[0].uri.fsPath)
.configure(vscode.workspace.workspaceFolders[0].uri.fsPath) // get currently active work spaces...
.then(
(configuration) => {
// calculate when workspace started loading
Expand All @@ -129,28 +136,58 @@ function startTrackingProject() {
}
);

vscode.debug.onDidStartDebugSession((event) => {
vscode.debug.onDidStartDebugSession(() => {
Codealike.trackDebuggingState();
});

vscode.debug.onDidTerminateDebugSession((event) => {
vscode.debug.onDidTerminateDebugSession(() => {
Codealike.trackCodingState();
});

vscode.workspace.onDidChangeTextDocument((event) => {
//let lineAt = null;
//if (event.contentChanges.length) {
// lineAt = event.document.positionAt().line;
//}
//Given an input line and results , find the corresponding class and symbol
function _findClassAndMember(results ,line) {
const clsSymbol = {
className: null,
member: null
}

if (!results || !line) {
return clsSymbol;
}

results.forEach(element => {
if (!element) return;
if (!element?.location || !element?.location.range) return;
if (!element?.location.range._start?.line) {
return;
}
const rangeLine = element.location.range._start.line;
if (rangeLine > line) {
return;
}
if (element.kind == vscode.SymbolKind.Class) {
clsSymbol.className = element.name;
}
if (element.kind == vscode.SymbolKind.Method) {
clsSymbol.member = element.name;
}
});
return clsSymbol;
}

vscode.workspace.onDidChangeTextDocument((event) => {

vscode
.commands
.executeCommand('vscode.executeDocumentSymbolProvider', event.document.uri)
.then(function(result) {

if (!event.contentChanges || event.contentChanges.length == 0)
return;

var line = event.contentChanges[0].range._start._line;
var line = event.contentChanges[0]?.range?.start?.line;

/* OLD CODE COMMENTED AND MOVED TO COMMON FUNCTION
var className = null;
var member = null;

Expand All @@ -167,13 +204,15 @@ function startTrackingProject() {
member = element.name;
}
}, this);
}
}*/

const clsSymbol = _findClassAndMember(result, line);

let context = {
file: event.document.fileName,
line: line,
className: className,
member: member
className: clsSymbol.className, //className,
member: clsSymbol.member //member
}

Codealike.trackCodingEvent(context);
Expand All @@ -194,11 +233,13 @@ function startTrackingProject() {
if (!event.selections || event.selections.length == 0)
return;

var line = event.selections[0]._active._line;
var line = event.selections[0]?.active?.line;

/* OLD CODE COMMENTED AND MOVED TO COMMON FUNCTION
var className = null;
var member = null;

if (result) {
if (result) {
result.forEach(function(element) {
if (!element || element.location.range._start.line > line)
return;
Expand All @@ -211,13 +252,15 @@ function startTrackingProject() {
member = element.name;
}
}, this);
}
} */

const clsSymbol = _findClassAndMember(result, line);

let context = {
file: event.textEditor.document.fileName,
line: line,
className: className,
member: member
className: clsSymbol.className, //className,
member: clsSymbol.member //member
}

Codealike.trackFocusEvent(context);
Expand Down
23 changes: 12 additions & 11 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6"
]
},
"exclude": [
"node_modules"
]
}
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"checkJs": true, /* Typecheck .js files. */
"lib": [
"ES2020"
]
},
"exclude": [
"node_modules"
]
}
21 changes: 21 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Codealike

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading