|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
import { IRange } from "monaco-editor"; |
|
|
|
|
import monaco from "../../../types/monaco"; |
|
|
|
|
import path from "path"; |
|
|
|
|
import { monaco } from '@remix-ui/editor'; |
|
|
|
|
|
|
|
|
|
type CodeParserImportsData = { |
|
|
|
|
files?: string[], |
|
|
|
@ -8,7 +7,7 @@ type CodeParserImportsData = { |
|
|
|
|
packages?: string[], |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getStringCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getStringCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: 'concatenate an arbitrary number of string values', |
|
|
|
@ -21,7 +20,7 @@ export function getStringCompletionItems(range: IRange, monaco): monaco.language |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getBytesCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getBytesCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: 'concatenate an arbitrary number of values', |
|
|
|
@ -35,7 +34,7 @@ export function getBytesCompletionItems(range: IRange, monaco): monaco.languages |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function getBlockCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getBlockCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: '(address): Current block miner’s address', |
|
|
|
@ -97,7 +96,7 @@ export function getBlockCompletionItems(range: IRange, monaco): monaco.languages |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getCompletionSnippets(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getCompletionSnippets(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
label: 'contract', |
|
|
|
@ -193,7 +192,7 @@ export function getCompletionSnippets(range: IRange, monaco): monaco.languages.C |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getTxCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getTxCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: '(uint): gas price of the transaction', |
|
|
|
@ -212,7 +211,7 @@ export function getTxCompletionItems(range: IRange, monaco): monaco.languages.Co |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getMsgCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getMsgCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: '(bytes): complete calldata', |
|
|
|
@ -252,7 +251,7 @@ export function getMsgCompletionItems(range: IRange, monaco): monaco.languages.C |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getAbiCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getAbiCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: 'encode(..) returs (bytes): ABI-encodes the given arguments', |
|
|
|
@ -298,7 +297,7 @@ export function getAbiCompletionItems(range: IRange, monaco): monaco.languages.C |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function GetCompletionTypes(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function GetCompletionTypes(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
const completionItems = []; |
|
|
|
|
const types = ['address', 'string', 'bytes', 'byte', 'int', 'uint', 'bool', 'hash']; |
|
|
|
|
for (let index = 8; index <= 256; index += 8) { |
|
|
|
@ -314,7 +313,7 @@ export function GetCompletionTypes(range: IRange, monaco): monaco.languages.Comp |
|
|
|
|
return completionItems; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function CreateCompletionItem(label: string, kind: monaco.languages.CompletionItemKind, detail: string, range: IRange) { |
|
|
|
|
function CreateCompletionItem(label: string, kind: monaco.languages.CompletionItemKind, detail: string, range: monaco.IRange) { |
|
|
|
|
const completionItem: monaco.languages.CompletionItem = { |
|
|
|
|
label, |
|
|
|
|
kind, |
|
|
|
@ -327,7 +326,7 @@ function CreateCompletionItem(label: string, kind: monaco.languages.CompletionIt |
|
|
|
|
return completionItem; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function GetCompletionKeywords(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function GetCompletionKeywords(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
const completionItems = []; |
|
|
|
|
const keywords = ['modifier', 'mapping', 'break', 'continue', 'delete', 'else', 'for', |
|
|
|
|
'after', 'promise', 'alias', 'apply', 'auto', 'copyof', 'default', 'define', 'final', 'implements', |
|
|
|
@ -366,7 +365,7 @@ export function GetCompletionKeywords(range: IRange, monaco): monaco.languages.C |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function GeCompletionUnits(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function GeCompletionUnits(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
const completionItems = []; |
|
|
|
|
const etherUnits = ['wei', 'gwei', 'finney', 'szabo', 'ether']; |
|
|
|
|
etherUnits.forEach(unit => { |
|
|
|
@ -390,7 +389,7 @@ export function GeCompletionUnits(range: IRange, monaco): monaco.languages.Compl |
|
|
|
|
return completionItems; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function GetImports(range: IRange |
|
|
|
|
export function GetImports(range: monaco.IRange |
|
|
|
|
, monaco, data: CodeParserImportsData |
|
|
|
|
, word: string |
|
|
|
|
): monaco.languages.CompletionItem[] { |
|
|
|
@ -473,7 +472,7 @@ export function GetImports(range: IRange |
|
|
|
|
return list; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export function GetGlobalVariable(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function GetGlobalVariable(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: 'Current block', |
|
|
|
@ -520,7 +519,7 @@ export function GetGlobalVariable(range: IRange, monaco): monaco.languages.Compl |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function GetGlobalFunctions(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function GetGlobalFunctions(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: 'assert(bool condition): throws if the condition is not met - to be used for internal errors.', |
|
|
|
@ -644,7 +643,7 @@ export function GetGlobalFunctions(range: IRange, monaco): monaco.languages.Comp |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getContextualAutoCompleteByGlobalVariable(word: string, range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getContextualAutoCompleteByGlobalVariable(word: string, range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
if (word === 'block') { |
|
|
|
|
return getBlockCompletionItems(range, monaco); |
|
|
|
|
} |
|
|
|
@ -669,7 +668,7 @@ export function getContextualAutoCompleteByGlobalVariable(word: string, range: I |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getArrayCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getArrayCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: '', |
|
|
|
@ -706,7 +705,7 @@ export function getArrayCompletionItems(range: IRange, monaco): monaco.languages |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getAddressCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getAddressCompletionItems(range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
detail: '(uint256): balance of the Address in Wei', |
|
|
|
@ -752,7 +751,7 @@ export function getAddressCompletionItems(range: IRange, monaco): monaco.languag |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function getContextualAutoCompleteBTypeName(word: string, range: IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
export function getContextualAutoCompleteBTypeName(word: string, range: monaco.IRange, monaco): monaco.languages.CompletionItem[] { |
|
|
|
|
if (word === 'ArrayTypeName') { |
|
|
|
|
return getArrayCompletionItems(range, monaco); |
|
|
|
|
} |
|
|
|
|