Search in sources :

Example 1 with TempOccurrenceAnalyzer

use of org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer in project che by eclipse.

the class PromoteTempToFieldRefactoring method addTempRenames.

private void addTempRenames(ASTRewrite rewrite) {
    boolean noNameChange = fFieldName.equals(fTempDeclarationNode.getName().getIdentifier());
    if (fLinkedProposalModel == null && noNameChange) {
        // no changes needed
        return;
    }
    TempOccurrenceAnalyzer analyzer = new TempOccurrenceAnalyzer(fTempDeclarationNode, false);
    analyzer.perform();
    // no javadocs (refactoring not for parameters)
    SimpleName[] tempRefs = analyzer.getReferenceNodes();
    for (int j = 0; j < tempRefs.length; j++) {
        SimpleName occurence = tempRefs[j];
        if (noNameChange) {
            addLinkedName(rewrite, occurence, false);
        } else {
            SimpleName newName = getAST().newSimpleName(fFieldName);
            addLinkedName(rewrite, newName, false);
            rewrite.replace(occurence, newName, null);
        }
    }
}
Also used : TempOccurrenceAnalyzer(org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer) SimpleName(org.eclipse.jdt.core.dom.SimpleName)

Example 2 with TempOccurrenceAnalyzer

use of org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer in project che by eclipse.

the class InlineTempRefactoring method getReferences.

public SimpleName[] getReferences() {
    if (fReferences != null)
        return fReferences;
    TempOccurrenceAnalyzer analyzer = new TempOccurrenceAnalyzer(getVariableDeclaration(), false);
    analyzer.perform();
    fReferences = analyzer.getReferenceNodes();
    return fReferences;
}
Also used : TempOccurrenceAnalyzer(org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer)

Aggregations

TempOccurrenceAnalyzer (org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer)2 SimpleName (org.eclipse.jdt.core.dom.SimpleName)1