An extension to provide Gradle language support for Visual Studio Code, including advanced functionalities like Syntax Highlighting, Keyword Auto-completion Proposals and Duplication Validation.
Homepage: Visual Studio Code Marketplace
The extension observes all .gradle documents and uses the server to provide validation and auto-completion proposals (IntelliSense).
The code for the extension is in the client folder, which uses the vscode-languageclient node module to launch the language server.
The language server is located in the server folder.
The tests are located in the test folder.
- The extension converts the sublime-gradle's TextMate grammar configuration for Gradle language.
The extension automatically detects the Java and Android plugin used in the Gradle scripts, then propose keywords smartly in different situations depending on the position of the cursor:
-
Inside a line with existing code:
-
At the start of a word:
- Particularly, after the
applymethod, propose the parameters for plugin application.
-
In a Task Container's constructor:
- At the start of a parameter, propose Task Container's constructor parameters.
- Particularly, after the
typeparameter, propose Task's default types.
- Particularly, after the
dependsOnparameter, propose other Tasks names.
- Particularly, after the
TaskDependencymethods (i.e.dependsOn,finalizedBy,mustRunAfterandshouldRunAfter), propose other Tasks names.
-
Elsewhere, propose the Delegate Object together with its properties and methods.
- Particularly, after the
-
After an entity's dot inside a line with existing code, propose the properties and methods of this entity.
-
-
At the start of a new line:
- On the root level of the build script, propose the properties and methods of the current script's Delegate Object.
- Particularly, in a
TaskContainer, analyze the task's type and propose the properties and methods according to this type.
- In a script block of
NamedDomainObjectContainer, such asBuildTypes,ProductFlavors,SigningConfigsandAndroidSourceSets, DO NOT override default keywords and let the user decide the name for each item.
- In a configure closure of an item within a
NamedDomainObjectContainer, propose the properties and methods of this container's element type.
- In a script block of a general property or method, propose the properties and methods of this script block.
- The extension automatically validates the script under editing and warns the user about duplicated script blocks.
- Download and install Visual Studio Code.
- Download and install Node.js.
- Pull the repo and
cdto the root directory. - Run
npm installto initialize the extension and the server. - Run
npm run compilein the terminal to compile the extension and the server. - Open the root folder in Visual Studio Code, then set the
Preferences -> Color ThemetoDark+ (default dark). - In the Debug viewlet, run
Launch Clientfrom drop-down menu (or pressF5) to launch the extension and attach to the extension. - Create and open a file
build.gradleand type'app'into it. You should see keywords proposed including'apply'.
- In the Debug viewlet, run
Attach to Serverlaunch config and set breakpoints in the client or the server.
- In the Debug viewlet, run
Launch Unit Testsfrom drop-down menu to run the unit tests.
- Syntax highlighting doesn't always work consistently with task constructor with parameters in parentheses, i.e.
task foo(type: Bar) {...}andtask foo {...}













