Archived
1
0

Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'

This commit is contained in:
Joe Previte
2020-12-15 15:52:33 -07:00
4649 changed files with 1311795 additions and 0 deletions

View File

@ -0,0 +1,2 @@
test/**
cgmanifest.json

View File

@ -0,0 +1,32 @@
{
"registrations": [
{
"component": {
"type": "git",
"git": {
"name": "textmate/groovy.tmbundle",
"repositoryUrl": "https://github.com/textmate/groovy.tmbundle",
"commitHash": "85d8f7c97ae473ccb9473f6c8d27e4ec957f4be1"
}
},
"licenseDetail": [
"Copyright (c) textmate-groovy.tmbundle project authors",
"",
"If not otherwise specified (see below), files in this repository fall under the following license:",
"",
"Permission to copy, use, modify, sell and distribute this",
"software is granted. This software is provided \"as is\" without",
"express or implied warranty, and with no claim as to its",
"suitability for any purpose.",
"",
"An exception is made for files in readable text which contain their own license information,",
"or files where an accompanying file exists (in the same directory) with a \"-license\" suffix added",
"to the base-name name of the original file, and an extension of txt, html, or similar. For example",
"\"tidy\" is accompanied by \"tidy-license.txt\"."
],
"license": "TextMate Bundle License",
"version": "0.0.0"
}
],
"version": 1
}

View File

@ -0,0 +1,25 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] }
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}

View File

@ -0,0 +1,32 @@
{
"name": "groovy",
"displayName": "%displayName%",
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": { "vscode": "*" },
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js textmate/groovy.tmbundle Syntaxes/Groovy.tmLanguage ./syntaxes/groovy.tmLanguage.json"
},
"contributes": {
"languages": [{
"id": "groovy",
"aliases": ["Groovy", "groovy"],
"extensions": [".groovy", ".gvy", ".gradle", ".jenkinsfile", ".nf"],
"filenames": [ "Jenkinsfile" ],
"filenamePatterns": ["Jenkinsfile.*"],
"firstLine": "^#!.*\\bgroovy\\b",
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "groovy",
"scopeName": "source.groovy",
"path": "./syntaxes/groovy.tmLanguage.json"
}],
"snippets": [{
"language": "groovy",
"path": "./snippets/groovy.code-snippets"
}]
}
}

View File

@ -0,0 +1,4 @@
{
"displayName": "Groovy Language Basics",
"description": "Provides snippets, syntax highlighting and bracket matching in Groovy files."
}

View File

@ -0,0 +1,226 @@
{
"replace(dir: …, includes: …, token: …, value: …)": {
"prefix": "replace",
"body": "replace(dir:\"${1:dirName}\", includes:\"${2:*.*}\", token:\"${3:tokenName}\", value:\"\\${${4:value}}\")$0",
"description": "Replace(...)"
},
"Doc Block": {
"prefix": "doc",
"body": [
"/**",
" * $0",
" */"
],
"description": "Doc block comment"
},
"key: \"value\" (Hash Pair)": {
"prefix": "key",
"body": "${1:key}: ${2:\"${3:value}\"}"
},
"Thread.start { … }": {
"prefix": "thread",
"body": [
"Thread.start {",
"\t$0",
"}"
],
"description": "Thread.start { ... }"
},
"Thread.startDaemon { … }": {
"prefix": "thread",
"body": [
"Thread.startDaemon {",
"\t$0",
"}"
],
"description": "Thread.startDaemon { ... }"
},
"case … break": {
"prefix": "case",
"body": [
"case ${1:CASE_NAME}:",
"\t$2",
"break$0"
],
"description": "case ... break"
},
"instance … (Singleton)": {
"prefix": "instance",
"body": [
"private static $1 instance",
"",
"static $1 getInstance(${2:args}) { ",
"\tif (!instance) instance = new $1(${2:args})",
"\treturn instance",
"}"
],
"description": "Singleton instance + Getter"
},
"class … extends GroovyTestCase { … }": {
"prefix": "tc",
"body": [
"class $1 extends GroovyTestCase {",
"",
"\t$0",
"}"
],
"description": "GroovyTestCase class"
},
"copy(file: …, tofile: …) ": {
"prefix": "copy",
"body": "copy(file:\"${1:sourceFile}\", tofile:\"${2:targetFile}\")",
"description": "Copy file"
},
"copy(todir: …) { fileset(dir: …) { include … exclude }": {
"prefix": "copy",
"body": [
"copy(todir:\"${1:targetDir}\") {",
"\tfileset(dir:\"${2:sourceDir}\") {",
"\t\tinclude(name:\"${3:includeName}\")",
"\t\texclude(name:\"${4:excludeName}\")",
"\t}",
"}"
],
"description": "Copy fileset todir w/ include/exclude"
},
"copy(todir: …) { fileset:dir …) }": {
"prefix": "copy",
"body": [
"copy(todir:\"${1:targetDir}\") {",
"\tfileset(dir:\"${2:sourceDir}\")",
"}"
],
"description": "Copy fileset todir"
},
"closure = { … } ": {
"prefix": "cv",
"body": [
"def ${1:closureName} = { ${2:args} ->",
"\t$0",
"}"
],
"description": "Closure block"
},
"for(… in …) { … }": {
"prefix": "forin",
"body": [
"for (${1:element} in ${2:collection}) {",
"\t$0",
"}"
],
"description": "For-loop"
},
"mkdir(dir: …)": {
"prefix": "mkdir",
"body": "mkdir(dir:\"${1:dirName}\")",
"description": "mkdir"
},
"print": {
"prefix": "p",
"body": "print $0",
"description": "print"
},
"println ": {
"prefix": "pl",
"body": "println $0",
"description": "println"
},
"runAfter() { … }": {
"prefix": "runa",
"body": [
"runAfter(${1:delay}) {",
"\t$0",
"}"
],
"description": "runAfter() { ... }"
},
"setUp() { … }": {
"prefix": "setup",
"body": [
"void setUp() {",
"\t$0",
"}"
],
"description": "setup() { ... }"
},
"sleep(secs) { … // on interrupt do }": {
"prefix": "sleep",
"body": [
"sleep(${1:secs}) {",
"\t${2:// on interrupt do}",
"}"
],
"description": "sleep with interrupt"
},
"sleep(secs)": {
"prefix": "sleep",
"body": "sleep(${1:secs})",
"description": "sleep"
},
"sort { … }": {
"prefix": "sort",
"body": [
"sort { ",
"\t$0",
"}"
],
"description": "sort"
},
"static main() { … }": {
"prefix": "main",
"body": [
"static main(args) {",
"\t$0",
"}"
],
"description": "main method"
},
"switch … case": {
"prefix": "switch",
"body": [
"switch(${1:value}) {",
"\tcase ${2:CASE}:",
"\t\t$3",
"\tbreak$0",
"}"
],
"description": "Switch-Case block"
},
"switch … case … default": {
"prefix": "switch",
"body": [
"switch(${1:value}) {",
"\tcase ${3:CASE}:",
"\t\t$4",
"\tbreak$0",
"\tdefault:",
"\t\t$2",
"\tbreak",
"}"
],
"description": "Switch-Case-Default block"
},
"tearDown() { … }": {
"prefix": "tear",
"body": [
"void tearDown() {",
"\t$0",
"}"
],
"description": "tearDown() { ... }"
},
"test()": {
"prefix": "t",
"body": [
"void test$1() {",
"\t$0",
"}"
],
"description": "test method"
},
"var": {
"prefix": "v",
"body": "${1:def} ${2:var}${3: = ${0:null}}",
"description": "var"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,219 @@
// Hello World
println "Hello world!"
/*
Variables:
You can assign values to variables for later use
*/
def x = 1
println x
x = new java.util.Date()
println x
x = -3.1499392
println x
x = false
println x
x = "Groovy!"
println x
/*
Collections and maps
*/
//Creating an empty list
def technologies = []
/*** Adding a elements to the list ***/
// As with Java
technologies.add("Grails")
// Left shift adds, and returns the list
technologies << "Groovy"
// Add multiple elements
technologies.addAll(["Gradle","Griffon"])
/*** Removing elements from the list ***/
// As with Java
technologies.remove("Griffon")
// Subtraction works also
technologies = technologies - 'Grails'
/*** Iterating Lists ***/
// Iterate over elements of a list
technologies.each { println "Technology: $it"}
technologies.eachWithIndex { it, i -> println "$i: $it"}
/*** Checking List contents ***/
//Evaluate if a list contains element(s) (boolean)
contained = technologies.contains( 'Groovy' )
// Or
contained = 'Groovy' in technologies
// To sort without mutating original, you can do:
sortedTechnologies = technologies.sort( false )
//Replace all elements in the list
Collections.replaceAll(technologies, 'Gradle', 'gradle')
//Shuffle a list
Collections.shuffle(technologies, new Random())
//Clear a list
technologies.clear()
//Creating an empty map
def devMap = [:]
//Add values
devMap = ['name':'Roberto', 'framework':'Grails', 'language':'Groovy']
devMap.put('lastName','Perez')
//Iterate over elements of a map
devMap.each { println "$it.key: $it.value" }
devMap.eachWithIndex { it, i -> println "$i: $it"}
//Evaluate if a map contains a key
assert devMap.containsKey('name')
//Get the keys of a map
println devMap.keySet()
class Foo {
// read only property
final String name = "Roberto"
// read only property with public getter and protected setter
String language
protected void setLanguage(String language) { this.language = language }
// dynamically typed property
def lastName
}
/*
Logical Branching and Looping
*/
//Groovy supports the usual if - else syntax
def x = 3
if(x==1) {
println "One"
} else if(x==2) {
println "Two"
} else {
println "X greater than Two"
}
//Groovy also supports the ternary operator:
def y = 10
def x = (y > 1) ? "worked" : "failed"
assert x == "worked"
//Groovy supports 'The Elvis Operator' too!
//Instead of using the ternary operator:
displayName = user.name ? user.name : 'Anonymous'
//We can write it:
displayName = user.name ?: 'Anonymous'
//For loop
//Iterate over a range
def x = 0
for (i in 0 .. 30) {
x += i
}
//Iterate over a list
x = 0
for( i in [5,3,2,1] ) {
x += i
}
//Iterate over an array
array = (0..20).toArray()
x = 0
for (i in array) {
x += i
}
//Iterate over a map
def map = ['name':'Roberto', 'framework':'Grails', 'language':'Groovy']
x = 0
for ( e in map ) {
x += e.value
}
def technologies = ['Groovy','Grails','Gradle']
technologies*.toUpperCase() // = to technologies.collect { it?.toUpperCase() }
def user = User.get(1)
def username = user?.username
def clos = { println "Hello World!" }
def sum = { a, b -> println a+b }
sum(2,4)
def x = 5
def multiplyBy = { num -> num * x }
println multiplyBy(10)
def clos = { print it }
clos( "hi" )
def cl = {a, b ->
sleep(3000) // simulate some time consuming processing
a + b
}
mem = cl.memoize()
def callClosure(a, b) {
def start = System.currentTimeMillis()
mem(a, b)
println "Inputs(a = $a, b = $b) - took ${System.currentTimeMillis() - start} msecs."
}
callClosure(1, 2)
//Another example:
import groovy.transform.TypeChecked
@TypeChecked
Integer test() {
Integer num = "1"
Integer[] numbers = [1,2,3,4]
Date date = numbers[1]
return "Test"
}
//CompileStatic example:
import groovy.transform.CompileStatic
@CompileStatic
int sum(int x, int y) {
x + y
}
assert sum(2,5) == 7

File diff suppressed because it is too large Load Diff