Skip to content

Commit

Permalink
Removed all snippets but logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahnfelt committed Apr 18, 2023
1 parent 0fd7abb commit 044082f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 191 deletions.
12 changes: 6 additions & 6 deletions compiler/Inference.ff
Original file line number Diff line number Diff line change
Expand Up @@ -964,20 +964,20 @@ extend self: Inference {
if(memberName.startsWith(prefix)) {
let realParameters = memberScheme.signature.parameters.dropFirst(if(member) {1} else {0})
let pair = if(!memberScheme.isVariable) {
let trailing = realParameters.last().flatMap {p =>
let trailing = realParameters.pairs().reverse().map {| Pair(i, p) =>
p.valueType.{
| TConstructor(_, name, _) {name.startsWith("Function$")} =>
Some(Pair(
" {...}"
" {$0}"
" {$" + (i + 1) + "}"
))
| _ =>
None
}
}
}.toStream().takeWhile {_ != None}.collect {_}.toList().reverse()
let allRequired = realParameters.filter {_.default.isEmpty()}
let required =
if(trailing.isEmpty()) {allRequired} else {allRequired.dropLast()}.pairs().map {
allRequired.dropLast(trailing.size()).pairs().map {
| Pair(index, p) =>
Pair(p.name, "${" + (index + 1) + ":" + p.name + "}")
}
Expand All @@ -989,12 +989,12 @@ extend self: Inference {
"(" + [...required.map {_.first}, ...optional.toList()].join(", ") + ")"
} else {
""
} + trailing.map {_.first}.else {""}
} + trailing.map {_.first}.join()
if(trailing.isEmpty() || !required.isEmpty()) {
"(" + required.map {_.second}.join(", ") + ")"
} else {
""
} + trailing.map {_.second}.else {"$0"}
} + if(trailing.isEmpty()) {"$0"} else {trailing.map {_.second}.join()}
)
} else {Pair("", "")}
let shortName = memberName.dropFirst(prefix.size())
Expand Down
193 changes: 8 additions & 185 deletions vscode/snippets.json
Original file line number Diff line number Diff line change
@@ -1,193 +1,16 @@
{
"main": {
"prefix": "main",
"body": [
"main(system: NodeSystem) {",
" $0",
"}"
],
"description": "Main function"
},
"nodeMain": {
"prefix": "node",
"body": [
"nodeMain(system: NodeSystem) {",
" $0",
"}"
],
"description": "Node main function"
},
"browserMain": {
"prefix": "browser",
"body": [
"browserMain(system: BrowserSystem) {",
" $0",
"}"
],
"description": "Browser main function"
},
"buildMain": {
"prefix": "build",
"body": [
"buildMain(system: BuildSystem) {",
" $0",
"}"
],
"description": "Build main function"
},
"extend": {
"prefix": "extend",
"body": [
"extend ${1:self}: $2 {",
" $0",
"}"
],
"description": "Extend a type with methods"
},
"data": {
"prefix": "data",
"body": [
"data ${1}($2) {$0}"
],
"description": "Data type declaration"
},
"class": {
"prefix": "class",
"body": [
"class ${1}($2) {$0}"
],
"description": "Class type declaration"
},
"capability": {
"prefix": "capability",
"body": [
"capability ${1}($2) {$0}"
],
"description": "Capability type declaration"
},
"package": {
"prefix": "package",
"body": [
"package $1:$2:$3"
],
"description": "Package declaration"
},
"dependency": {
"prefix": "dependency",
"body": [
"dependency $1:$2:$3"
],
"description": "Dependency declaration"
},
"import": {
"prefix": "import",
"body": [
"import $1 from $2:$3"
],
"description": "Import declaration"
},
"function": {
"prefix": "function",
"body": [
"function $1($2): $3 {",
" $0",
"}"
],
"description": "Function definition"
},
"let": {
"prefix": "let",
"body": [
"let $1 = $0"
],
"description": "Immutable variable definition"
},
"mutable": {
"prefix": "mutable",
"body": [
"mutable $1 = $0"
],
"description": "Mutable variable definition"
},
"if": {
"prefix": "if",
"body": [
"if($1) {",
" $0",
"}"
],
"description": "If expression"
},
"else": {
"prefix": "else",
"body": [
"else {",
" $0",
"}"
],
"description": "Else expression part"
},
"elseif": {
"prefix": "elseif",
"body": [
"elseIf {$1} {",
" $0",
"}"
],
"description": "ElseIf expression part"
},
"try": {
"prefix": "try",
"body": [
"try {",
" $1",
"} catch {| ${2:MyException e}, error =>",
" $3",
"} finally {",
" $0",
"} grab()"
],
"description": "Try catch finanlly expression"
},
"throw": {
"prefix": "throw",
"body": [
"throw(${1:MyException()})"
],
"description": "Throw expression"
},
"while": {
"prefix": "while",
"body": [
"while {$1} {",
" $0",
"}"
],
"description": "While expression"
},
"do": {
"prefix": "do",
"body": [
"do {",
" $0",
"}"
],
"description": "Do expression"
},
"dowhile": {
"prefix": "dowhile",
"log": {
"prefix": "Log",
"body": [
"doWhile {",
" $0",
"}"
"Log.trace(\"$1: \" + $1)"
],
"description": "Do while expression"
"description": "Trace expression"
},
"log": {
"prefix": "log",
"logg": {
"prefix": "Logg",
"body": [
"Log.debug(\"$1: \" + $1)"
"Log.trace(\"${RELATIVE_FILEPATH/[\\\\]/\\//g} $RANDOM_HEX\")"
],
"description": "Log expression"
"description": "Trace location"
}
}

0 comments on commit 044082f

Please sign in to comment.