/** * Creates an status entry context for the given type root. * * @param typeRoot the type root containing the error * @return the status entry context or <code>Context.NULL_CONTEXT</code> if the * context cannot be created */ public static RefactoringStatusContext create(ITypeRoot typeRoot) { return create(typeRoot, (ISourceRange)null); }
@Override public Object getCorrespondingElement() { if (isBinary()) return getClassFile(); else return getCompilationUnit(); } }
@Override public String toString() { return getSourceRange() + " in " + super.toString(); //$NON-NLS-1$ } }
JavaStatusContext jsc= (JavaStatusContext)context; IDocument document= null; if (jsc.isBinary()) { IClassFile file= jsc.getClassFile(); IEditorInput editorInput= new InternalClassFileEditorInput(file); document= getDocument(JavaPlugin.getDefault().getClassFileDocumentProvider(), editorInput); updateTitle(file); } else { ICompilationUnit cunit= jsc.getCompilationUnit(); if (cunit.isWorkingCopy()) { try { updateTitle(cunit); setInput(document, createRegion(jsc.getSourceRange())); } else if (context instanceof JavaStringStatusContext) { updateTitle(null);
@Override protected boolean selectStatusEntry(final RefactoringStatusEntry entry) { if (fSourceFolder != null) { final IPath source= fSourceFolder.getFullPath(); final RefactoringStatusContext context= entry.getContext(); if (context instanceof JavaStatusContext) { final JavaStatusContext extended= (JavaStatusContext) context; final ICompilationUnit unit= extended.getCompilationUnit(); if (unit != null) { final IResource resource= unit.getResource(); if (resource != null && source.isPrefixOf(resource.getFullPath())) return false; } } } return super.selectStatusEntry(entry); } }
if (entry.getContext() instanceof JavaStatusContext && fEditor != null) { JavaStatusContext context= (JavaStatusContext)entry.getContext(); ISourceRange range= context.getSourceRange(); fEditor.setHighlightRange(range.getOffset(), range.getLength(), true);
/** * Creates an status entry context for the given method binding * * @param method the method binding for which the context is supposed to be created * @return the status entry context or <code>Context.NULL_CONTEXT</code> if the * context cannot be created */ public static RefactoringStatusContext create(IMethodBinding method) { return create((IMethod) method.getJavaElement()); }
@Override public String toString() { return getSourceRange() + " in " + super.toString(); //$NON-NLS-1$ } }
@Override protected boolean handleSelectionEndsIn(ASTNode node) { invalidSelection(RefactoringCoreMessages.StatementAnalyzer_doesNotCover, JavaStatusContext.create(fCUnit, node)); return super.handleSelectionEndsIn(node); }
@Override public final boolean visit(final SuperFieldAccess node) { Assert.isNotNull(node); fStatus.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_uses_super, JavaStatusContext.create(fMethod.getCompilationUnit(), node))); fResult.add(node); return false; }
@Override public boolean visit(ThisExpression node) { if (node.getQualifier() != null) { status.addFatalError( RefactoringCoreMessages.InlineMethodRefactoring_SourceAnalyzer_qualified_this_expressions, JavaStatusContext.create(fTypeRoot, node)); return false; } return true; } private ASTNode getLastNode() {
@Override protected boolean handleSelectionEndsIn(ASTNode node) { invalidSelection(RefactoringCoreMessages.StatementAnalyzer_doesNotCover, JavaStatusContext.create(fCUnit, node)); return super.handleSelectionEndsIn(node); }
protected void nonStaticAccess(ASTNode node) { fStatus.addWarning(RefactoringCoreMessages.MoveStaticMemberAnalyzer_nonStatic, JavaStatusContext.create(fCuRewrite.getCu(), node)); }
@Override public final boolean visit(final SuperMethodInvocation node) { Assert.isNotNull(node); fStatus.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_uses_super, JavaStatusContext.create(fMethod.getCompilationUnit(), node))); fResult.add(node); return false; }
@Override public final boolean visit(final ThisExpression node) { Assert.isNotNull(node); fResult.add(node); fStatus.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_this_reference, JavaStatusContext.create(fMethod.getCompilationUnit(), node))); return false; } }
private void checkExpression(RefactoringStatus status) { ASTNode[] nodes = getSelectedNodes(); if (nodes != null && nodes.length == 1) { ASTNode node = nodes[0]; if (node instanceof Type) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_type_reference, JavaStatusContext.create(fCUnit, node)); } else if (node.getLocationInParent() == SwitchCase.EXPRESSION_PROPERTY) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_switch_case, JavaStatusContext.create(fCUnit, node)); } else if (node instanceof Annotation || ASTNodes.getParent(node, Annotation.class) != null) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_from_annotation, JavaStatusContext.create(fCUnit, node)); } } }
private void checkExpression(RefactoringStatus status) { ASTNode[] nodes= getSelectedNodes(); if (nodes != null && nodes.length == 1) { ASTNode node= nodes[0]; if (node instanceof Type) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_type_reference, JavaStatusContext.create(fCUnit, node)); } else if (node.getLocationInParent() == SwitchCase.EXPRESSION_PROPERTY) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_switch_case, JavaStatusContext.create(fCUnit, node)); } else if (node instanceof Annotation || ASTNodes.getParent(node, Annotation.class) != null) { status.addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_from_annotation, JavaStatusContext.create(fCUnit, node)); } } }
private void removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] parents, ASTNode[] invocations, int index) { ASTNode invocation= invocations[index]; for (int i= 0; i < parents.length; i++) { ASTNode parent= parents[i]; while (parent != null) { if (parent == invocation) { status.addError(RefactoringCoreMessages.InlineMethodRefactoring_nestedInvocation, JavaStatusContext.create(unit, parent)); invocations[index]= null; } parent= parent.getParent(); } } }
private void removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] parents, ASTNode[] invocations, int index) { ASTNode invocation= invocations[index]; for (int i= 0; i < parents.length; i++) { ASTNode parent= parents[i]; while (parent != null) { if (parent == invocation) { status.addError(RefactoringCoreMessages.InlineMethodRefactoring_nestedInvocation, JavaStatusContext.create(unit, parent)); invocations[index]= null; } parent= parent.getParent(); } } }
@Override public boolean visit(VariableDeclarationFragment node) { boolean result = super.visit(node); if (isFirstSelectedNode(node)) { if (node.getParent() instanceof FieldDeclaration) { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_variable_declaration_fragment_from_field, JavaStatusContext.create(fCUnit, node)); } else { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_variable_declaration_fragment, JavaStatusContext.create(fCUnit, node)); } return false; } return result; }