Lines 117-122
Link Here
|
117 |
import org.netbeans.api.java.source.GeneratorUtilities; |
117 |
import org.netbeans.api.java.source.GeneratorUtilities; |
118 |
import org.netbeans.api.java.source.JavaSource; |
118 |
import org.netbeans.api.java.source.JavaSource; |
119 |
import org.netbeans.api.java.source.JavaSource.Phase; |
119 |
import org.netbeans.api.java.source.JavaSource.Phase; |
|
|
120 |
import org.netbeans.api.java.source.SourceUtils; |
120 |
import org.netbeans.api.java.source.TreeMaker; |
121 |
import org.netbeans.api.java.source.TreeMaker; |
121 |
import org.netbeans.api.java.source.TreePathHandle; |
122 |
import org.netbeans.api.java.source.TreePathHandle; |
122 |
import org.netbeans.api.java.source.TreeUtilities; |
123 |
import org.netbeans.api.java.source.TreeUtilities; |
Lines 422-429
Link Here
|
422 |
TreePath value = resolved.getLeaf().getKind() != Kind.VARIABLE ? resolved : new TreePath(resolved, ((VariableTree) resolved.getLeaf()).getInitializer()); |
423 |
TreePath value = resolved.getLeaf().getKind() != Kind.VARIABLE ? resolved : new TreePath(resolved, ((VariableTree) resolved.getLeaf()).getInitializer()); |
423 |
boolean isConstant = checkConstantExpression(info, value) && !expressionStatement; |
424 |
boolean isConstant = checkConstantExpression(info, value) && !expressionStatement; |
424 |
boolean isVariable = findStatement(resolved) != null && method != null && resolved.getLeaf().getKind() != Kind.VARIABLE; |
425 |
boolean isVariable = findStatement(resolved) != null && method != null && resolved.getLeaf().getKind() != Kind.VARIABLE; |
425 |
Set<TreePath> duplicatesForVariable = isVariable ? CopyFinder.computeDuplicates(info, resolved, method, cancel, null).keySet() : null; |
426 |
Set<TreePath> duplicatesForVariable = isVariable ? SourceUtils.computeDuplicates(info, resolved, method, cancel) : null; |
426 |
Set<TreePath> duplicatesForConstant = /*isConstant ? */CopyFinder.computeDuplicates(info, resolved, new TreePath(info.getCompilationUnit()), cancel, null).keySet();// : null; |
427 |
Set<TreePath> duplicatesForConstant = /*isConstant ? */SourceUtils.computeDuplicates(info, resolved, new TreePath(info.getCompilationUnit()), cancel);// : null; |
427 |
Scope scope = info.getTrees().getScope(resolved); |
428 |
Scope scope = info.getTrees().getScope(resolved); |
428 |
boolean statik = scope != null ? info.getTreeUtilities().isStaticContext(scope) : false; |
429 |
boolean statik = scope != null ? info.getTreeUtilities().isStaticContext(scope) : false; |
429 |
String guessedName = Utilities.guessName(info, resolved); |
430 |
String guessedName = Utilities.guessName(info, resolved); |
Lines 1355-1361
Link Here
|
1355 |
returnValueComputed = true; |
1356 |
returnValueComputed = true; |
1356 |
} else { |
1357 |
} else { |
1357 |
if (returnValue != null && currentReturnValue != null) { |
1358 |
if (returnValue != null && currentReturnValue != null) { |
1358 |
Set<TreePath> candidates = CopyFinder.computeDuplicates(info, returnValue, currentReturnValue, cancel, null).keySet(); |
1359 |
Set<TreePath> candidates = SourceUtils.computeDuplicates(info, returnValue, currentReturnValue, cancel); |
1359 |
|
1360 |
|
1360 |
if (candidates.size() != 1 || candidates.iterator().next().getLeaf() != rt.getExpression()) { |
1361 |
if (candidates.size() != 1 || candidates.iterator().next().getLeaf() != rt.getExpression()) { |
1361 |
return "ERR_Different_Return_Values"; // NOI18N |
1362 |
return "ERR_Different_Return_Values"; // NOI18N |
Lines 1514-1520
Link Here
|
1514 |
parameter.rewrite(pathToClass.getLeaf(), nueClass); |
1515 |
parameter.rewrite(pathToClass.getLeaf(), nueClass); |
1515 |
|
1516 |
|
1516 |
if (replaceAll) { |
1517 |
if (replaceAll) { |
1517 |
for (TreePath p : CopyFinder.computeDuplicates(parameter, resolved, new TreePath(parameter.getCompilationUnit()), new AtomicBoolean(), null).keySet()) { |
1518 |
for (TreePath p : SourceUtils.computeDuplicates(parameter, resolved, new TreePath(parameter.getCompilationUnit()), new AtomicBoolean())) { |
1518 |
parameter.rewrite(p.getLeaf(), make.Identifier(name)); |
1519 |
parameter.rewrite(p.getLeaf(), make.Identifier(name)); |
1519 |
} |
1520 |
} |
1520 |
} |
1521 |
} |
Lines 1530-1536
Link Here
|
1530 |
int index; |
1531 |
int index; |
1531 |
|
1532 |
|
1532 |
if (replaceAll) { |
1533 |
if (replaceAll) { |
1533 |
Set<TreePath> candidates = CopyFinder.computeDuplicates(parameter, resolved, method, new AtomicBoolean(), null).keySet(); |
1534 |
Set<TreePath> candidates = SourceUtils.computeDuplicates(parameter, resolved, method, new AtomicBoolean()); |
1534 |
for (TreePath p : candidates) { |
1535 |
for (TreePath p : candidates) { |
1535 |
Tree leaf = p.getLeaf(); |
1536 |
Tree leaf = p.getLeaf(); |
1536 |
|
1537 |
|
Lines 1666-1672
Link Here
|
1666 |
boolean isAnyOccurenceStatic = false; |
1667 |
boolean isAnyOccurenceStatic = false; |
1667 |
|
1668 |
|
1668 |
if (replaceAll) { |
1669 |
if (replaceAll) { |
1669 |
for (TreePath p : CopyFinder.computeDuplicates(parameter, resolved, new TreePath(parameter.getCompilationUnit()), new AtomicBoolean(), null).keySet()) { |
1670 |
for (TreePath p : SourceUtils.computeDuplicates(parameter, resolved, new TreePath(parameter.getCompilationUnit()), new AtomicBoolean())) { |
1670 |
parameter.rewrite(p.getLeaf(), make.Identifier(name)); |
1671 |
parameter.rewrite(p.getLeaf(), make.Identifier(name)); |
1671 |
Scope occurenceScope = parameter.getTrees().getScope(p); |
1672 |
Scope occurenceScope = parameter.getTrees().getScope(p); |
1672 |
if(parameter.getTreeUtilities().isStaticContext(occurenceScope)) |
1673 |
if(parameter.getTreeUtilities().isStaticContext(occurenceScope)) |