mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-18 00:21:35 +00:00
Java Uast: Initial implementation
This commit is contained in:
33
plugins/uast-java/testData/render/ControlStructures.txt
vendored
Normal file
33
plugins/uast-java/testData/render/ControlStructures.txt
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
default class _Dummy_ {
|
||||
default inner class ControlStructures {
|
||||
public fun main(args: java.lang.String[]): void {
|
||||
if (args.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
var mode: String = (args.length === 1) ? ("singleArg") : ("multiArgs")
|
||||
for (arg : args) {
|
||||
System.out.println(arg)
|
||||
}
|
||||
|
||||
for (var i: int = 0; i < args.length; ++i) {
|
||||
System.out.println(i + ": " + args[i])
|
||||
}
|
||||
|
||||
var i: int = 0
|
||||
while (i < args.length) {
|
||||
System.out.println("Index " + i)
|
||||
i++
|
||||
}
|
||||
|
||||
i = 0
|
||||
do {
|
||||
System.out.println(i)
|
||||
i += 1
|
||||
}
|
||||
while (i < args.length)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
17
plugins/uast-java/testData/render/Lambda.txt
vendored
Normal file
17
plugins/uast-java/testData/render/Lambda.txt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
default class _Dummy_ {
|
||||
default inner class Lambda {
|
||||
default fun example(): void {
|
||||
doJob({ arg: String ->
|
||||
arg + arg
|
||||
}, "Mary")
|
||||
}
|
||||
|
||||
default fun doJob(job: Job, arg: String): void {
|
||||
System.out.println(job.doJob(arg))
|
||||
}
|
||||
|
||||
}
|
||||
default abstract interface Job {
|
||||
public fun doJob(arg: String): String = EmptyExpression
|
||||
}
|
||||
}
|
||||
14
plugins/uast-java/testData/render/NestedClasses.txt
vendored
Normal file
14
plugins/uast-java/testData/render/NestedClasses.txt
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
default class _Dummy_ {
|
||||
default inner class NestedClasses {
|
||||
public class Nested {
|
||||
default fun func1(): void {
|
||||
}
|
||||
|
||||
}
|
||||
public inner class Inner {
|
||||
default fun func2(): void {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
plugins/uast-java/testData/render/Simple.txt
vendored
Normal file
18
plugins/uast-java/testData/render/Simple.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
default class _Dummy_ {
|
||||
default inner class Simple {
|
||||
var name: String
|
||||
|
||||
public fun Simple(name: String) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
public fun getName(): String {
|
||||
return name
|
||||
}
|
||||
|
||||
public fun setName(name: String): void {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
68
plugins/uast-java/testData/render/SpecialExpressions.txt
vendored
Normal file
68
plugins/uast-java/testData/render/SpecialExpressions.txt
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
default class _Dummy_ {
|
||||
default inner class SpecialExpressions {
|
||||
default fun test(): boolean {
|
||||
assert 5 > 3 : EmptyExpression
|
||||
assert 5 > 3 : "Message"
|
||||
synchronized this : {
|
||||
System.out.println("A")
|
||||
}
|
||||
|
||||
var a: int = 5
|
||||
var b: int = 7
|
||||
var c: int
|
||||
while (a > 0) {
|
||||
if (a === 3) {
|
||||
break
|
||||
}
|
||||
|
||||
if (a % 5 === 0) {
|
||||
continue
|
||||
}
|
||||
|
||||
a--
|
||||
}
|
||||
|
||||
this.test()
|
||||
super.hashCode()
|
||||
var x: String
|
||||
switch (a)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
x = "1"
|
||||
break
|
||||
}
|
||||
|
||||
case 3:
|
||||
x = "3"
|
||||
case 4:
|
||||
x = "4"
|
||||
else:
|
||||
x = ""
|
||||
}
|
||||
|
||||
|
||||
if (System.getProperty("abc", "").equals("1")) {
|
||||
throw <noref>("Err")
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
finally {
|
||||
a = 3
|
||||
}
|
||||
|
||||
{
|
||||
a = 5
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user