harrisont / fastbuild-vscode Goto Github PK
View Code? Open in Web Editor NEWFASTBuild extension for Visual Studio Code
Home Page: https://marketplace.visualstudio.com/items?itemName=HarrisonT.fastbuild-support
License: MIT License
FASTBuild extension for Visual Studio Code
Home Page: https://marketplace.visualstudio.com/items?itemName=HarrisonT.fastbuild-support
License: MIT License
Split out from #28.
First I need to confirm that this duplicated data isn't necessary.
ForEach
iterating over multiple arrays at a time (single array iterating already supported) (docs). This is low priority, since I have never seen it used.VS Code docs:
The symbol list should include target and variable definitions.
"Go to references" on the .A
of the Print( .A )
statement in:
.MyStruct1 = [
.A = 1
]
.MyStruct2 = [
.A = 2
]
.MyStructs = {
.MyStruct1
.MyStruct2
}
ForEach( .MyStruct in .MyStructs )
{
Using( .MyStruct )
Print( .A )
}
4 references:
.A = 1
.A = 2
Using( .MyStruct )
Print( .A )
3 references:
.A = 1
Using( .MyStruct )
Print( .A )
Specifically by deduplicating the following fields in evaluated data:
variableReferences
with the same range
variableDefinitions
returned by getDocumentSymbols
/getWorkspaceSymbols
with the same name
and range
#if exists(...)
(docs) now checks the actual environment variable instead of always evaluating to false.
Code snippet:
} else if (isParsedDirectiveIfConditionTermEnvVarExists(term)) {
// The language server cannot know what environment variables will exist when FASTBuild is run,
// so always assume "exists(...)" evaluates to false.
evaulatedTerm = false;
}
Note that both the target's name and the target's output file reference a target.
Places that can define targets:
Copy
's .Dest
(be sure to correctly handle both file and directory values)CopyDir
's .Dest
?Exec
's .ExecOutput
Places that can reference targets:
.PreBuildDependencies
Copy
's .Source
CopyDir
's .SourcePaths
?Exec
's .ExecInput
src\Code\Tools\FBuild\FBuildCore\Graph\Node.h
):
Node::m_PreBuildDependencies
Node::m_StaticDependencies
Node::m_DynamicDependencies
This will make it so that users don't need to also get another extension (e.g. RoscoP.fastbuild
) for syntax highlighting.
Right now the results are in evaluation order.
fbuild.bff
:
.A = 1
#include 'other-file.bff'
other-file.bff
:
Print( .A )
other-file.bff
and ensure that fbuild.bff
is closed.Ctrl
and hover over the .A
in Print( .A )
.fbuild.bff
opened, changed, and closed.
state.documents.onDidChangeContent
in server.ts
or by adding a log there.Verbose Trace logs (trimmed):
[Trace - ...] Sending request 'textDocument/definition - (...)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Users/hting/Desktop/harrison.bff"
},
"position": {
"line": 0,
"character": 8
}
}
[Trace - ...] Received response 'textDocument/definition - (...)' in 2ms.
Result: [
{
...
"targetUri": "file:///c%3A/Users/hting/Desktop/fbuild.bff",
...
}
]
[Trace - ...] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Users/hting/Desktop/fbuild.bff",
...
}
}
[Trace - ...] Sending notification 'textDocument/didClose'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Users/hting/Desktop/fbuild.bff"
}
}
parse-duration: 0.751ms
evaluation-duration: 0.173ms
onDidChangeContent
notification even though nothing changed.For example,
Exec('MyAlias')
{
}
should generate a non-fatal error like "Exec() - Missing required property '.ExecOutput'".
"Go to definition" on the .A
of the Print( .A )
statement in:
.MyStruct1 = [
.A = 1
]
.MyStruct2 = [
.A = 2
]
.MyStructs = {
.MyStruct1
.MyStruct2
}
ForEach( .MyStruct in .MyStructs )
{
Using( .MyStruct )
Print( .A )
}
It shows the following definitions:
Using( .MyStruct )
.A = 1
.A = 2
It only shows the Using( .MyStruct )
definition.
.MyVar = { 'a' }
ForEach(.Item in .MyVar) {}
Print(.Item)
The reference to .Item
in Print(.Item)
generates an error, since it should not be defined.
No error is generated and hovering over the .Item
in Print(.Item)
shows the value from the loop.
Initial debugging shows that getWorkspaceSymbols
returns the symbols and the Received response 'workspace/symbol'
message happens, but VS Code is stuck showing that they are still loading.
Note that we already have a form of incremental parsing, in that we already only re-parse the changed files. This issue is specifically about incremental evaluation.
onBeforeImportFile
callback. The callback will check if the file is the same as the one being edited and if so, clear the cache and add the new file/state. It first clears the cache because the existing cached state might now be invalid.onAfterImportFile
callback..Message1 = "h^"i"
.Message2 = 'h^'i'
.Message3 = 'h^$i'
The strings are highlighted in the same color, and the Developer: Inspect Editor Tokens and Scopes
's textmate scopes are string.quoted.single.fastbuild
/string.quoted.double.fastbuild
, source.fastbuild
.
The ^
and the character after it are a different color, and have with textmate scopes constant.character.escape.fastbuild
, string.quoted.single.fastbuild
/string.quoted.double.fastbuild
, source.fastbuild
.
.Message = '^a'
An error message that indicates that it's an invalid escape sequence, and that only $
, ^
, '
(in single-quoted strings), and "
(in double-quoted strings) need to be escaped.
The error message is:
Syntax error: Unexpected input.
Expecting to see one of the following:
• single-quoted-String-end: "'"
• String-literal (example: "abc")
Attempt to "go to references" of the 1
in:
.A = 1
No references
Getting references fails:
[Trace - 6:36:33 PM] Sending request 'textDocument/references - (34)'.
[Trace - 6:36:33 PM] Received response 'textDocument/references - (34)' in 60ms. Request failed: Request textDocument/references failed with message: Reduce of empty array with no initial value (-32603).
[Error - 6:36:33 PM] Request textDocument/references failed.
Message: Request textDocument/references failed with message: Reduce of empty array with no initial value
Code: -32603
Internally, the error is:
TypeError: Reduce of empty array with no initial value
at Array.reduce (<anonymous>)
at getVariableReferences (server\src\features\referenceProvider.ts:94:10)
at Object.getReferences (server\src\features\referenceProvider.ts:34:24)
I'm unsure if this is actually undesired behavior or not - I'll need to ponder it.
"Go to references" on the .A
of the .A = 3
statement in:
.A = 3
Print( 'Before $A$' )
.MyStruct = [
.A = 1
]
Using( .MyStruct )
Print( 'After $A$' )
3 references:
.A = 3
Print( 'Before $A$' )
Using( .MyStruct )
5 references:
.A = 1
.A = 3
Print( 'Before $A$' )
Using( .MyStruct )
Print( 'After $A$' )
Right now if there is an evaluation error, it immediately stops the rest of the evaluation. In other words, all errors are "fatal" errors.
Support non-fatal errors by supporting generation and display of errors that do not stop the rest of the evaluation.
An example of a non-fatal error is a missing the required .ExecExecutable
property when calling the Exec
function.
Ideas for context:
Potential reason not to do this: without context we can deduplicate values across iterations. With context we would naturally show each iteration's value, even if they are the same. So it might be more usable to not show context and deduplicate values across iterations.
Right now it does not appear on hover or on "go to document symbols".
#13 added code completion of function properties. Adding code completion of available variables would be useful.
This will possibly require adding support for tracking the AST (abstract syntax tree), which doesn't currently happen.
.MyVar = '^';'
No parse error
Syntax error: Unexpected input.
Expecting to see one of the following:
• single-quoted-String-end: "'"
• String-literal (example: "abc")
Right now errors throw an exception and stop the evaluation. This issue is to instead continue the evaluating even after hitting non-fatal errors. This involves:
context.evaluatedData
.diagnosticProvider.ts
and server.ts
to handle the multiple errors.The evaluation completes after the textDocument/documentSymbol
response is sent:
[Trace] Sending notification 'textDocument/didChange'.
[Trace] Received request 'workspace/configuration - (3)'.
[Trace] Sending response 'workspace/configuration - (3)'. Processing request took 0ms
[Trace] Sending request 'textDocument/documentSymbol - (9)'.
[Trace] Received response 'textDocument/documentSymbol - (9)' in 45ms.
parse-duration: 9.052ms
evaluation-duration: 832.045ms
I'm guessing that's because the textDocument/didChange
notification queues an update because of the debounce delay, and then the client immediately requests textDocument/documentSymbol
.
My guess is that the fix is to change the handling of textDocument/documentSymbol
to first check if the document has a queued update, and wait to respond until it completes.
For example, TypeScript shows the container that the variable is in (the getReferences
function is in the ReferenceProvider
class):
Include the variable container as its context:
Implementation details
getDocumentSymbols
/getWorkspaceSymbols
to include the "children" symbols in the children
field in the DocumentSymbol
s that it returns, and remove the "children" symbols from the top-level symbols (otherwise they'll be duplicated)..'a.b' = 'Foo'
Print("$a.b$")
No syntax error
Syntax error: Unexpected input.
Expecting to see the following:
• template-variable-end: "$"
Also, the template does not syntax highlight properly.
Examples:
ForEach
looping over an array of structs, with a Using
on that struct, referencing a variable in that struct in the loop has multiple definitions, one for each definition in the struct in the array.Note: avoid returning multiple definitions that have the same location, since that's not helpful. For example, the definition of a loop variable will be the same for the whole loop.
.Message = '^a'
No error.
Errors:
Syntax error: Unexpected input.
Expecting to see one of the following:
• single-quoted-String-end: "'"
• String-literal (example: "abc")
Created as a result of #48.
.MyVar = 1
.1
, which correctly generates a parse error (Syntax error: Unexpected end of file.
).1
.The error goes away.
The error stays.
This is happening because the parse data for the document after step 1 of the repro is cached, along with the document content that generated that data. Step 2 does not change the cache. Step 3 then sees that the document content has not changed, so it early outs.
Exec('MyAlias')
{
}
Exec('MyAlias')
{
}
Target name "MyAlias" already exists at "file:///c%3A/Users/hting/Desktop/fbuild.bff": 1:6 - 1:15.
The same as the actual error, but with the existing definition split out into into a "related information", so the user can easily jump to it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.