Skip to content

Commit dca45b1

Browse files
committed
v0.0.18
1 parent 14755f7 commit dca45b1

File tree

7 files changed

+142
-48
lines changed

7 files changed

+142
-48
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
---
44

5+
## [v0.0.18](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.18) (2023-7-20)
6+
7+
- Bug fixes
8+
- `Own ObjectScript Documentation: Open InterSystems Class Documentation` improved
9+
10+
---
11+
512
## [v0.0.17](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.17) (2023-7-17)
613

714
- Bug fixes

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ git clone https://github.com/phil1436/ownobjectscriptextension C:\Users\<your-us
121121

122122
or download the [latest realease](https://github.com/phil1436/ownobjectscriptextension/releases/latest) and extract the file into `~/.vscode/extensions`.
123123

124+
- Go to the extension folder and run `npm install` in the terminal.
124125
- If the extension did not got installed, run the command `Developer: Install Extension from Location...` and choose the extension folder.
125126

126127
---
@@ -207,13 +208,10 @@ The extension will add a new color theme called _InterSystems Real Dark_. You ca
207208

208209
## [Release Notes](https://github.com/phil1436/ownobjectscriptextension/blob/master/CHANGELOG.md)
209210

210-
### [v0.0.17](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.17)
211+
### [v0.0.18](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.18)
211212

212213
- Bug fixes
213-
- Category `Own ObjectScript Comment` renamed to `Own ObjectScript Documentation`
214-
- Method description template changed
215-
- Command `Own ObjectScript Documentation: Open InterSystems Class Documentation` added
216-
- Command `Own ObjectScript Documentation: InterSystems Web Search` added
214+
- `Own ObjectScript Documentation: Open InterSystems Class Documentation` improved
217215

218216
---
219217

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Philipp B.",
66
"publisher": "PhilippB",
77
"license": "MIT",
8-
"version": "0.0.17",
8+
"version": "0.0.18",
99
"repository": {
1010
"type": "github",
1111
"url": "https://github.com/phil1436/ownobjectscriptextension"
@@ -103,7 +103,13 @@
103103
"editor/context": [
104104
{
105105
"command": "ownobjectscriptextension.openDocumentation",
106-
"group": "Own ObjectScript Extension"
106+
"group": "ObjectScript",
107+
"when": "editorLangId == objectscript-class"
108+
},
109+
{
110+
"command": "ownobjectscriptextension.addMethodDescriptionTemplate",
111+
"group": "ObjectScript",
112+
"when": "editorLangId == objectscript-class"
107113
}
108114
]
109115
},

src/commands/Documentation.js

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function addMethodDescriptionTemplate() {
2121
let line = vscode.window.activeTextEditor.document.lineAt(i);
2222
let trimedLine = line.text.toLowerCase().replace(/\s/g, '');
2323
if (
24-
trimedLine.startsWith('method') ||
25-
trimedLine.startsWith('classmethod')
24+
line.text.toLowerCase().startsWith('method') ||
25+
line.text.toLowerCase().startsWith('classmethod')
2626
) {
2727
let offset = 1;
2828
let lineString = line.text;
@@ -78,7 +78,6 @@ function addMethodDescriptionTemplate() {
7878

7979
// add paremeter description
8080
template += globalFunctions.makeParamterTemplate(startLine);
81-
8281
//if has return value
8382
if (startLine.split(')')[1].toLowerCase().includes('as')) {
8483
// Add return description
@@ -112,7 +111,6 @@ function addMethodDescriptionTemplate() {
112111

113112
//get classname
114113
let className = globalFunctions.getClassName();
115-
116114
//get method name
117115
let methodName = startLine.split(' ')[1];
118116
if (methodName.includes('(')) methodName = methodName.split('(')[0];
@@ -224,16 +222,106 @@ function addInlineComments() {
224222
function openDocumentation() {
225223
if (!globalFunctions.preConditions()) return;
226224

227-
let selection = vscode.window.activeTextEditor.selection;
225+
const selection = vscode.window.activeTextEditor.selection;
228226

229227
let searchString =
230228
vscode.window.activeTextEditor.document.getText(selection);
231229
if (selection.isEmpty) {
232-
searchString = vscode.window.activeTextEditor.document.getText(
230+
let wordRange =
231+
vscode.window.activeTextEditor.document.getWordRangeAtPosition(
232+
selection.start
233+
);
234+
235+
searchString =
236+
vscode.window.activeTextEditor.document.getText(wordRange);
237+
238+
// get character before
239+
if (wordRange.start.character != 0) {
240+
let characterBefore =
241+
vscode.window.activeTextEditor.document.getText(
242+
new vscode.Range(
243+
new vscode.Position(
244+
wordRange.start.line,
245+
wordRange.start.character - 1
246+
),
247+
wordRange.start
248+
)
249+
);
250+
while (characterBefore == '.') {
251+
wordRange =
252+
vscode.window.activeTextEditor.document.getWordRangeAtPosition(
253+
new vscode.Position(
254+
wordRange.start.line,
255+
wordRange.start.character - 1
256+
)
257+
);
258+
searchString =
259+
vscode.window.activeTextEditor.document.getText(wordRange) +
260+
'.' +
261+
searchString;
262+
if (wordRange.start.character == 0) break;
263+
characterBefore =
264+
vscode.window.activeTextEditor.document.getText(
265+
new vscode.Range(
266+
new vscode.Position(
267+
wordRange.start.line,
268+
wordRange.start.character - 1
269+
),
270+
wordRange.start
271+
)
272+
);
273+
}
274+
}
275+
wordRange =
233276
vscode.window.activeTextEditor.document.getWordRangeAtPosition(
234277
selection.start
235-
)
236-
);
278+
);
279+
if (
280+
wordRange.end.character !=
281+
vscode.window.activeTextEditor.document.lineAt(wordRange.end.line)
282+
.range.end.character
283+
) {
284+
let characterAfter =
285+
vscode.window.activeTextEditor.document.getText(
286+
new vscode.Range(
287+
wordRange.end,
288+
new vscode.Position(
289+
wordRange.end.line,
290+
wordRange.end.character + 1
291+
)
292+
)
293+
);
294+
while (characterAfter == '.') {
295+
wordRange =
296+
vscode.window.activeTextEditor.document.getWordRangeAtPosition(
297+
new vscode.Position(
298+
wordRange.end.line,
299+
wordRange.end.character + 1
300+
)
301+
);
302+
searchString =
303+
searchString +
304+
'.' +
305+
vscode.window.activeTextEditor.document.getText(wordRange);
306+
if (
307+
wordRange.end.character ==
308+
vscode.window.activeTextEditor.document.lineAt(
309+
wordRange.end.line
310+
).range.end.character
311+
)
312+
break;
313+
characterAfter =
314+
vscode.window.activeTextEditor.document.getText(
315+
new vscode.Range(
316+
wordRange.end,
317+
new vscode.Position(
318+
wordRange.end.line,
319+
wordRange.end.character + 1
320+
)
321+
)
322+
);
323+
}
324+
}
237325
}
238326

239327
if (
@@ -359,7 +447,7 @@ async function getHTMLFromURL(url) {
359447
const response = await axios.get(url);
360448
return response.data;
361449
} catch (error) {
362-
console.error('Error fetching HTML:', error.message);
450+
vscode.window.showErrorMessage('Error fetching HTML:' + error.message);
363451
return null;
364452
}
365453
}

src/commands/Translate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ function translateEmbPython() {
132132
vscode.workspace
133133
.getConfiguration('ownobjectscriptextension')
134134
.get('SaveFile')
135-
)
135+
) {
136136
vscode.window.activeTextEditor.document.save();
137+
}
137138
}
138139

139140
module.exports = {

src/extension.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ const SQL = require('./commands/SQL');
66
const Translate = require('./commands/Translate');
77
const Create = require('./commands/Create');
88

9-
const WorkspaceManager = require('./WorkspaceManager.js');
10-
const workspaceManager = new WorkspaceManager();
11-
workspaceManager.init();
12-
139
/**
1410
* @param {vscode.ExtensionContext} context
1511
*/
@@ -86,32 +82,30 @@ function activate(context) {
8682
Create.createNewClass
8783
);
8884

89-
/* const completionProvider = vscode.languages.registerCompletionItemProvider(
90-
'javascript',
91-
{
92-
provideCompletionItems(document, position) {
93-
// Check if the current word is 'hello'
94-
const wordRange = document.getWordRangeAtPosition(position);
95-
const currentWord = wordRange
96-
? document.getText(wordRange)
97-
: '';
98-
console.log(currentWord);
99-
if (currentWord !== 'hello') {
100-
return undefined;
101-
}
102-
103-
// Return a completion item for 'hello'
104-
const completionItem = new vscode.CompletionItem(
105-
'hello',
106-
vscode.CompletionItemKind.Keyword
107-
);
108-
completionItem.insertText = 'Hello, world!';
109-
return [completionItem];
85+
/* context.subscriptions.push(
86+
vscode.languages.registerCompletionItemProvider(
87+
'objectscript-class',
88+
{
89+
provideCompletionItems(document, position, token) {
90+
console.log('got here');
91+
const linePrefix = document
92+
.lineAt(position)
93+
.text.substr(0, position.character);
94+
if (!linePrefix.endsWith('///')) {
95+
return undefined;
96+
}
97+
98+
return [
99+
new vscode.CompletionItem(
100+
'Hello World',
101+
vscode.CompletionItemKind.Text
102+
),
103+
];
104+
},
110105
},
111-
},
112-
'h' // Specify the trigger character for the completion provider
113-
);
114-
context.subscriptions.push(completionProvider); */
106+
'/'
107+
)
108+
); */
115109
}
116110

117111
// This method is called when your extension is deactivated

0 commit comments

Comments
 (0)