forked from JavaTX/JavaCompilerCore
Implemented converter for FieldModifier.
This commit is contained in:
parent
e9e2d5c27b
commit
cca2da8018
@ -3,7 +3,7 @@ package de.dhbwstuttgart.parser;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.*;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.FieldModifier;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.*;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.methodModifier.MethodModifier;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
@ -264,6 +264,36 @@ public class SyntaxTreeGenerator{
|
||||
return newModifier;
|
||||
}
|
||||
|
||||
private FieldModifier convert(Java8Parser.FieldModifierContext ctx){
|
||||
FieldModifier newModifier = null;
|
||||
if(ctx.annotation() == null){
|
||||
TerminalNode t = (TerminalNode)ctx.getChild(0);
|
||||
if(t.getText().equals("public")){
|
||||
newModifier = new PublicFieldModifier();
|
||||
}
|
||||
else if(t.getText().equals("private")){
|
||||
newModifier = new PrivateFieldModifier();
|
||||
}
|
||||
else if(t.getText().equals("protected")){
|
||||
newModifier = new ProtectedFieldModifier();
|
||||
}
|
||||
else if(t.getText().equals("static")){
|
||||
newModifier = new StaticFieldModifier();
|
||||
}
|
||||
else if(t.getText().equals("transient")){
|
||||
newModifier = new Transient();
|
||||
}
|
||||
else if(t.getText().equals("volatile")){
|
||||
newModifier = new Volatile();
|
||||
}
|
||||
else{
|
||||
newModifier = new FinalFieldModifier();
|
||||
}
|
||||
}
|
||||
return newModifier;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Converts a TerminalNode to JavaClassName. If pkgName is set, it will be included like expected.
|
||||
**/
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
|
||||
|
||||
public class Final implements FieldModifier
|
||||
public class FinalFieldModifier implements FieldModifier
|
||||
{
|
||||
|
||||
public short getBitmask()
|
@ -1,6 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
|
||||
|
||||
public class Public implements FieldModifier
|
||||
public class PrivateFieldModifier implements FieldModifier
|
||||
{
|
||||
|
||||
public short getBitmask()
|
@ -0,0 +1,11 @@
|
||||
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
|
||||
|
||||
public class ProtectedFieldModifier implements FieldModifier
|
||||
{
|
||||
|
||||
public short getBitmask()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
|
||||
|
||||
public class Private implements FieldModifier
|
||||
public class PublicFieldModifier implements FieldModifier
|
||||
{
|
||||
|
||||
public short getBitmask()
|
@ -1,11 +0,0 @@
|
||||
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
|
||||
|
||||
public class Static implements FieldModifier
|
||||
{
|
||||
|
||||
public short getBitmask()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
|
||||
|
||||
public class Protected implements FieldModifier
|
||||
public class StaticFieldModifier implements FieldModifier
|
||||
{
|
||||
|
||||
public short getBitmask()
|
Loading…
Reference in New Issue
Block a user