/* * (non-Javadoc) * * @see org.walkmod.javalang.visitors.VoidVisitorAdapter#visit(org.walkmod.javalang.ast.body.Parameter, * java.lang.Object) */ @SuppressWarnings("unchecked") @Override public void visit(Parameter n, VisitorContext arg) { Map<String, Object> m = variablesMap.get(classStack.peek()); Object[] strings = methodStack.toArray(); for (int i = 0; i < methodStack.size(); i++) { m = (Map<String, Object>) m.get(strings[i]); } m.put(n.getId().getName(), getActualType(n.getType())); super.visit(n, arg); }
/** * Gets the unique method name. * * @param n the n * @return the unique method name */ private String getUniqueMethodName(BodyDeclaration n) { StringBuffer sb = new StringBuffer("m_"); List<Parameter> parameters = null; if (n instanceof ConstructorDeclaration) { sb.append(((ConstructorDeclaration) n).getName()); parameters = ((ConstructorDeclaration) n).getParameters(); } else if (n instanceof MethodDeclaration) { sb.append(((MethodDeclaration) n).getName()); parameters = ((MethodDeclaration) n).getParameters(); } if (parameters != null) { for (Parameter parameter : parameters) { Type type = parameter.getType(); sb.append("_").append(getActualType(type)); } } return sb.toString(); }