use of org.eclipse.jdt.internal.corext.refactoring.code.SourceAnalyzer.NameData in project che by eclipse.
the class SourceProvider method makeNamesUnique.
private void makeNamesUnique(ASTRewrite rewriter, CodeScopeBuilder.Scope scope) {
Collection<NameData> usedCalleeNames = fAnalyzer.getUsedNames();
for (Iterator<NameData> iter = usedCalleeNames.iterator(); iter.hasNext(); ) {
SourceAnalyzer.NameData nd = iter.next();
if (scope.isInUse(nd.getName())) {
String newName = scope.createName(nd.getName(), true);
List<SimpleName> references = nd.references();
for (Iterator<SimpleName> refs = references.iterator(); refs.hasNext(); ) {
SimpleName element = refs.next();
ASTNode newNode = rewriter.createStringPlaceholder(newName, ASTNode.SIMPLE_NAME);
rewriter.replace(element, newNode, null);
}
}
}
}
use of org.eclipse.jdt.internal.corext.refactoring.code.SourceAnalyzer.NameData in project che by eclipse.
the class SourceProvider method rewriteReferences.
private void rewriteReferences(ASTRewrite rewriter, ITypeBinding[] typeArguments, List<NameData> typeParameterReferences) {
if (typeArguments.length == 0)
return;
Assert.isTrue(typeArguments.length == typeParameterReferences.size());
for (int i = 0; i < typeArguments.length; i++) {
SourceAnalyzer.NameData refData = typeParameterReferences.get(i);
List<SimpleName> references = refData.references();
String newName = typeArguments[i].getName();
for (Iterator<SimpleName> iter = references.iterator(); iter.hasNext(); ) {
SimpleName name = iter.next();
rewriter.replace(name, rewriter.createStringPlaceholder(newName, ASTNode.SIMPLE_NAME), null);
}
}
}
Aggregations