use of org.eclipse.jdt.core.dom.SimpleName in project che by eclipse.
the class FullConstraintCreator method create.
/* (non-Javadoc)
* @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.QualifiedName)
*/
@Override
public ITypeConstraint[] create(QualifiedName qualifiedName) {
SimpleName name = qualifiedName.getName();
Name qualifier = qualifiedName.getQualifier();
IBinding nameBinding = name.resolveBinding();
if (nameBinding instanceof IVariableBinding) {
IVariableBinding vb = (IVariableBinding) nameBinding;
if (vb.isField())
return createConstraintsForAccessToField(vb, qualifier, qualifiedName);
}
//TODO other bindings
return new ITypeConstraint[0];
}
use of org.eclipse.jdt.core.dom.SimpleName in project che by eclipse.
the class FullConstraintCreator method getConstraintsFromFragmentList.
private ITypeConstraint[] getConstraintsFromFragmentList(List<VariableDeclarationFragment> list, Type type) {
int size = list.size();
ConstraintVariable typeVariable = fConstraintVariableFactory.makeTypeVariable(type);
List<ITypeConstraint> result = new ArrayList<ITypeConstraint>((size * (size - 1)) / 2);
for (int i = 0; i < size; i++) {
VariableDeclarationFragment fragment1 = list.get(i);
SimpleName fragment1Name = fragment1.getName();
result.addAll(Arrays.asList(fTypeConstraintFactory.createDefinesConstraint(fConstraintVariableFactory.makeExpressionOrTypeVariable(fragment1Name, getContext()), typeVariable)));
for (int j = i + 1; j < size; j++) {
VariableDeclarationFragment fragment2 = list.get(j);
result.addAll(Arrays.asList(fTypeConstraintFactory.createEqualsConstraint(fConstraintVariableFactory.makeExpressionOrTypeVariable(fragment1Name, getContext()), fConstraintVariableFactory.makeExpressionOrTypeVariable(fragment2.getName(), getContext()))));
}
}
return result.toArray(new ITypeConstraint[result.size()]);
}
use of org.eclipse.jdt.core.dom.SimpleName in project che by eclipse.
the class FullConstraintCreator method create.
/* (non-Javadoc)
* @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperFieldAccess)
*/
@Override
public ITypeConstraint[] create(SuperFieldAccess access) {
SimpleName name = access.getName();
IBinding binding = name.resolveBinding();
if (!(binding instanceof IVariableBinding))
return new ITypeConstraint[0];
IVariableBinding vb = (IVariableBinding) binding;
return createConstraintsForAccessToField(vb, null, access);
}
use of org.eclipse.jdt.core.dom.SimpleName in project che by eclipse.
the class RenameNodeCorrectionProposal method addEdits.
/*(non-Javadoc)
* @see org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal#addEdits(org.eclipse.jface.text.IDocument)
*/
@Override
protected void addEdits(IDocument doc, TextEdit root) throws CoreException {
super.addEdits(doc, root);
// build a full AST
CompilationUnit unit = SharedASTProvider.getAST(getCompilationUnit(), SharedASTProvider.WAIT_YES, null);
ASTNode name = NodeFinder.perform(unit, fOffset, fLength);
if (name instanceof SimpleName) {
SimpleName[] names = LinkedNodeFinder.findByProblems(unit, (SimpleName) name);
if (names != null) {
for (int i = 0; i < names.length; i++) {
SimpleName curr = names[i];
root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName));
}
return;
}
}
root.addChild(new ReplaceEdit(fOffset, fLength, fNewName));
}
use of org.eclipse.jdt.core.dom.SimpleName in project che by eclipse.
the class InlineTempRefactoring method inlineTemp.
private void inlineTemp(CompilationUnitRewrite cuRewrite) throws JavaModelException {
SimpleName[] references = getReferences();
TextEditGroup groupDesc = cuRewrite.createGroupDescription(RefactoringCoreMessages.InlineTempRefactoring_inline_edit_name);
ASTRewrite rewrite = cuRewrite.getASTRewrite();
for (int i = 0; i < references.length; i++) {
SimpleName curr = references[i];
ASTNode initializerCopy = getInitializerSource(cuRewrite, curr);
rewrite.replace(curr, initializerCopy, groupDesc);
}
}
Aggregations