TempSelectionAnalyzer(int selectionOffset, int selectionLength){ super(Selection.createFromStartLength(selectionOffset, selectionLength), true); }
TempSelectionAnalyzer(int selectionOffset, int selectionLength){ super(Selection.createFromStartLength(selectionOffset, selectionLength), true); }
private ASTVisitor createVisitor() throws CoreException { fAnalyzer= new ExtractMethodAnalyzer(fCUnit, Selection.createFromStartLength(fSelectionStart, fSelectionLength)); return fAnalyzer; }
private ASTVisitor createVisitor() throws CoreException { fAnalyzer = new ExtractMethodAnalyzer(fCUnit, Selection.createFromStartLength(fSelectionStart, fSelectionLength)); return fAnalyzer; }
private ASTVisitor createVisitor() throws CoreException { fAnalyzer= new ExtractMethodAnalyzer(fCUnit, Selection.createFromStartLength(fSelectionStart, fSelectionLength)); return fAnalyzer; }
public static SurroundWithTryCatchRefactoring create(ICompilationUnit cu, int offset, int length, boolean isMultiCatch) { return new SurroundWithTryCatchRefactoring(cu, Selection.createFromStartLength(offset, length), isMultiCatch); }
public static SurroundWithTryCatchRefactoring create(ICompilationUnit cu, int offset, int length, ISurroundWithTryCatchQuery query) { return new SurroundWithTryCatchRefactoring(cu, Selection.createFromStartLength(offset, length), query); }
public NameCollector(ASTNode node) { fSelection= Selection.createFromStartLength(node.getStartPosition(), node.getLength()); } @Override
public NameCollector(ASTNode node) { fSelection= Selection.createFromStartLength(node.getStartPosition(), node.getLength()); } protected boolean visitNode(ASTNode node) {
public static SurroundWithTryCatchRefactoring create(ICompilationUnit cu, ITextSelection selection, ISurroundWithTryCatchQuery query) { return new SurroundWithTryCatchRefactoring(cu, Selection.createFromStartLength(selection.getOffset(), selection.getLength()), query); }
public ASTNode[] resolveSelectedNodes() { if (fNodesRequested) return fSelectedNodes; fNodesRequested= true; CompilationUnit root= resolvePartialAstAtOffset(); if (root == null) return null; Selection ds= Selection.createFromStartLength(getOffset(), getLength()); SelectionAnalyzer analyzer= new SelectionAnalyzer(ds, false); root.accept(analyzer); fSelectedNodes= analyzer.getSelectedNodes(); fCoveringNode= analyzer.getLastCoveringNode(); return fSelectedNodes; }
public static boolean isApplicable(IInvocationContext context) throws CoreException { ICompilationUnit unit= context.getCompilationUnit(); CompilationUnit ast= SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_NO, null); if (ast == null) return true; Selection selection= Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()); SurroundWithAnalyzer analyzer= new SurroundWithAnalyzer(unit, selection, false); context.getASTRoot().accept(analyzer); return analyzer.getStatus().isOK() && analyzer.hasSelectedNodes(); }
public final ISourceRange getNewSelectionRange(ISourceRange oldSourceRange, ITypeRoot typeRoot) { try{ CompilationUnit root= getAST(typeRoot); if (root == null) return oldSourceRange; Selection selection= Selection.createFromStartLength(oldSourceRange.getOffset(), oldSourceRange.getLength()); SelectionAnalyzer selAnalyzer= new SelectionAnalyzer(selection, true); root.accept(selAnalyzer); return internalGetNewSelectionRange(oldSourceRange, typeRoot, selAnalyzer); } catch (JavaModelException e){ JavaPlugin.log(e); //dialog would be too heavy here return new SourceRange(oldSourceRange.getOffset(), oldSourceRange.getLength()); } }
public final ISourceRange getNewSelectionRange(ISourceRange oldSourceRange, ISourceReference sr) { try{ CompilationUnit root= getAST(sr); if (root == null) return oldSourceRange; Selection selection= Selection.createFromStartLength(oldSourceRange.getOffset(), oldSourceRange.getLength()); SelectionAnalyzer selAnalyzer= new SelectionAnalyzer(selection, true); root.accept(selAnalyzer); return internalGetNewSelectionRange(oldSourceRange, sr, selAnalyzer); } catch (JavaModelException e){ JavaPlugin.log(e); //dialog would be too heavy here return new SourceRange(oldSourceRange.getOffset(), oldSourceRange.getLength()); } }
public static boolean isApplicable(IInvocationContext context) throws CoreException { ICompilationUnit unit= context.getCompilationUnit(); CompilationUnit ast= SharedASTProviderCore.getAST(unit, SharedASTProviderCore.WAIT_NO, null); if (ast == null) return true; Selection selection= Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()); SurroundWithAnalyzer analyzer= new SurroundWithAnalyzer(unit, selection, false); context.getASTRoot().accept(analyzer); return analyzer.getStatus().isOK() && analyzer.hasSelectedNodes(); }
public static boolean isApplicable(IInvocationContext context) throws JavaModelException { ICompilationUnit unit= context.getCompilationUnit(); CompilationUnit ast= ASTProvider.getASTProvider().getAST(unit, ASTProvider.WAIT_NO, null); if (ast == null) return true; Selection selection= Selection.createFromStartLength(context.getSelectionOffset(), context.getSelectionLength()); SurroundWithAnalyzer analyzer= new SurroundWithAnalyzer(unit, selection); context.getASTRoot().accept(analyzer); return analyzer.getStatus().isOK() && analyzer.hasSelectedNodes(); }
public static RefactoringStatus checkMethodSyntaxErrors(int selectionStart, int selectionLength, CompilationUnit cuNode, String invalidSelectionMessage){ SelectionAnalyzer analyzer= new SelectionAnalyzer(Selection.createFromStartLength(selectionStart, selectionLength), true); cuNode.accept(analyzer); ASTNode coveringNode= analyzer.getLastCoveringNode(); if (! (coveringNode instanceof Block) || ! (coveringNode.getParent() instanceof MethodDeclaration)) return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); if (ASTNodes.getMessages(coveringNode, ASTNodes.NODE_ONLY).length == 0) return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); MethodDeclaration methodDecl= (MethodDeclaration)coveringNode.getParent(); String[] keys= {methodDecl.getName().getIdentifier()}; String message= Messages.format(RefactoringCoreMessages.CodeRefactoringUtil_error_message, keys); return RefactoringStatus.createFatalErrorStatus(message); }
public static RefactoringStatus checkMethodSyntaxErrors(int selectionStart, int selectionLength, CompilationUnit cuNode, String invalidSelectionMessage){ SelectionAnalyzer analyzer= new SelectionAnalyzer(Selection.createFromStartLength(selectionStart, selectionLength), true); cuNode.accept(analyzer); ASTNode coveringNode= analyzer.getLastCoveringNode(); if (! (coveringNode instanceof Block) || ! (coveringNode.getParent() instanceof MethodDeclaration)) return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); if (ASTNodes.getMessages(coveringNode, ASTNodes.NODE_ONLY).length == 0) return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); MethodDeclaration methodDecl= (MethodDeclaration)coveringNode.getParent(); String message= Messages.format(RefactoringCoreMessages.CodeRefactoringUtil_error_message, BasicElementLabels.getJavaElementName(methodDecl.getName().getIdentifier())); return RefactoringStatus.createFatalErrorStatus(message); }
public static RefactoringStatus checkMethodSyntaxErrors(int selectionStart, int selectionLength, CompilationUnit cuNode, String invalidSelectionMessage) { SelectionAnalyzer analyzer = new SelectionAnalyzer(Selection.createFromStartLength(selectionStart, selectionLength), true); cuNode.accept(analyzer); ASTNode coveringNode = analyzer.getLastCoveringNode(); if (!(coveringNode instanceof Block) || !(coveringNode.getParent() instanceof MethodDeclaration)) { return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); } if (ASTNodes.getMessages(coveringNode, ASTNodes.NODE_ONLY).length == 0) { return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); } MethodDeclaration methodDecl = (MethodDeclaration) coveringNode.getParent(); String message = Messages.format(RefactoringCoreMessages.CodeRefactoringUtil_error_message, BasicElementLabels.getJavaElementName(methodDecl.getName().getIdentifier())); return RefactoringStatus.createFatalErrorStatus(message); }
public static RefactoringStatus checkMethodSyntaxErrors(int selectionStart, int selectionLength, CompilationUnit cuNode, String invalidSelectionMessage){ SelectionAnalyzer analyzer= new SelectionAnalyzer(Selection.createFromStartLength(selectionStart, selectionLength), true); cuNode.accept(analyzer); ASTNode coveringNode= analyzer.getLastCoveringNode(); if (! (coveringNode instanceof Block) || ! (coveringNode.getParent() instanceof MethodDeclaration)) return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); if (ASTNodes.getMessages(coveringNode, ASTNodes.NODE_ONLY).length == 0) return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage); MethodDeclaration methodDecl= (MethodDeclaration)coveringNode.getParent(); String message= Messages.format(RefactoringCoreMessages.CodeRefactoringUtil_error_message, BasicElementLabels.getJavaElementName(methodDecl.getName().getIdentifier())); return RefactoringStatus.createFatalErrorStatus(message); }