Skip to content

Commit

Permalink
tact compiler version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
logvik committed May 11, 2024
1 parent 4d1cc5d commit 92f56a9
Show file tree
Hide file tree
Showing 13 changed files with 2,322 additions and 1,595 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Tact language (for .tact file) extension to use together with Tact compiler for Visual Studio Code to develop smart contract for TON blockchain",
"publisher": "KonVik",
"icon": "icons/logo.png",
"version": "1.0.20",
"version": "1.3.0",
"keywords": [
"tact",
"blockchain",
Expand Down Expand Up @@ -48,7 +48,7 @@
"build": "vsce package"
},
"dependencies": {
"@tact-lang/compiler": "^1.2.0",
"@tact-lang/compiler": "^1.3.0",
"ajv": "^6.10.2",
"ajv-keywords": "^3.4.1",
"ast-parents": "0.0.1",
Expand Down
8 changes: 8 additions & 0 deletions snippets/tact.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
"require expression": {
"prefix": "req",
"body": "require(${1:Bool}, ${2:String});"
},
"try expression": {
"prefix": "try",
"body": "try {\n\n}"
},
"try catch expression": {
"prefix": "try-catch",
"body": "try {\n\n} catch (e) {\n\n}"
}
}
}
98 changes: 94 additions & 4 deletions src/completionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class CompletionService {
selectedFunction.findVariableDeclarationsInScope(offset);
//adding input parameters
allVariables = allVariables.concat(selectedFunction.input);
//ading all variables
//adding all variables
allVariables = allVariables.concat(selectedFunction.variablesInScope);
}

Expand Down Expand Up @@ -333,9 +333,8 @@ export class CompletionService {
items = getStringBuilderCompletionItems();
break;
case "Address":
// no methods now
items = getAddressCompletionItems();
break;

}

if (items.length > 0) {
Expand Down Expand Up @@ -447,6 +446,13 @@ export class CompletionService {
completionItems.push(items[i]);
}
}

if (type?.name == 'Address') {
const items = getAddressCompletionItems();
for (let i in items) {
completionItems.push(items[i]);
}
}
}

private findDotType(allStructs: Struct[], allMessages: Message[], type: DeclarationType | undefined, autocompleteByDot: AutocompleteByDot, completionItems: any[], allContracts: Contract2[], currentContract: Contract2) {
Expand Down Expand Up @@ -664,7 +670,37 @@ export function GetGlobalVariables(): CompletionItem[] {
detail: 'Int 16',
kind: CompletionItemKind.Variable,
label: 'SendBounceIfActionFail',
}
},
{
detail: 'Int 0',
kind: CompletionItemKind.Variable,
label: 'ReserveExact',
},
{
detail: 'Int 1',
kind: CompletionItemKind.Variable,
label: 'ReserveAllExcept',
},
{
detail: 'Int 2',
kind: CompletionItemKind.Variable,
label: 'ReserveAtMost',
},
{
detail: 'Int 4',
kind: CompletionItemKind.Variable,
label: 'ReserveAddOriginalBalance',
},
{
detail: 'Int 8',
kind: CompletionItemKind.Variable,
label: 'ReserveInvertSign',
},
{
detail: 'Int 16',
kind: CompletionItemKind.Variable,
label: 'ReserveBounceIfActionFail',
},
];
}

Expand Down Expand Up @@ -1087,6 +1123,27 @@ function getMathCompletionItems(): CompletionItem[] {
insertTextFormat: 2,
label: 'nativeRandomInterval',
},
{
detail: 'Power function with base 2',
kind: CompletionItemKind.Property,
insertText: 'pow2(${1:Int})',
insertTextFormat: 2,
label: 'pow2',
},
{
detail: 'Logarithm function with base 2',
kind: CompletionItemKind.Property,
insertText: 'log2(${1:Int})',
insertTextFormat: 2,
label: 'log2',
},
{
detail: 'Logarithm function with base',
kind: CompletionItemKind.Property,
insertText: 'log(${1:Int},${2:Int})',
insertTextFormat: 2,
label: 'log',
},
]
}

Expand Down Expand Up @@ -1131,6 +1188,20 @@ function getMapCompletionItems(): CompletionItem[] {
insertTextFormat: 2,
label: 'set',
},
{
detail: 'As cell',
kind: CompletionItemKind.Property,
insertText: "asCell()",
insertTextFormat: 2,
label: 'asCell',
},
{
detail: 'Is empty',
kind: CompletionItemKind.Property,
insertText: "isEmpty()",
insertTextFormat: 2,
label: 'isEmpty',
},
]
}

Expand Down Expand Up @@ -1171,6 +1242,25 @@ function getStringBuilderCompletionItems(): CompletionItem[] {
insertTextFormat: 2,
label: 'toSlice',
},
{
detail: 'Concatenation of strings',
kind: CompletionItemKind.Property,
insertText: "concat()",
insertTextFormat: 2,
label: 'concat',
},
];
}

function getAddressCompletionItems(): CompletionItem[] {
return [
{
detail: 'Address to string.',
kind: CompletionItemKind.Property,
insertText: "toString()",
insertTextFormat: 2,
label: 'toString',
},
];
}

Expand Down
Loading

0 comments on commit 92f56a9

Please sign in to comment.