Skip to content

Commit

Permalink
Use standalone language server (#263)
Browse files Browse the repository at this point in the history
* Use standalone language server

* fix

* work

* suites work

* suites work

* work

* work

* Test format range

* lint

* work

* format range suites

* cleanup

* work

* Work on Mac

* schema validation tests

* fix suites

* fixes

* fix tree tests

* Fix colorization suites

* Fix more tests

* work on functional tests

* fix launch.json

* Working on expressions functional tests

* Expression suites

* Expression suites

* lint

* Change diagnostics source

* Fix lang server path

* Fix suites

* arrow functions

* Simplify output of colorization tests

* fix colorization results

* orphaned files

* Fix #250, strings vs expressions boundary cases

* Fix suite

* Fix suite

* fix suite

* Increase timeout again

work

* fix

* Update ui

* lint

* Fix path check

* PR fix

* Disable lang server tests for now

* Lang conf file must be copied to dist (#276)

* Lang conf file must be copied to dist

* PR fix

* Acquire .dotnet core and search further in file for schema

* Fix build, suites

* Improve language server error handling (#282)

* Always validate file if langid=ARM (#285)

* Always validate file if langid=ARM

* refactor

* Show warnings about --wait-for-debugger and custom lang serve path (#286)

* Clarify licensing for public repo, update version/readme/changelog for 0.7.0 (#283)

* Remove EULA (handled by LICENSE.md)

* Clarify licensing in README.md

* Bump version, update changelog/readme

* Additional changes

* grammar

* Acquire language server binaries during build (#289)

* Acquire language server binaries during build

* Update to get threading fix

* PR fix

* comment

* Fixes

* IMprove message

* Improve message
  • Loading branch information
StephenWeatherford authored Sep 17, 2019
1 parent 36779c4 commit 8165079
Show file tree
Hide file tree
Showing 127 changed files with 6,092 additions and 1,371 deletions.
16 changes: 16 additions & 0 deletions .azure-pipelines/common/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
steps:

# Install nuget for use by 'npm run package'
- task: NuGetToolInstaller@0
inputs:
versionSpec: '5.2.0'

- task: NodeTool@0
displayName: 'Use Node 8.x'
inputs:
Expand All @@ -7,6 +13,16 @@ steps:
- task: Npm@1
displayName: 'npm install'

# First package without language server bits (as a test, and if LANGSERVER_NUGET_USERNAME/PASSWORD are not available)
- script: npm run package
displayName: Package without language server (as a test)

- script: npm run package
displayName: Package
env:
LANGSERVER_NUGET_USERNAME: $(LANGSERVER_NUGET_USERNAME)
LANGSERVER_NUGET_PASSWORD: $(LANGSERVER_NUGET_PASSWORD)

- task: Npm@1
displayName: 'Build'
inputs:
Expand Down
1 change: 1 addition & 0 deletions .azure-pipelines/common/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ steps:
SERVICE_PRINCIPAL_SECRET: $(SERVICE_PRINCIPAL_SECRET)
SERVICE_PRINCIPAL_DOMAIN: $(SERVICE_PRINCIPAL_DOMAIN)
DISPLAY: :10 # Only necessary for linux tests
DISABLE_LANGUAGE_SERVER_TESTS: "true" # TODO: remove

- task: PublishTestResults@2
displayName: 'Publish Test Results'
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -299,5 +299,11 @@ dist
test-results.xml

# Colorization test failure diffs
test/**/*.actual
test/*.actual
test/**/*.full-scope-result.txt

# Nuget package downloads
pkgs/**

# Staged language server bits
languageServer/**
17 changes: 9 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"sourceMaps": true,
// outFiles is used for locating generated JavaScript files, see https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_source-maps
"outFiles": [
"${workspaceFolder}/**/*.js"
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: compile",
"env": {
"AZCODE_ARM_IGNORE_BUNDLE": "1",
"DEBUGTELEMETRY": "1",
"DEBUGTELEMETRY": "1", // 1=quiet, verbose=see telemetry in console
"NODE_DEBUG": ""
}
},
Expand All @@ -34,12 +34,13 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/**/*.js"
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: webpack",
"env": {
"DEBUGTELEMETRY": "1",
"NODE_DEBUG": ""
"DEBUGTELEMETRY": "1", // 1=quiet, verbose=see telemetry in console
"NODE_DEBUG": "",
"DEBUG_WEBPACK": ""
}
},
{
Expand All @@ -59,10 +60,10 @@
],
"preLaunchTask": "npm: compile",
"env": {
"AZCODE_ARM_IGNORE_BUNDLE": "1",
"MOCHA_grep": "", // RegExp of tests to run (empty for all)
"AZCODE_ARM_IGNORE_BUNDLE": "1",
"MOCHA_enableTimeouts": "0", // Disable time-outs
"DEBUGTELEMETRY": "1",
"DEBUGTELEMETRY": "1", // 1=quiet, verbose=see telemetry in console
"NODE_DEBUG": ""
}
},
Expand All @@ -85,7 +86,7 @@
"env": {
"MOCHA_grep": "", // RegExp of tests to run (empty for all)
"MOCHA_enableTimeouts": "0", // Disable time-outs
"DEBUGTELEMETRY": "1",
"DEBUGTELEMETRY": "",
"NODE_DEBUG": ""
}
}
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"out": true,
"**/node_modules": true
},
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
Expand Down
8 changes: 1 addition & 7 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"isBackground": true,
"presentation": {
"reveal": "silent"
"reveal": "never"
},
"problemMatcher": "$tsc-watch"
},
Expand All @@ -36,12 +36,6 @@
"script": "watch-grammars",
"problemMatcher": [],
"isBackground": true
},
{
"type": "npm",
"script": "watch",
"problemMatcher": [],
"isBackground": true
}
]
}
4 changes: 4 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ tsd.json
tslint.json
typings/**
webpack.config*
*.vsix
*.zip
pkgs
tools
File renamed without changes
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
# Change Log
All notable changes to the "vscode-azurearmtools" extension will be documented in this file.

## Version 0.7.0 (2019-09-16)
### Added
- 0.7.0 contains the first release of a new language service that we are creating specifically for Azure Resource Manager deployment template files. Up to this point, the extension has been built on top of the built-in VS Code JSON language server. This has caused some problems, including:
1. Deployment templates allow comments, unlike standard JSON files
1. Deployment templates allow multi-line strings
1. Deployment templates use case-insensitive properties
1. Deployment templates have looser type rules, allowing substitutions such as "true" and "false" instead of true and false
1. The large schema files published for Azure resources cause poor validation performance
1. The errors provided by standard JSON validation frequently provide poor suggestions for fixing (due to lack of knowledge of Azure Resource Manager-specific properties such as resource name and apiVersion)

The new language server aims to provide a better experience for deployment template creation and editing by alleviating many of the problems above.
This version addresses points 1-3 above (see [#fixed](#fixed-070) section). We intend to alleviate more of these problems in upcoming versions.
In addition, we are considering other improvements to the experience, such as:
1. Snippets
2. User-defined functions support
3. Copy loops support
If you would like to suggest additional features, or for other comments or problems, please enter a new issue at our [public repo](https://github.com/microsoft/vscode-azurearmtools/issues).

### Fixed<a id="fixed-070"></a>
- Comments are now supported (`//` and `/* */` styles)
- Multi-line strings are now supported
- Schema validation no longer reports false positives because of incorrectly-cased properties
Examples:
```json
"parameters": {
"dnsLabelPrefix": {
"type": "String", << No longer flagged as incorrect
```
```json
"resources": [
{
"type": "microsoft.network/networkInterfaces", << No longer flagged as incorrect
```
- Expressions in property names are not colorized [#225](https://github.com/microsoft/vscode-azurearmtools/issues/225)
- Intellisense completion for parameter object properties defined inside a defaultValue [#124](https://github.com/microsoft/vscode-azurearmtools/issues/124)
- Parameters color not correct if whitespace separates param name from parentheses [#239](https://github.com/microsoft/vscode-azurearmtools/issues/239)
- Does not correctly handle colorization when a string starts with a bracket but does not end with a bracket [#250](https://github.com/microsoft/vscode-azurearmtools/issues/250)

## Version 0.6.0 (2019-04-25)
### Added
- Expressions inside strings are now colorized
Expand Down
Binary file removed EULA.pdf
Binary file not shown.
13 changes: 13 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="WebTools" value="https://devdiv.pkgs.visualstudio.com/_packaging/WebTools/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<WebTools>
<add key="Username" value="$LANGSERVER_NUGET_USERNAME" />
<add key="ClearTextPassword" value="$LANGSERVER_NUGET_PASSWORD" />
</WebTools>
</packageSourceCredentials>
</configuration>
53 changes: 21 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,38 @@
This extension provides language support for Azure Resource Manager deployment templates and template language expressions.

## Features
- Provides a language server that understands Azure Resource Manager deployment template files
- ARM Template Outline view for easy navigation through large templates
- Colorization for Template Language Expressions (TLE)
- IntelliSense for TLE expressions
- Analyze and validate JSON syntax, JSON schema conformance for Azure resources, string expressions and deployment issues
- IntelliSense for string expressions
- [Built-in function names](https://go.microsoft.com/fwlink/?LinkID=733958)
- [Parameter references](https://go.microsoft.com/fwlink/?LinkID=733959)
- [Variable references](https://go.microsoft.com/fwlink/?LinkID=733960)
- [resourceGroup() properties](https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-functions/#resourcegroup)
- [subscription() properties](https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-functions/#subscription)
- Properties of references to variables that are objects
- [Signature help](https://code.visualstudio.com/docs/editor/editingevolved#_parameter-hints) for TLE function parameters
- [Go To Definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition) for variable and parameter references
- [Peek](https://code.visualstudio.com/docs/editor/editingevolved#_peek) for variable and parameter definitions
- Find all references (Shift + F12) for variables and parameters
- Rename all references (F2) for variables and parameters
- [Hover](https://code.visualstudio.com/docs/editor/editingevolved#_hover) for parameter description
- [TLE brace matching](https://code.visualstudio.com/docs/editor/editingevolved#_bracket-matching)
- [Errors](https://code.visualstudio.com/docs/editor/editingevolved#_errors-warnings) for:
- Undefined parameter references
- Undefined variable references
- Unrecognized TLE function names
- [reference() function usage in variable definition](https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-functions/#reference)
- Incorrect number of arguments in TLE functions
- [Warnings](https://code.visualstudio.com/docs/editor/editingevolved#_errors-warnings) for:
- Unused parameters
- Unused variables

## Using comments in JSON

- If you would like to use comments in your template files, you can use the jsonc ("JSON with comments") language mode. Add the following to your user settings in VS code:
- [Signature help](https://code.visualstudio.com/docs/editor/editingevolved#_parameter-hints) for TLE function parameters
- [Go To Definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition) for variable and parameter references
- [Peek](https://code.visualstudio.com/docs/editor/editingevolved#_peek) for variable and parameter definitions
- Find all references (Shift + F12) for variables and parameters
- Rename all references (F2) for variables and parameters
- [Hover](https://code.visualstudio.com/docs/editor/editingevolved#_hover) for parameter description
- [TLE brace matching](https://code.visualstudio.com/docs/editor/editingevolved#_bracket-matching)
- Rename parameters and variables

## Automatic Detection of deployment template files

By default, the extension recognizes a .json or .jsonc file as a deployment template file based on the $schema specified in the file (for instance, ```https://schema.management.azure.com/schemas/2018-05-01/deploymentTemplate.json#```) and will switch the editor language to "ARM Deployment Template" automatically. If you do not want that behavior, you can set the ```armTools.autoDetectJsonTemplates``` setting to false and use the below methods to determine which files to treat as deployment templates.

Besides automatic detection, any file ending with the extension ```.arm``` will be considered a deployment template. You can also use the ```files.associations``` setting to set up your own specific mappings based on specific files paths or patterns to mark them as deployment templates, e.g.

```json
"files.associations": {
// Use the following to allow comments inside .jsonc
// (This will not be necessary after VS Code ships the fix for https://github.com/Microsoft/vscode/issues/48969)
"*.jsonc": "jsonc"

// Use the following to also allow comments inside .json file
// "*.json": "jsonc"
"*.arm.json": "arm-deployment" // Treat these files as deployment templates
}
```

## To Install

Press F1 in VSCode, type "ext install" and then look for "Azure Resource Manager Tools".

## Related Links

- [VS Code Azure Resource Manager snippets and cross platform deployment scripts](https://go.microsoft.com/fwlink/?LinkID=733962)
Expand Down Expand Up @@ -78,4 +65,6 @@ VS Code collects usage data and sends it to Microsoft to help improve our produc

## License

[MIT](LICENSE.md)
The source code in our [public repository](https://github.com/Microsoft/vscode-azurearmtools) is licensed under the [MIT license](LICENSE.md). The public source code currently contains functionality related to the parsing and validation of template expression strings, but does not contain functionality related to JSON parsing and validation or backend template validation.

The extension as it is built in Azure DevOps and [published](https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools) to the VS Code Marketplace is a distribution of the public repository and is bundled with the Azure Resource Manager language service binaries. The published extension and language service binaries are licensed under a traditional Microsoft product license.
49 changes: 49 additions & 0 deletions assets/scripts/determine-linux-distro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
#
# Copyright © Microsoft Corporation
# All rights reserved.
#
# Licensed under the MIT License. See LICENSE-CODE in the project root for details.
#
# Exit codes:
# 0 - Success
# 4 - Distribution not supported by script
#

set H+

#openSUSE - Has to be first since apt-get is available but package names different
if type zypper > /dev/null 2>&1; then
echo "SUSE"
exit 0

# Debian / Ubuntu
elif type apt-get > /dev/null 2>&1; then
echo "Debian"
exit 0

#RHL/Fedora/CentOS
elif type yum > /dev/null 2>&1; then
echo "RedHat"
exit 0

#ArchLinux
elif type pacman > /dev/null 2>&1; then
echo "ArchLinux"
exit 0

#Solus
elif type eopkg > /dev/null 2>&1; then
echo "Solus"
exit 0

#Alpine Linux
elif type apk > /dev/null 2>&1; then
echo "Alpine"
exit 0

# Distro not supported
else
echo "UNKNOWN"
exit 4
fi
2 changes: 2 additions & 0 deletions assets/scripts/dotnet-install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0dotnet-install.ps1' %*; exit $LASTEXITCODE"
Loading

0 comments on commit 8165079

Please sign in to comment.