Git Product home page Git Product logo

vscode-autoit's People

Contributors

genius257 avatar sven-seyfert avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-autoit's Issues

Incorrect variable declaration lookup within function

Variable lookup within a function does not work as expected.

          @genius257 Unfortunately, the latest update appears to have broken the GTD functionality for functions. ☹️

Originally posted by @Danp2 in #24 (comment)

Example:

#include <Array.au3>

$x = 123

Func x()
    $x = 321
    $MB_HELP
    $x
EndFunc

The issue with the $MB_HELP declaration is caused partially by the parser: genius257/autoit3-pegjs#33 (comment)

The remaining declaration resolve problem is caused by the Local/Global/Auto scope of a variable not being taken into account, within a function.

As matching variable declarations are found within the function (before the lookup origin), the scope of the declaration must be updated.

  • Global will do nothing special, and let the general global lookup logic handle declaration mach finding.
  • Local will override previous global scope declarations and cannot be scope overridden. Meaning first matching declaration with local scope will be a match.
  • Auto will keep first matching declaration as a fallback if the general global lookup returns nothing.

Suggestion for the CHANGELOG file

Hi @genius257 ,

I was pleased to see that you use both "SemVer" and "keepachangelog" 👍 . To increase the benefit even more, I would suggest to use the CHANGELOG.md file with the GitHub TAG comparison functionality. I mean comparison of changes between the versions/tags.

See the possible changes in my fork branch extent-changelog-by-tag-comparison here.

Then you can do this:
github-comparing-changes

If you think this would be a easy but good improvement, please let me know. I would love to create the pull request 🤞 .

Best regards
Sven

DocBlock support: Summary and Description

DocBlock support for Files, Functions and Variables.
Info about how the structure of the Summary and Description are defined here.
The Summary and Description should be available in hover info and suggestion information.

Example for the DocBlock syntax in AutoIt3:

#cs
# A summary informing the user what the associated element does.
#
# A *description*, that can span multiple lines, to go _in-depth_ into
# the details of this element and to provide some background information
# or textual references.
#ce

Go To Definition functionality

Running some basic tests, I've encountered one small issue with the GTD functionality. Here's a code sample --

#include "..\webdriver\wd_core.au3"
#include "..\webdriver\wd_capabilities.au3"

Func Main()
	$_WD_Debug = $_WD_DEBUG_Full

	_WD_CapabilitiesDefine($_WD_KEYS__STANDARD_PRIMITIVE, 'webSocketUrl')
	_WD_CapabilitiesDefine($_WD_KEYS__STANDARD_PRIMITIVE, 'moz:debuggerAddress')
EndFunc

With the above, everything is good except that I am unable to find a reference for $_WD_Debug, which is a global variable declared in wd_core.au3. Taking a deeper dive, it seems that most of the global variables from include files are not being recognized.

Better function signature help

Currently it does not know what parameter you are on, but guesses based on when a comma is pressed.

It is tricky when the parser MIGHT detect a syntax error and not be able to calculate it based on AST tree information.

Another problem with the AST is there is no information about the position of the comma's between the parameters being entered, so currently it is tricky to know when moving with the arrow keys if the threshold between two parameters are crossed.

I will haft to look at how other extensions handle this, and see if a non janky solution is currently possible.

Missing intellisense support for built-in function Opt

Function Opt is not currently support for suggestions and hovering.

Expected cause is because it is omitted from the function listing on the official autoit3 documentation.
It is mentioned in "AutoItSetOption" but does not have it's own list entry.

Change for loop, to instead use Array.forEach

This is to prevent the use of ! in front of array indexed values

for (let index = 0; index < includes.length; index++) {
let script = workspace.get(includes[index]!);
if (script !== undefined) {
let _completionItems = script.declarations.reduce<CompletionItem[]>((completionItems, declaration) => {
switch (declaration.type) {
case "FunctionDeclaration":
completionItems.push({
label: declaration.id.name,
kind: CompletionItemKind.Function,
});
break;
case "VariableDeclarator":
completionItems.push({
label: "$" + declaration.id.name,
kind: CompletionItemKind.Variable,
insertText: "$" + declaration.id.name,
});
break;
}
return completionItems;
}, []);
completionItems.push(..._completionItems);
includes.push(...script.getIncludes().map(x => x.uri).filter((x):x is string => x!==null && !includes.includes(x)));
}
}

Generate native suggestion objects once, and re-use as cached array

Generating the native suggestions should be done once, since it's not going to change

//Add all native suggestions
completionItems = completionItems.concat(Object.keys(nativeSuggestions).map<CompletionItem>(nativeSuggestion => ({ //FIXME: Map Object.entries instead
label: nativeSuggestions[nativeSuggestion]!.title || "",
kind: nativeSuggestions[nativeSuggestion]!.kind,
documentation: nativeSuggestions[nativeSuggestion]!.documentation,
detail: nativeSuggestions[nativeSuggestion]!.detail,
})));

Declarations in For loops are ignored

Global $aItems = [1, 2, 3]
For $item In $aItems
    ConsoleWrite($item & @CRLF)
Next

Currently $item will not work for declaration lookup or completion suggestions.

Issue with standard include files

#include <array.au3> ; this isn't working
#include "array.au3" ; this works fine, linking to "C:\Program Files (x86)\AutoIt3\Include\array.au3"

Settings.json file contains

		"autoit3.userDefinedLibraries": [
          "C:\\Users\\danpo\\Dropbox\\Autoit UDFs"
		],
		"autoit3.installDir": "C:\\Program Files (x86)\\AutoIt3\\"

Observations when using <> as delimiters --

  • No hovers, intellisense, etc
  • No file link for UDF

P.S. I wanted to investigate this myself, but all my breakpoints appeared as unbound. Can you provide guidance on this?

Variable identifier outside function points to function parameter as it's declaration

variables within the same line numbers, as a function in an included script, have their declarator seen as the parameter of said function.

Example that demonstrates this issue:

Func _ArrayAdd(ByRef $aArray, $vValue, $iStart = 0, $sDelim_Item = "|", $sDelim_Row = @CRLF, $iForce = $ARRAYFILL_FORCE_DEFAULT)
Is declared on line 77 in array.au3

#include <array.au3>











































































$aArray

Extension setting for hiding AutoIt3 functions and variables prefixed with __ from completion suggestions

A setting for hiding functions and variables prefixed with __, normally used to indicate internal usage only.1

So if the Color UDF is included via #include <Color.au3> functions like __ColorConvertHueToRGB and variables like $__COLORCONSTANTS_HSLMAX would not be suggested, but variables with the prefix within current open document would still be suggested.

Footnotes

  1. Additionally a sub-setting for if the same applies to current open document might be needed.

Extension uses a document selector without scheme

I noticed this message in the Output pane --

2023-04-02 11:47:05.073 [info] Extension 'genius257.autoit' uses a document selector without scheme. Learn more about this: https://go.microsoft.com/fwlink/?linkid=872305

After researching, it appears to be resolved by adding a scheme to this line --

const documentSelector: DocumentSelector | string = [{ language: 'au3' }];

Would adding scheme: 'file' here break anything?

Wrong AST to string representation for array access in variable declaration information shown on hover.

Wrong AST to string representation for array access in variable declaration information shown on hover.

Global $aVar = ["", $aRelativeURI[43], UBound($aRelativeURI)>44?$aRelativeURI[44]:"", UBound($aRelativeURI)>45?$aRelativeURI[45]:""]
$aVar

Shows as object property access via the dot notation:

$aVar = ["", $aRelativeURI.43, UBound($aRelativeURI)>44 ? $aRelativeURI.44 : "", UBound($aRelativeURI)>45 ? $aRelativeURI.45 : ""]

Process Assign function calls as a pseudo variable declaration statements

The native AutoIt3 function Assign is basically an extended variable declaration statement, and should be processed as such.

It will require some extra special logic due to:

  • It being a function call, so it can appear within statements.
  • The optional flags $ASSIGN_CREATE and $ASSIGN_EXISTFAIL

The flags parameter potentially being unavailable to resolve via static analysis may cause problems.

Issue first discovered here: #24 (comment)

Debugging extension with VSCode

P.S. I wanted to investigate this myself, but all my breakpoints appeared as unbound. Can you provide guidance on this?

Are you running the code using the "Client + Server" option from the drop-down list in the debug tab?

Originally posted by @genius257 in #27 (comment)

au3 signature helper support for builtin functions

Currently signature help is not available, caused by server logic expecting to have AST for the built-in function declarations.

The ideal solution, is an internal always loaded script instance that contains all the built-in functions.
This will currently make it impossible to show function description and documentation.
Therefore this feature will wait for #41 to finish first, so that existing function documentation shown can be transferred to the function Docblock.

First constant array is marked as problem

It looks like there is an issue with constant arrays.
Only the first occurrence of an constant array is marked as problem.

Const $constVar = 2
Const $constArray[2] = [1, 2]
Const $constArray2[2] = [1, 2]

Problem:
Expected " ", "=", "\t", or [0-9a-zA-Z_] but "[" found.

[{
"resource": "/C:/Users/GlobalConstArray.au3",
"owner": "generated_diagnostic_collection_name#0",
"severity": 8,
"message": "Expected " ", "=", "\t", or [0-9a-zA-Z_] but "[" found.",
"startLineNumber": 2,
"startColumn": 18,
"endLineNumber": 2,
"endColumn": 19
}]

Completion suggestions for PreProc

Known PreProcs sould be in the completion suggestions
Examples: #include-once, #include, #pragma, #comments-start, #comments-end, #cs, #ce and #NoTrayIcon.

Special PreProcs for Au3Check should also be added: #ignorefunc, #forceref and #forcedef

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.