private ITypeBinding getBinding(IType type, CompilationUnit unit) throws JavaModelException { ITypeBinding binding = null; ASTNode node = NodeFinder.perform(unit, type.getNameRange()); do { node = node.getParent(); } while (node != null && !AbstractTypeDeclaration.class.isInstance(node)); AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) node; if (declaration != null) binding = declaration.resolveBinding(); return binding; }
private ITypeBinding getDestinationBinding() throws JavaModelException { ASTNode node= NodeFinder.perform(fTarget.getRoot(), fDestinationType.getNameRange()); if (!(node instanceof SimpleName)) return null; IBinding binding= ((SimpleName)node).resolveBinding(); if (!(binding instanceof ITypeBinding)) return null; return (ITypeBinding)binding; }
private ITypeBinding getDestinationBinding() throws JavaModelException { ASTNode node= NodeFinder.perform(fTarget.getRoot(), fDestinationType.getNameRange()); if (!(node instanceof SimpleName)) return null; IBinding binding= ((SimpleName)node).resolveBinding(); if (!(binding instanceof ITypeBinding)) return null; return (ITypeBinding)binding; }
private ASTNode typeToDeclaration(IType type, CompilationUnit root) throws JavaModelException { Name intermediateName= (Name) NodeFinder.perform(root, type.getNameRange()); if (type.isAnonymous()) { return ASTNodes.getParent(intermediateName, AnonymousClassDeclaration.class); } else { return ASTNodes.getParent(intermediateName, AbstractTypeDeclaration.class); } }
private ASTNode typeToDeclaration(IType type, CompilationUnit root) throws JavaModelException { Name intermediateName= (Name) NodeFinder.perform(root, type.getNameRange()); if (type.isAnonymous()) { return ASTNodes.getParent(intermediateName, AnonymousClassDeclaration.class); } else { return ASTNodes.getParent(intermediateName, AbstractTypeDeclaration.class); } }
@Override protected Position getSourceRange(IType type, IDocument doc, IReference reference) throws CoreException, BadLocationException { ISourceRange range = type.getNameRange(); Position pos = null; if (range != null) { pos = new Position(range.getOffset(), range.getLength()); } if (pos == null) { return defaultSourcePosition(type, reference); } return pos; }
private ASTNode typeToDeclaration(IType type, CompilationUnit root) throws JavaModelException { Name intermediateName= (Name) NodeFinder.perform(root, type.getNameRange()); if (type.isAnonymous()) { return ASTNodes.getParent(intermediateName, AnonymousClassDeclaration.class); } else { return ASTNodes.getParent(intermediateName, AbstractTypeDeclaration.class); } }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name= RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength= fType.getElementName().length(); ICompilationUnit cu= fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name = RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength = fType.getElementName().length(); ICompilationUnit cu = fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name= RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength= fType.getElementName().length(); ICompilationUnit cu= fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private void addTypeDeclarationUpdate(TextChangeManager manager) throws CoreException { String name= RefactoringCoreMessages.RenameTypeRefactoring_update; int typeNameLength= fType.getElementName().length(); ICompilationUnit cu= fType.getCompilationUnit(); TextChangeCompatibility.addTextEdit(manager.get(cu), name, new ReplaceEdit(fType.getNameRange().getOffset(), typeNameLength, getNewElementName())); }
private static Integer[] createOffsetArray(IType[] types) throws JavaModelException { List result= new ArrayList(); for (int i= 0; i < types.length; i++) { IType iType= types[i]; addOffset(result, iType.getNameRange().getOffset()); addOffset(result, iType.getSourceRange().getOffset() + iType.getSourceRange().getLength()); addMemberOffsetList(result, iType.getMethods()); addMemberOffsetList(result, iType.getFields()); addMemberOffsetList(result, iType.getInitializers()); } return (Integer[]) result.toArray(new Integer[result.size()]); }
private static Integer[] createOffsetArray(IType[] types) throws JavaModelException { List<Integer> result= new ArrayList<>(); for (int i= 0; i < types.length; i++) { IType iType= types[i]; addOffset(result, iType.getNameRange().getOffset()); addOffset(result, iType.getSourceRange().getOffset() + iType.getSourceRange().getLength()); addMemberOffsetList(result, iType.getMethods()); addMemberOffsetList(result, iType.getFields()); addMemberOffsetList(result, iType.getInitializers()); } return result.toArray(new Integer[result.size()]); }
void initialize(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL); fUnit= parser.parse(type.getCompilationUnit(), true); fTypeBinding= null; // type cannot be anonymous final AbstractTypeDeclaration declaration= ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) fTypeBinding= declaration.resolveBinding(); }
void initialize(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL); fUnit= parser.parse(type.getCompilationUnit(), true); fTypeBinding= null; // type cannot be anonymous final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) fTypeBinding= declaration.resolveBinding(); }
public void run(IStructuredSelection selection) { IType type= getElement(selection); if (type == null) return; ISourceRange range; try { range= type.getNameRange(); run(type.getCompilationUnit(), range.getOffset(), range.getLength()); } catch (JavaModelException e) { ExceptionHandler.handle(e, RefactoringMessages.ConvertAnonymousToNestedAction_dialog_title, RefactoringMessages.NewTextRefactoringAction_exception); } }
public AddUnimplementedConstructorsContentProvider(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(AST.JLS3); fUnit= parser.parse(type.getCompilationUnit(), true); AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) { ITypeBinding binding= declaration.resolveBinding(); if (binding != null) fMethodsList= StubUtility2.getVisibleConstructors(binding, true, false); } }
public AddUnimplementedConstructorsContentProvider(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL); fUnit= parser.parse(type.getCompilationUnit(), true); AbstractTypeDeclaration declaration= ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) { ITypeBinding binding= declaration.resolveBinding(); if (binding != null) fMethodsList= StubUtility2Core.getVisibleConstructors(binding, true, false); } }
public AddUnimplementedConstructorsContentProvider(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL); fUnit= parser.parse(type.getCompilationUnit(), true); AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) { ITypeBinding binding= declaration.resolveBinding(); if (binding != null) fMethodsList= StubUtility2.getVisibleConstructors(binding, true, false); } }
private void initialize(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(AST.JLS3); fUnit= parser.parse(type.getCompilationUnit(), true); fTypeBinding= null; // type cannot be anonymous final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) fTypeBinding= declaration.resolveBinding(); fCandidateFields= fTypeBinding.getDeclaredFields(); }