Skip to content

Commit

Permalink
feat: <java> add implment api supportt
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 4, 2020
1 parent 2301c2e commit f4ba9e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class JavaIdentListener(fileName: String) : JavaParserBaseListener() {

if (ctx.IMPLEMENTS() != null) {
for (_type in ctx.typeList().typeType()) {
val typeText = _type.text
this.buildImplement(typeText)
this.buildImplement(_type.text)
}
}

Expand Down Expand Up @@ -153,8 +152,12 @@ class JavaIdentListener(fileName: String) : JavaParserBaseListener() {
return codeFile.PackageName + "." + currentClz + "." + name + ":" + function.Position.StartLine.toString()
}

private fun buildImplement(typeText: String?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
private fun buildImplement(typeText: String) {
var target = this.warpTargetFullType(typeText)
if (target == "") {
target = typeText
}
currentNode.Implements += target
}

private fun buildExtend(extendName: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ public class HelloWorld {
assertEquals(codeFile.DataStructures[0].Extend, "HasStatic")
}

@Test
internal fun shouldGetImplementName() {
val code = """
class Pig implements Animal {
public void animalSound() {
System.out.println("The pig says: wee wee");
}
public void sleep() {
System.out.println("Zzz");
}
}
"""
val codeFile = JavaIdentApp().analysis(code, "")
assertEquals(codeFile.DataStructures[0].Implements[0], "Animal")
}

@Test
internal fun shouldGetInnerStructureName() {
val code = """
Expand Down

0 comments on commit f4ba9e7

Please sign in to comment.