package gumtree.spoon.builder;

import com.github.gumtreediff.tree.ITree;
import spoon.reflect.code.CtArrayAccess;
import spoon.reflect.code.CtBinaryOperator;
import spoon.reflect.code.CtConstructorCall;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLiteral;
import spoon.reflect.code.CtThisAccess;
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.code.CtUnaryOperator;
import spoon.reflect.code.CtVariableAccess;
import spoon.reflect.declaration.CtModifiable;
import spoon.reflect.declaration.CtNamedElement;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.visitor.CtInheritanceScanner;

/** responsible to add additional nodes
 * only overrides scan* to add new nodes */
class NodeCreator extends CtInheritanceScanner {
	private final TreeScanner builder;

	NodeCreator(TreeScanner builder) {
		this.builder = builder;
	}

	@Override
	public void scanCtModifiable(CtModifiable m) {
		ITree modifiers = builder.createNode("Modifiers", "");
		for (ModifierKind kind : m.getModifiers()) {
			ITree modifier = builder.createNode("Modifier", kind.toString());
			modifier.setMetadata(SpoonGumTreeBuilder.SPOON_OBJECT, m);
			modifiers.addChild(modifier);
		}
		builder.addSiblingNode(modifiers);

	}

	@Override
	public <T> void scanCtVariable(CtVariable<T> e) {
		builder.addSiblingNode(builder.createNode("VARIABLE_TYPE", e.getType().getQualifiedName()));
	}
}

@@ -92,495 +92,32 @@
 ect.
-code.CtArrayAccess;%0Aimport spoon.reflect.code.CtBinaryOperator;%0Aimport spoon.reflect.code.CtConstructorCall;%0Aimport spoon.reflect.code.CtExpression;%0Aimport spoon.reflect.code.CtInvocation;%0Aimport spoon.reflect.code.CtLiteral;%0Aimport spoon.reflect.code.CtThisAccess;%0Aimport spoon.reflect.code.CtTypeAccess;%0Aimport spoon.reflect.code.CtUnaryOperator;%0Aimport spoon.reflect.code.CtVariableAccess;%0Aimport spoon.reflect.declaration.CtModifiable;%0Aimport spoon.reflect.declaration.CtNamedElement
+declaration.CtModifiable
 ;%0Aim
@@ -610,16 +610,78 @@
 %22, %22%22);%0A
+%09%09modifiers.setMetadata(SpoonGumTreeBuilder.SPOON_OBJECT, m);%0A
 %09%09for (M
@@ -993,39 +993,37 @@
  e) %7B%0A%09%09
-builder.addSiblingNode(
+ITree variableType = 
 builder.
@@ -1081,16 +1081,130 @@
 dName())
+;%0A%09%09variableType.setMetadata(SpoonGumTreeBuilder.SPOON_OBJECT, e.getType());%0A%09%09builder.addSiblingNode(variableType
 );%0A%09%7D%0A%7D%0A

define spoon element for type of modifier