| @@ -0,0 +1,220 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.internal.core.PHPVersion; | ||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
| import org2.eclipse.php.internal.core.compiler.ast.nodes.ASTNodeKinds; | ||
|
|
||
| public class ChainingInstanceCall extends Expression { | ||
|
|
||
| private PHPArrayDereferenceList arrayDereferenceList; | ||
| // private ASTNode.NodeList<VariableBase> chainingMethodOrProperty = new | ||
| // ASTNode.NodeList<VariableBase>( | ||
| // CHAINING_METHOD_OR_PROPERTY); | ||
| private List<VariableBase> chainingMethodOrProperty = new LinkedList<VariableBase>(); | ||
|
|
||
| public static final ChildPropertyDescriptor ARRAY_DEREFERENCE_LIST = new ChildPropertyDescriptor( | ||
| ChainingInstanceCall.class, | ||
| "arrayDereferenceList", PHPArrayDereferenceList.class, OPTIONAL, CYCLE_RISK); //$NON-NLS-1$ | ||
| // public static final ChildListPropertyDescriptor | ||
| // CHAINING_METHOD_OR_PROPERTY = new ChildListPropertyDescriptor( | ||
| // ChainingInstanceCall.class, | ||
| // "chainingMethodOrProperty", VariableBase.class, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * A list of property descriptors (element type: | ||
| * {@link StructuralPropertyDescriptor}), or null if uninitialized. | ||
| */ | ||
| private static final List<StructuralPropertyDescriptor> PROPERTY_DESCRIPTORS; | ||
|
|
||
| static { | ||
| List<StructuralPropertyDescriptor> propertyList = new ArrayList<StructuralPropertyDescriptor>( | ||
| 1); | ||
| propertyList.add(ARRAY_DEREFERENCE_LIST); | ||
| // propertyList.add(CHAINING_METHOD_OR_PROPERTY); | ||
| PROPERTY_DESCRIPTORS = Collections.unmodifiableList(propertyList); | ||
| } | ||
|
|
||
| public ChainingInstanceCall(int start, int end, AST ast, | ||
| PHPArrayDereferenceList arrayDereferenceList, | ||
| List<VariableBase> chainingMethodOrProperty) { | ||
| super(start, end, ast); | ||
|
|
||
| this.arrayDereferenceList = arrayDereferenceList; | ||
| if (chainingMethodOrProperty != null) { | ||
| this.chainingMethodOrProperty.addAll(chainingMethodOrProperty); | ||
| } | ||
| } | ||
|
|
||
| public ChainingInstanceCall(AST ast, | ||
| PHPArrayDereferenceList arrayDereferenceList, | ||
| List<VariableBase> chainingMethodOrProperty) { | ||
| super(ast); | ||
|
|
||
| setArrayDereferenceList(arrayDereferenceList); | ||
| if (chainingMethodOrProperty != null) { | ||
| this.chainingMethodOrProperty.addAll(chainingMethodOrProperty); | ||
| } | ||
| } | ||
|
|
||
| public List<VariableBase> getChainingMethodOrProperty() { | ||
| return chainingMethodOrProperty; | ||
| } | ||
|
|
||
| public void setChainingMethodOrProperty( | ||
| ASTNode.NodeList<VariableBase> chainingMethodOrProperty) { | ||
| this.chainingMethodOrProperty = chainingMethodOrProperty; | ||
| } | ||
|
|
||
| public void setArrayDereferenceList( | ||
| PHPArrayDereferenceList arrayDereferenceList) { | ||
| ASTNode oldChild = this.arrayDereferenceList; | ||
| preReplaceChild(oldChild, arrayDereferenceList, ARRAY_DEREFERENCE_LIST); | ||
| this.arrayDereferenceList = arrayDereferenceList; | ||
| postReplaceChild(oldChild, arrayDereferenceList, ARRAY_DEREFERENCE_LIST); | ||
| } | ||
|
|
||
| public PHPArrayDereferenceList getArrayDereferenceList() { | ||
| return arrayDereferenceList; | ||
| } | ||
|
|
||
| public int getKind() { | ||
| return ASTNodeKinds.USE_STATEMENT; | ||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
|
|
||
| public void childrenAccept(Visitor visitor) { | ||
| if (arrayDereferenceList != null) { | ||
|
|
||
| arrayDereferenceList.accept(visitor); | ||
| } | ||
| if (chainingMethodOrProperty != null) { | ||
| for (VariableBase variableBase : chainingMethodOrProperty) { | ||
| variableBase.accept(visitor); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public void traverseTopDown(Visitor visitor) { | ||
| accept(visitor); | ||
| if (arrayDereferenceList != null) { | ||
|
|
||
| arrayDereferenceList.traverseTopDown(visitor); | ||
| } | ||
| if (chainingMethodOrProperty != null) { | ||
| for (VariableBase variableBase : chainingMethodOrProperty) { | ||
| variableBase.traverseTopDown(visitor); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void traverseBottomUp(Visitor visitor) { | ||
| if (arrayDereferenceList != null) { | ||
|
|
||
| arrayDereferenceList.traverseBottomUp(visitor); | ||
| } | ||
| if (chainingMethodOrProperty != null) { | ||
| for (VariableBase variableBase : chainingMethodOrProperty) { | ||
| variableBase.traverseBottomUp(visitor); | ||
| } | ||
| } | ||
| accept(visitor); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<ChainingInstanceCall"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| // buffer.append(TAB).append(tab).append("<arrayDereferenceList>\n"); //$NON-NLS-1$ | ||
| if (arrayDereferenceList != null) { | ||
| buffer.append(TAB).append(tab) | ||
| .append("<PHPArrayDereferenceList>\n"); //$NON-NLS-1$ | ||
| arrayDereferenceList.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(TAB).append(tab).append("</PHPArrayDereferenceList>"); //$NON-NLS-1$ | ||
| } | ||
| if (chainingMethodOrProperty != null) { | ||
| buffer.append(TAB).append(tab) | ||
| .append("<ChainingMethodOrProperty>\n"); //$NON-NLS-1$ | ||
| for (VariableBase variableBase : chainingMethodOrProperty) { | ||
| variableBase.toString(buffer, TAB + TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(TAB).append(tab) | ||
| .append("</ChainingMethodOrProperty>"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</ChainingInstanceCall>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| public int getType() { | ||
| return ASTNode.FUNCTION_NAME; | ||
| } | ||
|
|
||
| /* | ||
| * Method declared on ASTNode. | ||
| */ | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| // dispatch to correct overloaded match method | ||
| return matcher.match(this, other); | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| PHPArrayDereferenceList arrayDereferenceList = ASTNode.copySubtree( | ||
| target, getArrayDereferenceList()); | ||
|
|
||
| final List<VariableBase> chainingMethodOrProperty = ASTNode | ||
| .copySubtrees(target, getChainingMethodOrProperty()); | ||
| final ChainingInstanceCall result = new ChainingInstanceCall( | ||
| this.getStart(), this.getEnd(), target, arrayDereferenceList, | ||
| chainingMethodOrProperty); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| List<StructuralPropertyDescriptor> internalStructuralPropertiesForType( | ||
| PHPVersion apiLevel) { | ||
| return PROPERTY_DESCRIPTORS; | ||
| } | ||
|
|
||
| /* | ||
| * (omit javadoc for this method) Method declared on ASTNode. | ||
| */ | ||
| final List internalGetChildListProperty(ChildListPropertyDescriptor property) { | ||
| // if (property == CHAINING_METHOD_OR_PROPERTY) { | ||
| // return getChainingMethodOrProperty(); | ||
| // } | ||
| // allow default implementation to flag the error | ||
| return super.internalGetChildListProperty(property); | ||
| } | ||
|
|
||
| final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, | ||
| boolean get, ASTNode child) { | ||
| if (property == ARRAY_DEREFERENCE_LIST) { | ||
| if (get) { | ||
| return getArrayDereferenceList(); | ||
| } else { | ||
| setArrayDereferenceList((PHPArrayDereferenceList) child); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // allow default implementation to flag the error | ||
| return super.internalGetSetChildProperty(property, get, child); | ||
| } | ||
|
|
||
| } |
| @@ -1,14 +1,3 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| @@ -0,0 +1,173 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.internal.core.PHPVersion; | ||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| public class FullyQualifiedTraitMethodReference extends Expression { | ||
|
|
||
| private NamespaceName className; | ||
| private Identifier functionName; | ||
|
|
||
| public static final ChildPropertyDescriptor CLASS_NAME = new ChildPropertyDescriptor( | ||
| FullyQualifiedTraitMethodReference.class, | ||
| "className", NamespaceName.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$ | ||
| public static final ChildPropertyDescriptor FUNCTION_NAME = new ChildPropertyDescriptor( | ||
| FullyQualifiedTraitMethodReference.class, | ||
| "functionName", Identifier.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * A list of property descriptors (element type: | ||
| * {@link StructuralPropertyDescriptor}), or null if uninitialized. | ||
| */ | ||
| private static final List<StructuralPropertyDescriptor> PROPERTY_DESCRIPTORS; | ||
|
|
||
| static { | ||
| List<StructuralPropertyDescriptor> propertyList = new ArrayList<StructuralPropertyDescriptor>( | ||
| 1); | ||
| propertyList.add(CLASS_NAME); | ||
| propertyList.add(FUNCTION_NAME); | ||
| PROPERTY_DESCRIPTORS = Collections.unmodifiableList(propertyList); | ||
| } | ||
|
|
||
| public FullyQualifiedTraitMethodReference(int start, int end, AST ast, | ||
| NamespaceName className, Identifier functionName) { | ||
| super(start, end, ast); | ||
| setClassName(className); | ||
| setFunctionName(functionName); | ||
| } | ||
|
|
||
| public FullyQualifiedTraitMethodReference(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| public NamespaceName getClassName() { | ||
| return className; | ||
| } | ||
|
|
||
| public void setClassName(NamespaceName className) { | ||
| if (className == null) { | ||
| throw new IllegalArgumentException(); | ||
| } | ||
|
|
||
| ASTNode oldChild = this.className; | ||
| preReplaceChild(oldChild, className, CLASS_NAME); | ||
| this.className = className; | ||
| postReplaceChild(oldChild, className, CLASS_NAME); | ||
| } | ||
|
|
||
| public Identifier getFunctionName() { | ||
| return functionName; | ||
| } | ||
|
|
||
| public void setFunctionName(Identifier functionName) { | ||
| ASTNode oldChild = this.functionName; | ||
| preReplaceChild(oldChild, functionName, FUNCTION_NAME); | ||
| this.functionName = functionName; | ||
| postReplaceChild(oldChild, functionName, FUNCTION_NAME); | ||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
|
|
||
| public void childrenAccept(Visitor visitor) { | ||
| className.accept(visitor); | ||
| functionName.accept(visitor); | ||
|
|
||
| } | ||
|
|
||
| public void traverseTopDown(Visitor visitor) { | ||
| accept(visitor); | ||
| className.traverseTopDown(visitor); | ||
| functionName.traverseTopDown(visitor); | ||
| } | ||
|
|
||
| public void traverseBottomUp(Visitor visitor) { | ||
| className.traverseBottomUp(visitor); | ||
| functionName.traverseBottomUp(visitor); | ||
| accept(visitor); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<FunctionName"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(" functionName='").append(functionName.getName()) | ||
| .append("'"); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| className.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</FunctionName>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| public int getType() { | ||
| return ASTNode.FULLY_QUALIFIED_TRAIT_METHOD_REFERENCE; | ||
| } | ||
|
|
||
| /* | ||
| * Method declared on ASTNode. | ||
| */ | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| // dispatch to correct overloaded match method | ||
| return matcher.match(this, other); | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| NamespaceName className = ASTNode.copySubtree(target, getClassName()); | ||
| final FullyQualifiedTraitMethodReference result = new FullyQualifiedTraitMethodReference( | ||
| this.getStart(), this.getEnd(), target, className, functionName); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| List<StructuralPropertyDescriptor> internalStructuralPropertiesForType( | ||
| PHPVersion apiLevel) { | ||
| return PROPERTY_DESCRIPTORS; | ||
| } | ||
|
|
||
| // @Override | ||
| // Object internalGetSetObjectProperty(SimplePropertyDescriptor property, | ||
| // boolean get, Object value) { | ||
| // if (property == FUNCTION_NAME) { | ||
| // if (get) { | ||
| // return getFunctionName(); | ||
| // } else { | ||
| // setFunctionName((String) value); | ||
| // return null; | ||
| // } | ||
| // } | ||
| // return super.internalGetSetObjectProperty(property, get, value); | ||
| // } | ||
|
|
||
| final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, | ||
| boolean get, ASTNode child) { | ||
| if (property == CLASS_NAME) { | ||
| if (get) { | ||
| return getClassName(); | ||
| } else { | ||
| setClassName((NamespaceName) child); | ||
| return null; | ||
| } | ||
| } else if (property == FUNCTION_NAME) { | ||
| if (get) { | ||
| return getFunctionName(); | ||
| } else { | ||
| setFunctionName((Identifier) child); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // allow default implementation to flag the error | ||
| return super.internalGetSetChildProperty(property, get, child); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,5 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| public interface MethodStub { | ||
|
|
||
| } |
| @@ -0,0 +1,10 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class ParameterAndDereferenceList { | ||
|
|
||
| public List parameterList; | ||
| public PHPArrayDereferenceList arrayDereferenceList; | ||
|
|
||
| } |
| @@ -0,0 +1,228 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.core.compiler.PHPFlags; | ||
| import org2.eclipse.php.internal.core.PHPVersion; | ||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| public class TraitAlias extends Expression { | ||
|
|
||
| // TODO need modifier start offset,change functionName to scalar | ||
| public TraitAlias(int start, int end, AST ast, Expression traitMethod, | ||
| int modifier, int modifierOffset, Identifier functionName) { | ||
| super(start, end, ast); | ||
| setTraitMethod(traitMethod); | ||
| setModifier(modifier); | ||
| setModifierOffset(modifierOffset); | ||
| setFunctionName(functionName); | ||
| } | ||
|
|
||
| public TraitAlias(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| private Expression traitMethod; | ||
| private int modifier; | ||
| private int modifierOffset; | ||
|
|
||
| /** | ||
| * functionName could be null | ||
| */ | ||
| private Identifier functionName; | ||
|
|
||
| public static final ChildPropertyDescriptor TRAIT_METHOD = new ChildPropertyDescriptor( | ||
| TraitAlias.class, | ||
| "traitMethod", Expression.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$ | ||
| public static final SimplePropertyDescriptor MODIFIER = new SimplePropertyDescriptor( | ||
| TraitAlias.class, "modifier", Integer.class, OPTIONAL); //$NON-NLS-1$ | ||
| public static final ChildPropertyDescriptor FUNCTION_NAME = new ChildPropertyDescriptor( | ||
| TraitAlias.class, | ||
| "functionName", Identifier.class, OPTIONAL, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * A list of property descriptors (element type: | ||
| * {@link StructuralPropertyDescriptor}), or null if uninitialized. | ||
| */ | ||
| private static final List<StructuralPropertyDescriptor> PROPERTY_DESCRIPTORS; | ||
|
|
||
| static { | ||
| List<StructuralPropertyDescriptor> propertyList = new ArrayList<StructuralPropertyDescriptor>( | ||
| 1); | ||
| propertyList.add(TRAIT_METHOD); | ||
| propertyList.add(MODIFIER); | ||
| propertyList.add(FUNCTION_NAME); | ||
| PROPERTY_DESCRIPTORS = Collections.unmodifiableList(propertyList); | ||
| } | ||
|
|
||
| public Expression getTraitMethod() { | ||
| return traitMethod; | ||
| } | ||
|
|
||
| public void setTraitMethod(Expression traitMethod) { | ||
| if (traitMethod == null) { | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| ASTNode oldChild = this.traitMethod; | ||
| preReplaceChild(oldChild, traitMethod, TRAIT_METHOD); | ||
| this.traitMethod = traitMethod; | ||
| postReplaceChild(oldChild, traitMethod, TRAIT_METHOD); | ||
| } | ||
|
|
||
| public int getModifier() { | ||
| return modifier; | ||
| } | ||
|
|
||
| public void setModifier(int modifier) { | ||
| preValueChange(MODIFIER); | ||
| this.modifier = modifier; | ||
| postValueChange(MODIFIER); | ||
| } | ||
|
|
||
| public int getModifierOffset() { | ||
| return modifierOffset; | ||
| } | ||
|
|
||
| public void setModifierOffset(int modifierOffset) { | ||
| this.modifierOffset = modifierOffset; | ||
| } | ||
|
|
||
| public Identifier getFunctionName() { | ||
| return functionName; | ||
| } | ||
|
|
||
| public void setFunctionName(Identifier functionName) { | ||
| ASTNode oldChild = this.functionName; | ||
| preReplaceChild(oldChild, functionName, FUNCTION_NAME); | ||
| this.functionName = functionName; | ||
| postReplaceChild(oldChild, functionName, FUNCTION_NAME); | ||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
|
|
||
| public void childrenAccept(Visitor visitor) { | ||
| traitMethod.accept(visitor); | ||
| if (functionName != null) { | ||
| functionName.accept(visitor); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public void traverseTopDown(Visitor visitor) { | ||
| accept(visitor); | ||
| traitMethod.traverseTopDown(visitor); | ||
| if (functionName != null) { | ||
| functionName.traverseTopDown(visitor); | ||
| } | ||
| } | ||
|
|
||
| public void traverseBottomUp(Visitor visitor) { | ||
| traitMethod.traverseBottomUp(visitor); | ||
| if (functionName != null) { | ||
| functionName.traverseBottomUp(visitor); | ||
| } | ||
| accept(visitor); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitAlias"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| if (functionName != null) { | ||
| buffer.append(" functionName='").append(functionName.getName()).append("' "); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(" modifier='").append(PHPFlags.toString(modifier)).append("'>\n"); //$NON-NLS-1$ //$NON-NLS-2$ | ||
| traitMethod.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</TraitAlias>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| public int getType() { | ||
| return ASTNode.FUNCTION_NAME; | ||
| } | ||
|
|
||
| /* | ||
| * Method declared on ASTNode. | ||
| */ | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| // dispatch to correct overloaded match method | ||
| return matcher.match(this, other); | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| Expression traitMethod = ASTNode.copySubtree(target, getTraitMethod()); | ||
| Identifier functionName = ASTNode | ||
| .copySubtree(target, getFunctionName()); | ||
| final TraitAlias result = new TraitAlias(this.getStart(), | ||
| this.getEnd(), target, traitMethod, modifier, modifierOffset, | ||
| functionName); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| List<StructuralPropertyDescriptor> internalStructuralPropertiesForType( | ||
| PHPVersion apiLevel) { | ||
| return PROPERTY_DESCRIPTORS; | ||
| } | ||
|
|
||
| // @Override | ||
| // Object internalGetSetObjectProperty(SimplePropertyDescriptor property, | ||
| // boolean get, Object value) { | ||
| // if (property == FUNCTION_NAME) { | ||
| // if (get) { | ||
| // return getFunctionName(); | ||
| // } else { | ||
| // setFunctionName((String) value); | ||
| // return null; | ||
| // } | ||
| // } | ||
| // return super.internalGetSetObjectProperty(property, get, value); | ||
| // } | ||
|
|
||
| @Override | ||
| int internalGetSetIntProperty(SimplePropertyDescriptor property, | ||
| boolean get, int value) { | ||
| if (property == MODIFIER) { | ||
| if (get) { | ||
| return getModifier(); | ||
| } else { | ||
| int oldValue = getModifier(); | ||
| setModifier(value); | ||
| return oldValue; | ||
| } | ||
| } | ||
| return super.internalGetSetIntProperty(property, get, value); | ||
| } | ||
|
|
||
| final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, | ||
| boolean get, ASTNode child) { | ||
| if (property == TRAIT_METHOD) { | ||
| if (get) { | ||
| return getTraitMethod(); | ||
| } else { | ||
| setTraitMethod((Expression) child); | ||
| return null; | ||
| } | ||
| } else if (property == FUNCTION_NAME) { | ||
| if (get) { | ||
| return getFunctionName(); | ||
| } else { | ||
| setFunctionName((Identifier) child); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // allow default implementation to flag the error | ||
| return super.internalGetSetChildProperty(property, get, child); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,59 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| public class TraitAliasStatement extends TraitStatement { | ||
| private TraitAlias alias; | ||
|
|
||
| public TraitAliasStatement(int start, int end, AST ast, TraitAlias alias) { | ||
| super(start, end, ast, alias); | ||
| this.alias = alias; | ||
| } | ||
|
|
||
| public TraitAliasStatement(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| public TraitAlias getAlias() { | ||
| return alias; | ||
| } | ||
|
|
||
| public void setAlias(TraitAlias alias) { | ||
| super.setExp(alias); | ||
| this.alias = alias; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| if (!(other instanceof TraitAliasStatement)) { | ||
| return false; | ||
| } | ||
| return super.subtreeMatch(matcher, other); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitAliasStatement"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| alias.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</TraitAliasStatement>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| TraitAlias alias = ASTNode.copySubtree(target, getAlias()); | ||
| final TraitAliasStatement result = new TraitAliasStatement( | ||
| this.getStart(), this.getEnd(), target, alias); | ||
| return result; | ||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
| } |
| @@ -0,0 +1,59 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
|
|
||
| public class TraitDeclaration extends ClassDeclaration { | ||
|
|
||
| public TraitDeclaration(int start, int end, AST ast, int modifier, | ||
| Identifier className, Expression superClass, List interfaces, | ||
| Block body) { | ||
| super(start, end, ast, modifier, className, superClass, interfaces, | ||
| body); | ||
| } | ||
|
|
||
| public TraitDeclaration(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| /* | ||
| * Method declared on ASTNode. | ||
| */ | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| if (!(other instanceof TraitDeclaration)) { | ||
| return false; | ||
| } | ||
| return super.subtreeMatch(matcher, other); | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| final Block body = ASTNode.copySubtree(target, getBody()); | ||
| final int modifier = getModifier(); | ||
| final Identifier name = ASTNode.copySubtree(target, getName()); | ||
|
|
||
| final TraitDeclaration result = new TraitDeclaration(getStart(), | ||
| getEnd(), target, modifier, name, getName(), interfaces(), body); | ||
| return result; | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitDeclaration"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append("'>\n"); //$NON-NLS-1$ //$NON-NLS-2$ | ||
| buffer.append(tab).append(TAB).append("<TraitName>\n"); //$NON-NLS-1$ | ||
| getName().toString(buffer, TAB + TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append(TAB).append("</TraitName>\n"); //$NON-NLS-1$ | ||
|
|
||
| getBody().toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</TraitDeclaration>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| public int getType() { | ||
| return ASTNode.CLASS_DECLARATION; | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,185 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.internal.core.PHPVersion; | ||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| public class TraitPrecedence extends Expression { | ||
|
|
||
| public TraitPrecedence(int start, int end, AST ast, | ||
| FullyQualifiedTraitMethodReference methodReference, | ||
| List<NamespaceName> trList) { | ||
| super(start, end, ast); | ||
| setMethodReference(methodReference); | ||
|
|
||
| if (trList != null) { | ||
| this.trList.addAll(trList); | ||
| } | ||
| } | ||
|
|
||
| public TraitPrecedence(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| private FullyQualifiedTraitMethodReference methodReference; | ||
| private ASTNode.NodeList<NamespaceName> trList = new ASTNode.NodeList<NamespaceName>( | ||
| TRAIT_REFERENCE_LIST);; | ||
|
|
||
| public static final ChildPropertyDescriptor METHOD_REFERENCE = new ChildPropertyDescriptor( | ||
| TraitPrecedence.class, | ||
| "methodReference", FullyQualifiedTraitMethodReference.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| public static final ChildListPropertyDescriptor TRAIT_REFERENCE_LIST = new ChildListPropertyDescriptor( | ||
| TraitPrecedence.class, "trList", NamespaceName.class, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * A list of property descriptors (element type: | ||
| * {@link StructuralPropertyDescriptor}), or null if uninitialized. | ||
| */ | ||
| private static final List<StructuralPropertyDescriptor> PROPERTY_DESCRIPTORS; | ||
|
|
||
| static { | ||
| List<StructuralPropertyDescriptor> propertyList = new ArrayList<StructuralPropertyDescriptor>( | ||
| 1); | ||
| propertyList.add(METHOD_REFERENCE); | ||
| propertyList.add(TRAIT_REFERENCE_LIST); | ||
| PROPERTY_DESCRIPTORS = Collections.unmodifiableList(propertyList); | ||
| } | ||
|
|
||
| public FullyQualifiedTraitMethodReference getMethodReference() { | ||
| return methodReference; | ||
| } | ||
|
|
||
| public void setMethodReference( | ||
| FullyQualifiedTraitMethodReference methodReference) { | ||
| if (methodReference == null) { | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| ASTNode oldChild = this.methodReference; | ||
| preReplaceChild(oldChild, methodReference, METHOD_REFERENCE); | ||
| this.methodReference = methodReference; | ||
| postReplaceChild(oldChild, methodReference, METHOD_REFERENCE); | ||
| } | ||
|
|
||
| public List<NamespaceName> getTrList() { | ||
| return trList; | ||
| } | ||
|
|
||
| public void setTrList(List<NamespaceName> trList) { | ||
| this.trList.clear(); | ||
| if (trList != null) { | ||
| this.trList.addAll(trList); | ||
| } | ||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
|
|
||
| public void childrenAccept(Visitor visitor) { | ||
| methodReference.accept(visitor); | ||
| if (trList != null) { | ||
| for (NamespaceName name : trList) { | ||
| name.accept(visitor); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public void traverseTopDown(Visitor visitor) { | ||
| accept(visitor); | ||
| methodReference.traverseTopDown(visitor); | ||
| if (trList != null) { | ||
| for (NamespaceName name : trList) { | ||
| name.traverseTopDown(visitor); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void traverseBottomUp(Visitor visitor) { | ||
| methodReference.traverseBottomUp(visitor); | ||
| if (trList != null) { | ||
| for (NamespaceName name : trList) { | ||
| name.traverseBottomUp(visitor); | ||
| } | ||
| } | ||
| accept(visitor); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitPrecedence"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| methodReference.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| if (trList != null) { | ||
| buffer.append(TAB).append(tab).append("<TraitReferenceList>\n"); //$NON-NLS-1$ | ||
| for (NamespaceName name : trList) { | ||
| name.toString(buffer, TAB + TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(TAB).append(tab).append("</TraitReferenceList>\n"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(tab).append("</TraitPrecedence>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| public int getType() { | ||
| return ASTNode.FUNCTION_NAME; | ||
| } | ||
|
|
||
| /* | ||
| * Method declared on ASTNode. | ||
| */ | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| // dispatch to correct overloaded match method | ||
| return matcher.match(this, other); | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| FullyQualifiedTraitMethodReference methodReference = ASTNode | ||
| .copySubtree(target, getMethodReference()); | ||
| List<NamespaceName> trList = ASTNode.copySubtrees(target, getTrList()); | ||
| final TraitPrecedence result = new TraitPrecedence(this.getStart(), | ||
| this.getEnd(), target, methodReference, trList); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| List<StructuralPropertyDescriptor> internalStructuralPropertiesForType( | ||
| PHPVersion apiLevel) { | ||
| return PROPERTY_DESCRIPTORS; | ||
| } | ||
|
|
||
| final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, | ||
| boolean get, ASTNode child) { | ||
| if (property == METHOD_REFERENCE) { | ||
| if (get) { | ||
| return getMethodReference(); | ||
| } else { | ||
| setMethodReference((FullyQualifiedTraitMethodReference) child); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // allow default implementation to flag the error | ||
| return super.internalGetSetChildProperty(property, get, child); | ||
| } | ||
|
|
||
| final List internalGetChildListProperty(ChildListPropertyDescriptor property) { | ||
| if (property == TRAIT_REFERENCE_LIST) { | ||
| return getTrList(); | ||
| } | ||
| // allow default implementation to flag the error | ||
| return super.internalGetChildListProperty(property); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,61 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| public class TraitPrecedenceStatement extends TraitStatement { | ||
| private TraitPrecedence precedence; | ||
|
|
||
| public TraitPrecedenceStatement(int start, int end, AST ast, | ||
| TraitPrecedence precedence) { | ||
| super(start, end, ast, precedence); | ||
| this.precedence = precedence; | ||
| } | ||
|
|
||
| public TraitPrecedenceStatement(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| public TraitPrecedence getPrecedence() { | ||
| return precedence; | ||
| } | ||
|
|
||
| public void setPrecedence(TraitPrecedence precedence) { | ||
| setExp(precedence); | ||
| this.precedence = precedence; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| if (!(other instanceof TraitPrecedenceStatement)) { | ||
| return false; | ||
| } | ||
| return super.subtreeMatch(matcher, other); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitPrecedenceStatement"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| precedence.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</TraitPrecedenceStatement>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| TraitPrecedence precedence = ASTNode.copySubtree(target, | ||
| getPrecedence()); | ||
| final TraitPrecedenceStatement result = new TraitPrecedenceStatement( | ||
| this.getStart(), this.getEnd(), target, precedence); | ||
| return result; | ||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
| } |
| @@ -0,0 +1,121 @@ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.internal.core.PHPVersion; | ||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| public abstract class TraitStatement extends Statement { | ||
|
|
||
| private Expression exp; | ||
|
|
||
| public static final ChildPropertyDescriptor EXP = new ChildPropertyDescriptor( | ||
| TraitStatement.class, | ||
| "exp", Expression.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * A list of property descriptors (element type: | ||
| * {@link StructuralPropertyDescriptor}), or null if uninitialized. | ||
| */ | ||
| private static final List<StructuralPropertyDescriptor> PROPERTY_DESCRIPTORS; | ||
|
|
||
| static { | ||
| List<StructuralPropertyDescriptor> propertyList = new ArrayList<StructuralPropertyDescriptor>( | ||
| 1); | ||
| propertyList.add(EXP); | ||
| PROPERTY_DESCRIPTORS = Collections.unmodifiableList(propertyList); | ||
| } | ||
|
|
||
| public TraitStatement(int start, int end, AST ast, Expression exp) { | ||
| super(start, end, ast); | ||
| setExp(exp); | ||
| } | ||
|
|
||
| public TraitStatement(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| public Expression getExp() { | ||
| return exp; | ||
| } | ||
|
|
||
| public void setExp(Expression exp) { | ||
| if (exp == null) { | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| ASTNode oldChild = this.exp; | ||
| preReplaceChild(oldChild, exp, EXP); | ||
| this.exp = exp; | ||
| postReplaceChild(oldChild, exp, EXP); | ||
|
|
||
| } | ||
|
|
||
| public void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
|
|
||
| public void childrenAccept(Visitor visitor) { | ||
| exp.accept(visitor); | ||
|
|
||
| } | ||
|
|
||
| public void traverseTopDown(Visitor visitor) { | ||
| accept(visitor); | ||
| exp.traverseTopDown(visitor); | ||
| } | ||
|
|
||
| public void traverseBottomUp(Visitor visitor) { | ||
| exp.traverseBottomUp(visitor); | ||
| accept(visitor); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitStatement"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| exp.toString(buffer, TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| buffer.append(tab).append("</TraitStatement>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| public int getType() { | ||
| return ASTNode.FUNCTION_NAME; | ||
| } | ||
|
|
||
| /* | ||
| * Method declared on ASTNode. | ||
| */ | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| // dispatch to correct overloaded match method | ||
| return matcher.match(this, other); | ||
| } | ||
|
|
||
| @Override | ||
| List<StructuralPropertyDescriptor> internalStructuralPropertiesForType( | ||
| PHPVersion apiLevel) { | ||
| return PROPERTY_DESCRIPTORS; | ||
| } | ||
|
|
||
| final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, | ||
| boolean get, ASTNode child) { | ||
| if (property == EXP) { | ||
| if (get) { | ||
| return getExp(); | ||
| } else { | ||
| setExp((Expression) child); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // allow default implementation to flag the error | ||
| return super.internalGetSetChildProperty(property, get, child); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,195 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2009 IBM Corporation and others. | ||
| * All rights reserved. This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License v1.0 | ||
| * which accompanies this distribution, and is available at | ||
| * http://www.eclipse.org/legal/epl-v10.html | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| * Zend Technologies | ||
| *******************************************************************************/ | ||
| package org2.eclipse.php.internal.core.ast.nodes; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org2.eclipse.php.internal.core.PHPVersion; | ||
| import org2.eclipse.php.internal.core.ast.match.ASTMatcher; | ||
| import org2.eclipse.php.internal.core.ast.visitor.Visitor; | ||
|
|
||
| /** | ||
| * Represent a 'use' statement. | ||
| * | ||
| * <pre>e.g. | ||
| * | ||
| * <pre> | ||
| * use A; | ||
| * use A as B; | ||
| * use \A\B as C; | ||
| */ | ||
| public class TraitUseStatement extends Statement { | ||
|
|
||
| private ASTNode.NodeList<NamespaceName> traitList = new ASTNode.NodeList<NamespaceName>( | ||
| TRAIT); | ||
| private ASTNode.NodeList<TraitStatement> tsList = new ASTNode.NodeList<TraitStatement>( | ||
| TRAIT_STATEMENT); | ||
|
|
||
| public static final ChildListPropertyDescriptor TRAIT = new ChildListPropertyDescriptor( | ||
| TraitUseStatement.class, | ||
| "traitList", NamespaceName.class, CYCLE_RISK); //$NON-NLS-1$ | ||
| public static final ChildListPropertyDescriptor TRAIT_STATEMENT = new ChildListPropertyDescriptor( | ||
| TraitUseStatement.class, "tsList", TraitStatement.class, CYCLE_RISK); //$NON-NLS-1$ | ||
|
|
||
| /** | ||
| * A list of property descriptors (element type: | ||
| * {@link StructuralPropertyDescriptor}), or null if uninitialized. | ||
| */ | ||
| private static final List<StructuralPropertyDescriptor> PROPERTY_DESCRIPTORS; | ||
|
|
||
| static { | ||
| List<StructuralPropertyDescriptor> propertyList = new ArrayList<StructuralPropertyDescriptor>( | ||
| 1); | ||
| propertyList.add(TRAIT); | ||
| propertyList.add(TRAIT_STATEMENT); | ||
| PROPERTY_DESCRIPTORS = Collections.unmodifiableList(propertyList); | ||
| } | ||
|
|
||
| public TraitUseStatement(int start, int end, AST ast, | ||
| List<NamespaceName> traitList, List<TraitStatement> tsList) { | ||
| super(start, end, ast); | ||
|
|
||
| if (traitList != null) { | ||
| this.traitList.addAll(traitList); | ||
| } | ||
| if (tsList != null) { | ||
| this.tsList.addAll(tsList); | ||
| } | ||
| } | ||
|
|
||
| public TraitUseStatement(AST ast) { | ||
| super(ast); | ||
| } | ||
|
|
||
| public void childrenAccept(Visitor visitor) { | ||
| for (ASTNode node : traitList) { | ||
| node.accept(visitor); | ||
| } | ||
| for (ASTNode node : tsList) { | ||
| node.accept(visitor); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public void traverseTopDown(Visitor visitor) { | ||
| for (ASTNode node : traitList) { | ||
| node.traverseTopDown(visitor); | ||
| } | ||
| for (ASTNode node : tsList) { | ||
| node.traverseTopDown(visitor); | ||
| } | ||
| } | ||
|
|
||
| public void traverseBottomUp(Visitor visitor) { | ||
| for (ASTNode node : traitList) { | ||
| node.traverseBottomUp(visitor); | ||
| } | ||
| for (ASTNode node : tsList) { | ||
| node.traverseBottomUp(visitor); | ||
| } | ||
| accept(visitor); | ||
| } | ||
|
|
||
| public void toString(StringBuffer buffer, String tab) { | ||
| buffer.append(tab).append("<TraitUseStatement"); //$NON-NLS-1$ | ||
| appendInterval(buffer); | ||
| buffer.append(">\n"); //$NON-NLS-1$ | ||
| if (traitList != null && !traitList.isEmpty()) { | ||
| buffer.append(TAB).append(tab).append("<TraitNameList>\n"); //$NON-NLS-1$ | ||
| for (NamespaceName name : traitList) { | ||
| name.toString(buffer, TAB + TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(TAB).append(tab).append("</TraitNameList>\n"); //$NON-NLS-1$ | ||
| } | ||
| if (tsList != null && !tsList.isEmpty()) { | ||
| buffer.append(TAB).append(tab).append("<TraitStatementList>\n"); //$NON-NLS-1$ | ||
| for (TraitStatement name : tsList) { | ||
| name.toString(buffer, TAB + TAB + tab); | ||
| buffer.append("\n"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(TAB).append(tab).append("</TraitStatementList>\n"); //$NON-NLS-1$ | ||
| } | ||
| buffer.append(tab).append("</TraitUseStatement>"); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| @Override | ||
| void accept0(Visitor visitor) { | ||
| final boolean visit = visitor.visit(this); | ||
| if (visit) { | ||
| childrenAccept(visitor); | ||
| } | ||
| visitor.endVisit(this); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { | ||
| return matcher.match(this, other); | ||
| } | ||
|
|
||
| @Override | ||
| public int getType() { | ||
| return TRAIT_USE_STATEMENT; | ||
| } | ||
|
|
||
| @Override | ||
| List<StructuralPropertyDescriptor> internalStructuralPropertiesForType( | ||
| PHPVersion apiLevel) { | ||
| return PROPERTY_DESCRIPTORS; | ||
| } | ||
|
|
||
| @Override | ||
| ASTNode clone0(AST target) { | ||
| final List<NamespaceName> traitList = ASTNode.copySubtrees(target, | ||
| getTraitList()); | ||
| List<TraitStatement> tsList = ASTNode.copySubtrees(target, getTsList()); | ||
| final TraitUseStatement result = new TraitUseStatement(this.getStart(), | ||
| this.getEnd(), target, traitList, tsList); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| public List<NamespaceName> getTraitList() { | ||
| return traitList; | ||
| } | ||
|
|
||
| public void setTraitList(List<NamespaceName> traitList) { | ||
| this.traitList.clear(); | ||
| if (traitList != null) { | ||
| this.traitList.addAll(traitList); | ||
| } | ||
| } | ||
|
|
||
| public List<TraitStatement> getTsList() { | ||
| return tsList; | ||
| } | ||
|
|
||
| public void setTsList(List<TraitStatement> tsList) { | ||
| this.tsList.clear(); | ||
| if (tsList != null) { | ||
| this.tsList.addAll(tsList); | ||
| } | ||
| } | ||
|
|
||
| final List internalGetChildListProperty(ChildListPropertyDescriptor property) { | ||
| if (property == TRAIT) { | ||
| return getTraitList(); | ||
| } else if (property == TRAIT_STATEMENT) { | ||
| return getTsList(); | ||
| } | ||
| // allow default implementation to flag the error | ||
| return super.internalGetChildListProperty(property); | ||
| } | ||
|
|
||
| } |