Ejemplo n.º 1
0
  public void doTransformPM(final PMProject pm_project) {
    final SimpleName element = (SimpleName) location.getASTNode();
    final IBinding binding = element.resolveBinding();

    // 		if (binding != null) {
    // 			final int kind = binding.getKind();

    // 			if (kind == IBinding.TYPE
    // 			    || (kind == IBinding.METHOD
    // 				&& ((IMethodBinding) binding).isConstructor())) {
    // 				// rename the associated type and all constructors
    // 				final ITypeBinding declaring_class = (kind == IBinding.TYPE)? (ITypeBinding) binding :
    // ((IMethodBinding) binding).getDeclaringClass();
    // 				final IMethodBinding[] methods = declaring_class.getDeclaredMethods();
    // 				final AType type = new AType(tproject, (IType) declaring_class.getJavaElement());
    // 				final LinkedList<AMethod> constructors = new LinkedList<AMethod>();

    // 				for (IMethodBinding b : methods)
    // 					if (b.isConstructor())
    // 						constructors.add(new AMethod(tproject, (IMethod) b.getJavaElement()));

    // 				// We found all that needs renaming.
    // 				System.err.println("--< start >--------------------------------------");
    // 				System.err.println("=| " + type + "\n" + type.getASTNode());
    // 				System.err.println("-- Complex rename : " + constructors.size() + " constructors.");
    // 				for (AMethod constructor : constructors) {
    // 					System.err.println("-- rename constructor " + constructor);
    // 					doTransformPMOne(pm_project, ((MethodDeclaration) constructor.getASTNode()).getName());
    // 				}
    // 				System.err.println("-- rename class " + type);

    // 				final ASTNode n = type.getASTNode();
    // 				SimpleName name = null;
    // 				if (n instanceof SimpleName)
    // 					name = (SimpleName) n;
    // 				else if (n instanceof CompilationUnit) {
    // 					final List<?> list = ((CompilationUnit)n).types();
    // 					for (Object o : list) {
    // 						if (o instanceof TypeDeclaration) {
    // 							TypeDeclaration tdecl = (TypeDeclaration) o;
    // 							if (name == null)
    // 								name = tdecl.getName();
    // 							else
    // 								throw new RuntimeException("Multiple classes to rename: at least " + name + " and " +
    // tdecl
    // 											   + " (in " + type + ")!");
    // 						}
    // 					}
    // 				} else
    // 					throw new RuntimeException("Don't know how to get SimpleName from " + n.getClass());

    // 				doTransformPMOne(pm_project, name);
    // 				System.err.println("--< end >--------------------------------------");

    // 				return;
    // 			}
    // 		}

    System.err.println("-- Doing simple renaming on " + element);
    doTransformPMOne(pm_project, element);
  }
Ejemplo n.º 2
0
 public boolean visit(SimpleName name) {
   if (this.have(name.resolveBinding().getJavaElement())) recordOwner();
   return true;
 }