Skip to content

Commit d238beb

Browse files
committed
Fixes #76
1 parent fb6ea76 commit d238beb

File tree

4 files changed

+68
-18
lines changed

4 files changed

+68
-18
lines changed

package.json

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,50 +143,55 @@
143143
"group": "idris@5"
144144
},
145145
{
146-
"command": "idris.case-split",
146+
"command": "idris.add-proof-clause",
147147
"when": "editorFocus && editorLangId == idris",
148148
"group": "idris@6"
149149
},
150150
{
151-
"command": "idris.proof-search",
151+
"command": "idris.case-split",
152152
"when": "editorFocus && editorLangId == idris",
153153
"group": "idris@7"
154154
},
155155
{
156-
"command": "idris.make-with",
156+
"command": "idris.proof-search",
157157
"when": "editorFocus && editorLangId == idris",
158158
"group": "idris@8"
159159
},
160160
{
161-
"command": "idris.make-case",
161+
"command": "idris.make-with",
162162
"when": "editorFocus && editorLangId == idris",
163163
"group": "idris@9"
164164
},
165165
{
166-
"command": "idris.make-lemma",
166+
"command": "idris.make-case",
167167
"when": "editorFocus && editorLangId == idris",
168168
"group": "idris@10"
169169
},
170170
{
171-
"command": "idris.eval-selection",
171+
"command": "idris.make-lemma",
172172
"when": "editorFocus && editorLangId == idris",
173173
"group": "idris@11"
174174
},
175175
{
176-
"command": "idris.start-refresh-repl",
176+
"command": "idris.eval-selection",
177177
"when": "editorFocus && editorLangId == idris",
178178
"group": "idris@12"
179179
},
180180
{
181-
"command": "idris.send-selection-repl",
181+
"command": "idris.start-refresh-repl",
182182
"when": "editorFocus && editorLangId == idris",
183183
"group": "idris@13"
184184
},
185185
{
186-
"command": "idris.cleanup-ibc",
186+
"command": "idris.send-selection-repl",
187187
"when": "editorFocus && editorLangId == idris",
188188
"group": "idris@14"
189189
},
190+
{
191+
"command": "idris.cleanup-ibc",
192+
"when": "editorFocus && editorLangId == idris",
193+
"group": "idris@15"
194+
},
190195
{
191196
"command": "idris.typecheck",
192197
"when": "editorFocus && editorLangId == lidris",
@@ -213,49 +218,54 @@
213218
"group": "idris@5"
214219
},
215220
{
216-
"command": "idris.case-split",
221+
"command": "idris.add-proof-clause",
217222
"when": "editorFocus && editorLangId == lidris",
218223
"group": "idris@6"
219224
},
220225
{
221-
"command": "idris.proof-search",
226+
"command": "idris.case-split",
222227
"when": "editorFocus && editorLangId == lidris",
223228
"group": "idris@7"
224229
},
225230
{
226-
"command": "idris.make-with",
231+
"command": "idris.proof-search",
227232
"when": "editorFocus && editorLangId == lidris",
228233
"group": "idris@8"
229234
},
230235
{
231-
"command": "idris.make-case",
236+
"command": "idris.make-with",
232237
"when": "editorFocus && editorLangId == lidris",
233238
"group": "idris@9"
234239
},
235240
{
236-
"command": "idris.make-lemma",
241+
"command": "idris.make-case",
237242
"when": "editorFocus && editorLangId == lidris",
238243
"group": "idris@10"
239244
},
240245
{
241-
"command": "idris.eval-selection",
246+
"command": "idris.make-lemma",
242247
"when": "editorFocus && editorLangId == lidris",
243248
"group": "idris@11"
244249
},
245250
{
246-
"command": "idris.start-refresh-repl",
251+
"command": "idris.eval-selection",
247252
"when": "editorFocus && editorLangId == lidris",
248253
"group": "idris@12"
249254
},
250255
{
251-
"command": "idris.send-selection-repl",
256+
"command": "idris.start-refresh-repl",
252257
"when": "editorFocus && editorLangId == lidris",
253258
"group": "idris@13"
254259
},
255260
{
256-
"command": "idris.cleanup-ibc",
261+
"command": "idris.send-selection-repl",
257262
"when": "editorFocus && editorLangId == lidris",
258263
"group": "idris@14"
264+
},
265+
{
266+
"command": "idris.cleanup-ibc",
267+
"when": "editorFocus && editorLangId == lidris",
268+
"group": "idris@15"
259269
}
260270
]
261271
},
@@ -290,6 +300,11 @@
290300
"title": "Idris: Generate an initial pattern match clause",
291301
"description": "Add an initial pattern match clause"
292302
},
303+
{
304+
"command": "idris.add-proof-clause",
305+
"title": "Idris: Generate an initial pattern match clause when trying to proof a type",
306+
"description": "http://docs.idris-lang.org/en/latest/reference/misc.html#match-application"
307+
},
293308
{
294309
"command": "idris.case-split",
295310
"title": "Idris: Generate a case split for the pattern variable",

src/controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ let getCommands = () => {
1717
['idris.print-definition', runCommand(commands.printDefinition)],
1818
['idris.show-holes', runCommand(commands.showHoles)],
1919
['idris.add-clause', runCommand(commands.addClause)],
20+
['idris.add-proof-clause', runCommand(commands.addProofClause)],
2021
['idris.case-split', runCommand(commands.caseSplit)],
2122
['idris.proof-search', runCommand(commands.proofSearch)],
2223
['idris.make-with', runCommand(commands.makeWith)],

src/idris/commands.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,35 @@ let addClause = (uri) => {
416416
})
417417
}
418418

419+
let addProofClause = (uri) => {
420+
let currentWord = getWord()
421+
if (!currentWord) return
422+
let editor = vscode.window.activeTextEditor
423+
let line = editor.selection.active.line
424+
425+
let successHandler = (arg) => {
426+
let clause = arg.msg[0] + "\n"
427+
editor.edit((edit) => {
428+
edit.insert(new vscode.Position(line + 1, 0), line + 1 == editor.document.lineCount ? "\n" + clause : clause)
429+
})
430+
431+
outputChannel.clear()
432+
needDestroy = true
433+
}
434+
435+
new Promise((resolve, reject) => {
436+
model.load(uri).filter((arg) => {
437+
return arg.responseType === 'return'
438+
}).flatMap(() => {
439+
return model.addProofClause(line + 1, currentWord)
440+
}).subscribe(handlerWrapper(successHandler), displayErrors)
441+
showLoading()
442+
resolve()
443+
}).then(function () {
444+
}).catch(function () {
445+
})
446+
}
447+
419448
let caseSplit = (uri) => {
420449
let currentWord = getWord()
421450
if (!currentWord) return
@@ -674,6 +703,7 @@ module.exports = {
674703
printDefinition,
675704
showHoles,
676705
addClause,
706+
addProofClause,
677707
caseSplit,
678708
proofSearch,
679709
makeWith,

src/idris/model.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ class IdrisModel {
181181
return this.prepareCommand([':add-clause', line, word])
182182
}
183183

184+
addProofClause(line, word) {
185+
return this.prepareCommand([':add-proof-clause', line, word])
186+
}
187+
184188
caseSplit(line, word) {
185189
return this.prepareCommand([':case-split', line, word])
186190
}

0 commit comments

Comments
 (0)