Skip to content

Commit

Permalink
Update readme for change from snippets to IntelliSense
Browse files Browse the repository at this point in the history
  • Loading branch information
loganch committed Apr 27, 2017
1 parent 47f9ef3 commit 67f9e9a
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ and developed from Damien122's release.

## Features

* Show AutoIt Syntax highlighting
* Snippets for Functions, Packaged UDFs, and Macros
* AutoIt Syntax highlighting
* IntelliSense (code hints and completion)
* Launch, compile and build scripts from VSCode
* Launch AutoIt Help for highlighted text

Expand All @@ -16,4 +16,4 @@ Advanced functions on the full install of [SciTE4AutoIt3](https://www.autoitscri
## GitHub
Check out the code, leave feedback and feature requests now on [GitHub/loganch](https://github.com/loganch/AutoIt-VSCode)
### Contributing
Please fork the repository and contribute back using pull requests.
Please fork the repository and contribute using pull requests.
86 changes: 86 additions & 0 deletions out/src/ai_signature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
'use strict'

var { languages, Position, SignatureHelp, SignatureInformation, ParameterInformation } = require('vscode')


module.exports = languages.registerSignatureHelpProvider(
{ language: 'autoit', scheme: 'file' },
{
provideSignatureHelp(document, position, token) {
let theCall = frontOfCall(document, position)
if (theCall == null) {
return null
}
let callerPos = this.prevTokenPos(document, theCall.openParen)
return definitionLocation(document, callerPos, { language: 'autoit', scheme: 'file' }).then(res => {
if (!res) {
// The definition was not found
return null
}
if (res.line === callerPos.line) {
// This must be a function definition
return null
}
let result = new SignatureHelp()
let declarationText, sig
let si
declarationText = res.declarationlines[0]
let funcNameStart = declarationText.indexOf(res.name + '('); // Find 'functionname(' to remove anything before it
if (funcNameStart > 0) {
declarationText = declarationText.substring(funcNameStart)
}
si = new SignatureInformation(declarationText, res.doc)
sig = declarationText.substring(res.name.length)

si.parameters = parameters(sig).map(paramText =>
new ParameterInformation(paramText)
)
result.signatures = [si]
result.activeSignature = 0;
result.activeParameter = Math.min(theCall.commas.length, si.parameters.length - 1)
return result
})
}
},
',', '('
)

var prevTokenPos = function(doc, pos) {
while (pos.character > 0) {
let word = doc.getWordRangeAtPosition(pos)
if (word) {
return word.start
}

pos = pos.translate(0, -1)
}
return null
}

var frontOfCall = function(doc, pos) {
let currentLine = doc.lineAt(pos.line).text.substring(0, pos.character)
let parenBalance = 0
let commas = []

for (let char = pos.character; char >= 0; char--) {
switch(currentLine[char]) {
case '(':
parenBalance--
if (parenBalance < 0) {
return {
openParen: new Position(pos.line, char),
commas: commas
}
}
break
case ')':
parenBalance++
break
case ',':
if (parenBalance === 0) {
commas.push(new Position(pos.line, char))
}
}
}
return null
}
10 changes: 10 additions & 0 deletions out/src/signatures/functions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ClipGet": {
"description": "Retrieves text from the clipboard.",
"signature": "( )"
},
"ClipPut": {
"description": "Writes text to the clipboard.",
"signature": "( \"value\" )"
}
}

0 comments on commit 67f9e9a

Please sign in to comment.