private void generate(IType type, IField[] getterFields, IField[] setterFields, IField[] getterSetterFields, CompilationUnit unit, IJavaElement elementPosition) throws CoreException { if (getterFields.length == 0 && setterFields.length == 0 && getterSetterFields.length == 0) return; ICompilationUnit cu= null; if (getterFields.length != 0) cu= getterFields[0].getCompilationUnit(); else if (setterFields.length != 0) cu= setterFields[0].getCompilationUnit(); else cu= getterSetterFields[0].getCompilationUnit(); // open the editor, forces the creation of a working copy run(cu, type, getterFields, setterFields, getterSetterFields, JavaUI.openInEditor(cu), unit, elementPosition); }
private void generate(IType type, IField[] getterFields, IField[] setterFields, IField[] getterSetterFields, CompilationUnit unit, IJavaElement elementPosition) throws CoreException { if (getterFields.length == 0 && setterFields.length == 0 && getterSetterFields.length == 0) return; ICompilationUnit cu= null; if (getterFields.length != 0) cu= getterFields[0].getCompilationUnit(); else if (setterFields.length != 0) cu= setterFields[0].getCompilationUnit(); else cu= getterSetterFields[0].getCompilationUnit(); // open the editor, forces the creation of a working copy run(cu, type, getterFields, setterFields, getterSetterFields, JavaUI.openInEditor(cu), unit, elementPosition); }
private void generate(IType type, IField[] getterFields, IField[] setterFields, IField[] getterSetterFields, CompilationUnit unit, IJavaElement elementPosition) throws CoreException { if (getterFields.length == 0 && setterFields.length == 0 && getterSetterFields.length == 0) return; ICompilationUnit cu= null; if (getterFields.length != 0) cu= getterFields[0].getCompilationUnit(); else if (setterFields.length != 0) cu= setterFields[0].getCompilationUnit(); else cu= getterSetterFields[0].getCompilationUnit(); // open the editor, forces the creation of a working copy run(cu, type, getterFields, setterFields, getterSetterFields, JavaUI.openInEditor(cu), unit, elementPosition); }
private CompilationUnitRewrite getCuRewrite(ICompilationUnit cu) { CompilationUnitRewrite cuRewrite; if (cu.equals(fSelectionCu)) { cuRewrite= fSelectionCuRewrite; } else if (cu.equals(fField.getCompilationUnit())) { cuRewrite= fDeclarationCuRewrite; } else { cuRewrite= new CompilationUnitRewrite(cu); } return cuRewrite; }
private CompilationUnitRewrite getCuRewrite(ICompilationUnit cu) { CompilationUnitRewrite cuRewrite; if (cu.equals(fSelectionCu)) { cuRewrite= fSelectionCuRewrite; } else if (cu.equals(fField.getCompilationUnit())) { cuRewrite= fDeclarationCuRewrite; } else { cuRewrite= new CompilationUnitRewrite(cu); } return cuRewrite; }
public GetterSetterCompletionProposal(IField field, int start, int length, boolean isGetter, int relevance) throws JavaModelException { super("", field.getCompilationUnit(), start, length, JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC), getDisplayName(field, isGetter), relevance); //$NON-NLS-1$ Assert.isNotNull(field); fField= field; fIsGetter= isGetter; setProposalInfo(new ProposalInfo(field)); }
public GetterSetterCompletionProposal(IField field, int start, int length, boolean isGetter, int relevance) throws JavaModelException { super("", field.getCompilationUnit(), start, length, JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC), getDisplayName(field, isGetter), relevance); //$NON-NLS-1$ Assert.isNotNull(field); fField= field; fIsGetter= isGetter; setProposalInfo(new ProposalInfo(field)); }
private String createFieldComment(IField field, String lineDelimiter) throws JavaModelException, CoreException { String typeName= Signature.toString(field.getTypeSignature()); String fieldName= field.getElementName(); return CodeGeneration.getFieldComment(field.getCompilationUnit(), typeName, fieldName, lineDelimiter); }
private String createFieldComment(IField field, String lineDelimiter) throws JavaModelException, CoreException { String typeName= Signature.toString(field.getTypeSignature()); String fieldName= field.getElementName(); return CodeGeneration.getFieldComment(field.getCompilationUnit(), typeName, fieldName, lineDelimiter); }
private String createFieldComment(IField field, String lineDelimiter) throws JavaModelException, CoreException { String typeName= Signature.toString(field.getTypeSignature()); String fieldName= field.getElementName(); return CodeGeneration.getFieldComment(field.getCompilationUnit(), typeName, fieldName, lineDelimiter); }
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IField primary= (IField) fField.getPrimaryElement(); if (primary == null || !primary.exists()) { String message= Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_deleted, BasicElementLabels.getFileName(fField.getCompilationUnit())); return RefactoringStatus.createFatalErrorStatus(message); } fField= primary; return Checks.checkIfCuBroken(fField); }
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IField primary= (IField) fField.getPrimaryElement(); if (primary == null || !primary.exists()) { String message= Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_deleted, BasicElementLabels.getFileName(fField.getCompilationUnit())); return RefactoringStatus.createFatalErrorStatus(message); } fField= primary; return Checks.checkIfCuBroken(fField); }
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IField primary= (IField) fField.getPrimaryElement(); if (primary == null || !primary.exists()) { String message= Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_deleted, fField.getCompilationUnit().getElementName()); return RefactoringStatus.createFatalErrorStatus(message); } fField= primary; return Checks.checkIfCuBroken(fField); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
private void addDeclarationUpdate() throws CoreException { ISourceRange nameRange= fField.getNameRange(); TextEdit textEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName()); ICompilationUnit cu= fField.getCompilationUnit(); String groupName= RefactoringCoreMessages.RenameFieldRefactoring_Update_field_declaration; addTextEdit(fChangeManager.get(cu), groupName, textEdit); }
@Override public void run(IStructuredSelection selection) { try { Assert.isTrue(RefactoringAvailabilityTester.isInlineConstantAvailable(selection)); Object first= selection.getFirstElement(); Assert.isTrue(first instanceof IField); IField field= (IField) first; run(field.getNameRange().getOffset(), field.getNameRange().getLength(), field.getCompilationUnit()); } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_unexpected_exception); } }
@Override public void run(IStructuredSelection selection) { try { Assert.isTrue(RefactoringAvailabilityTester.isInlineConstantAvailable(selection)); Object first= selection.getFirstElement(); Assert.isTrue(first instanceof IField); IField field= (IField) first; run(field.getNameRange().getOffset(), field.getNameRange().getLength(), field.getCompilationUnit()); } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_unexpected_exception); } }
public void run(IStructuredSelection selection) { try { Assert.isTrue(RefactoringAvailabilityTester.isInlineConstantAvailable(selection)); Object first= selection.getFirstElement(); Assert.isTrue(first instanceof IField); IField field= (IField) first; run(field.getNameRange().getOffset(), field.getNameRange().getLength(), field.getCompilationUnit()); } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), RefactoringMessages.InlineConstantAction_dialog_title, RefactoringMessages.InlineConstantAction_unexpected_exception); } }