if (node instanceof FieldDeclaration) {
locator.match((FieldDeclaration) node, getNodeSet());
} else if (node instanceof ConstantDeclaration) {
ConstantDeclaration constDecl = (ConstantDeclaration) node;
ConstantReference constantName = constDecl.getConstantName();
FieldDeclaration decl = new FieldDeclarationLocation(constantName
.getName(), constantName.sourceStart(), constantName
.sourceEnd(), constDecl.sourceStart(), constDecl
.sourceEnd());
decl.setModifiers(Modifiers.AccConstant);
locator.match(decl, getNodeSet());
} else if (node instanceof FieldAccess) {
Expression field = ((FieldAccess) node).getField();
if (field instanceof SimpleReference) {
SimpleReference ref = (SimpleReference) field;
SimpleReferenceLocation refLoc = new SimpleReferenceLocation(
ref.sourceStart(), ref.sourceEnd(), '$' + ref.getName());
locator.match(refLoc, getNodeSet());
}
} else if (node instanceof StaticFieldAccess) {
Expression field = ((StaticFieldAccess) node).getField();
if (field instanceof SimpleReference) {
SimpleReference ref = (SimpleReference) field;
SimpleReferenceLocation refLoc = new SimpleReferenceLocation(
ref.sourceStart(), ref.sourceEnd(), '$' + ref.getName());
locator.match(refLoc, getNodeSet());
}
} else if (node instanceof StaticConstantAccess) {
ConstantReference constantRef = ((StaticConstantAccess) node)
.getConstant();
locator.match(constantRef, getNodeSet());
}
/*
* else if (node instanceof ConstantReference) {
* locator.match((ConstantReference)node, getNodeSet()); }
*/
else if (node instanceof Assignment) {
Expression left = ((Assignment) node).getVariable();
if (left instanceof FieldAccess) { // class variable ($this->a = .)
FieldAccess fieldAccess = (FieldAccess) left;
Expression dispatcher = fieldAccess.getDispatcher();
if (dispatcher instanceof VariableReference) { // && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
Expression field = fieldAccess.getField();
if (field instanceof SimpleReference) {
SimpleReference ref = (SimpleReference) field;
FieldDeclaration decl = new FieldDeclarationLocation(
'$' + ref.getName(), ref.sourceStart(), ref
.sourceEnd(), node.sourceStart(), node
.sourceEnd());
locator.match(decl, getNodeSet());
}
}
} else if (left instanceof VariableReference) {
FieldDeclaration decl = new FieldDeclarationLocation(
((VariableReference) left).getName(), left
.sourceStart(), left.sourceEnd(), node
.sourceStart(), node.sourceEnd());
locator.match(decl, getNodeSet());
}
} else if (node instanceof ListVariable) {
recursiveListMatch(node, locator);
} else if (node instanceof TypeReference) {
locator.match((TypeReference) node, getNodeSet());
} else if (node instanceof VariableReference) {
locator.match((VariableReference) node, getNodeSet());
} else if (node instanceof CallExpression) {
FieldDeclaration constantDecl = ASTUtils
.getConstantDeclaration((CallExpression) node);
if (constantDecl != null) {
locator.match(constantDecl, getNodeSet());
} else {
locator.match((CallExpression) node, getNodeSet());
}
} else if (node instanceof Include) {
Include include = (Include) node;
if (include.getExpr() instanceof Scalar) {
Scalar filePath = (Scalar) include.getExpr();
CallExpression callExpression = new CallExpressionLocation(
filePath.sourceStart(), filePath.sourceEnd(), null,
"include", new CallArgumentsList()); //$NON-NLS-1$
locator.match(callExpression, getNodeSet());
}
} else if (node instanceof Argument) {
SimpleReference ref = ((Argument) node).getRef();
FieldDeclaration decl = new FieldDeclarationLocation(ref.getName(),
ref.sourceStart(), ref.sourceEnd(), node.sourceStart(),
node.sourceEnd());
locator.match(decl, getNodeSet());
} else if (node instanceof ForEachStatement) {
Expression key = ((ForEachStatement) node).getKey();
Expression value = ((ForEachStatement) node).getValue();
if (key instanceof SimpleReference) {
SimpleReference ref = (SimpleReference) key;
FieldDeclaration decl = new FieldDeclarationLocation(ref
.getName(), ref.sourceStart(), ref.sourceEnd(), node
.sourceStart(), node.sourceEnd());
locator.match(decl, getNodeSet());
}
if (value instanceof SimpleReference) {
SimpleReference ref = (SimpleReference) value;
FieldDeclaration decl = new FieldDeclarationLocation(ref
.getName(), ref.sourceStart(), ref.sourceEnd(), ref
.sourceStart(), ref.sourceEnd());
locator.match(decl, getNodeSet());
}
} else if (node instanceof CatchClause) {
VariableReference ref = ((CatchClause) node).getVariable();
FieldDeclaration decl = new FieldDeclarationLocation(ref.getName(),
ref.sourceStart(), ref.sourceEnd(), node.sourceStart(),
node.sourceEnd());
locator.match(decl, getNodeSet());
}
}