1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-08-19 13:14:03 -07:00
parent 03f2299797
commit e781b4773a
6 changed files with 47 additions and 147 deletions

View file

@ -42,9 +42,9 @@ public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
* @param name the display name of the proposal.
* @param tu the translation unit that is modified.
* @param rewrite the AST rewrite that is invoked when the proposal is applied or
* <code>null</code> if {@link #getRewrite()} is overridden.
* {@code null} if {@link #getRewrite()} is overridden.
* @param relevance The relevance of this proposal.
* @param image The image that is displayed for this proposal or <code>null</code> if no
* @param image The image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
public ASTRewriteCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite, int relevance, Image image) {
@ -52,9 +52,6 @@ public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
fRewrite= rewrite;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.text.correction.TUCorrectionProposal#addEdits(org.eclipse.jface.text.IDocument)
*/
@Override
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
super.addEdits(document, editRoot);

View file

@ -12,31 +12,26 @@
package org.eclipse.cdt.internal.ui.text.correction.proposals;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.link.LinkedModeModel;
import org.eclipse.ui.IEditorPart;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.IUndoManager;
import org.eclipse.ltk.core.refactoring.NullChange;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorPart;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
@ -65,10 +60,10 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
* Constructs a change correction proposal.
*
* @param name The name that is displayed in the proposal selection dialog.
* @param change The change that is executed when the proposal is applied or <code>null</code>
* @param change The change that is executed when the proposal is applied or {@code null}
* if the change will be created by implementors of {@link #createChange()}.
* @param relevance The relevance of this proposal.
* @param image The image that is displayed for this proposal or <code>null</code> if no
* @param image The image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
public ChangeCorrectionProposal(String name, Change change, int relevance, Image image) {
@ -97,10 +92,10 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
/**
* Performs the change associated with this proposal.
*
* @param activeEditor The editor currently active or <code>null</code> if no
* editor is active.
* @param document The document of the editor currently active or <code>null</code> if
* no editor is visible.
* @param activeEditor The editor currently active or {@code null} if no
* editor is active.
* @param document The document of the editor currently active or {@code null} if
* no editor is visible.
* @throws CoreException Thrown when the invocation of the change failed.
*/
protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException {
@ -147,9 +142,6 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
}
}
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
@Override
public String getAdditionalProposalInfo() {
StringBuffer buf= new StringBuffer();
@ -174,17 +166,11 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
return buf.toString();
}
/*
* @see ICompletionProposal#getContextInformation()
*/
@Override
public IContextInformation getContextInformation() {
return null;
}
/*
* @see ICompletionProposal#getDisplayString()
*/
@Override
public String getDisplayString() {
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
@ -194,9 +180,6 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
return getName();
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension6#getStyledDisplayString()
*/
@Override
public StyledString getStyledDisplayString() {
StyledString str= new StyledString(getName());
@ -218,24 +201,18 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
return fName;
}
/*
* @see ICompletionProposal#getImage()
*/
@Override
public Image getImage() {
return fImage;
}
/*
* @see ICompletionProposal#getSelection(IDocument)
*/
@Override
public Point getSelection(IDocument document) {
return null;
}
/**
* Sets the proposal's image or <code>null</code> if no image is desired.
* Sets the proposal's image or {@code null} if no image is desired.
*
* @param image the desired image.
*/
@ -280,9 +257,6 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
fName= name;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.text.c.ICCompletionProposal#getRelevance()
*/
@Override
public int getRelevance() {
return fRelevance;
@ -290,25 +264,23 @@ public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandA
/**
* Sets the relevance.
*
* @param relevance the relevance to set
*/
public void setRelevance(int relevance) {
fRelevance= relevance;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.text.correction.IShortcutProposal#getProposalId()
*/
@Override
public String getCommandId() {
return fCommandId;
}
/**
* Set the proposal id to allow assigning a shortcut to the correction proposal.
* Sets the proposal id to allow assigning a shortcut to the correction proposal.
*
* @param commandId The proposal id for this proposal or <code>null</code> if no command
* should be assigned to this proposal.
* @param commandId The proposal id for this proposal or {@code null} if no command
* should be assigned to this proposal.
*/
public void setCommandId(String commandId) {
fCommandId= commandId;

View file

@ -26,15 +26,14 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
* @since 5.1
*/
public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal {
/**
* Constructs a linked correction proposal.
* @param name The display name of the proposal.
* @param tu The translation unit that is modified.
* @param rewrite The AST rewrite that is invoked when the proposal is applied
* <code>null</code> can be passed if {@link #getRewrite()} is overridden.
* {@code null} can be passed if {@link #getRewrite()} is overridden.
* @param relevance The relevance of this proposal.
* @param image The image that is displayed for this proposal or <code>null</code> if no
* @param image The image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
public LinkedCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite,
@ -45,10 +44,11 @@ public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal {
/**
* Adds a linked position to be shown when the proposal is applied. All position with the
* same group id are linked.
*
* @param position The position to add.
* @param isFirst If set, the proposal is jumped to first.
* @param groupID The id of the group the proposal belongs to. All proposals in the same group
* are linked.
* are linked.
*/
public void addLinkedPosition(ITrackedNodePosition position, boolean isFirst, String groupID) {
getLinkedProposalModel().getPositionGroup(groupID, true).addPosition(position, isFirst);
@ -56,6 +56,7 @@ public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal {
/**
* Sets the end position of the linked mode to the end of the passed range.
*
* @param position The position that describes the end position of the linked mode.
*/
public void setEndPosition(ITrackedNodePosition position) {
@ -64,10 +65,11 @@ public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal {
/**
* Adds a linked position proposal to the group with the given id.
*
* @param groupID The id of the group that should present the proposal
* @param proposal The string to propose.
* @param image The image to show for the position proposal or <code>null</code> if
* no image is desired.
* @param image The image to show for the position proposal or {@code null} if
* no image is desired.
*/
public void addLinkedPositionProposal(String groupID, String proposal, Image image) {
getLinkedProposalModel().getPositionGroup(groupID, true).addProposal(proposal, image, 10);

View file

@ -62,11 +62,10 @@ import org.eclipse.cdt.internal.ui.text.correction.ICommandAccess;
import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
/**
* A proposal.allowing user to edit in place all occurrences of a name.
* A proposal allowing user to edit in place all occurrences of a name.
*/
public class LinkedNamesAssistProposal implements ICCompletionProposal, ICompletionProposalExtension2,
ICompletionProposalExtension6, ICommandAccess {
/**
* An exit policy that skips Backspace and Delete at the beginning and at the end
* of a linked position, respectively.
@ -125,9 +124,6 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
fRelevance= 8;
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
*/
@Override
public void apply(final ITextViewer viewer, char trigger, int stateMask, final int offset) {
try {
@ -138,7 +134,6 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
new NullProgressMonitor(), new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
if (astRoot == null)
@ -159,14 +154,13 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
// Sort the locations starting with the one @ offset.
Arrays.sort(fLocations, new Comparator<IRegion>() {
@Override
public int compare(IRegion n1, IRegion n2) {
return rank(n1) - rank(n2);
}
/**
* Returns the absolute rank of a location. Location preceding <code>offset</code>
* Returns the absolute rank of a location. Location preceding {@code offset}
* are ranked last.
*
* @param location the location to compute the rank for
@ -174,10 +168,11 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
*/
private int rank(IRegion location) {
int relativeRank= location.getOffset() + location.getLength() - offset;
if (relativeRank < 0)
if (relativeRank < 0) {
return Integer.MAX_VALUE + relativeRank;
else
} else {
return relativeRank;
}
}
});
@ -214,46 +209,34 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
}
/**
* Returns the currently active C editor, or <code>null</code> if it
* cannot be determined.
* Returns the currently active C editor, or {@code null} if it cannot be determined.
*
* @return the currently active C editor, or <code>null</code>
* @return the currently active C editor, or {@code null}
*/
private CEditor getCEditor() {
IEditorPart part= CUIPlugin.getActivePage().getActiveEditor();
if (part instanceof CEditor)
if (part instanceof CEditor) {
return (CEditor) part;
else
} else {
return null;
}
}
/*
* @see ICompletionProposal#apply(IDocument)
*/
@Override
public void apply(IDocument document) {
// can't do anything
}
/*
* @see ICompletionProposal#getSelection(IDocument)
*/
@Override
public Point getSelection(IDocument document) {
return null;
}
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
@Override
public String getAdditionalProposalInfo() {
return CorrectionMessages.LinkedNamesAssistProposal_proposalinfo;
}
/*
* @see ICompletionProposal#getDisplayString()
*/
@Override
public String getDisplayString() {
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
@ -264,9 +247,6 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
return fLabel;
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension6#getStyledDisplayString()
*/
@Override
public StyledString getStyledDisplayString() {
StyledString str= new StyledString(fLabel);
@ -280,55 +260,34 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
return str;
}
/*
* @see ICompletionProposal#getImage()
*/
@Override
public Image getImage() {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_LINKED_RENAME);
}
/*
* @see ICompletionProposal#getContextInformation()
*/
@Override
public IContextInformation getContextInformation() {
return null;
}
/*
* @see ICCompletionProposal#getRelevance()
*/
@Override
public int getRelevance() {
return fRelevance;
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
*/
@Override
public void selected(ITextViewer textViewer, boolean smartToggle) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
*/
@Override
public void unselected(ITextViewer textViewer) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
*/
@Override
public boolean validate(IDocument document, int offset, DocumentEvent event) {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.text.correction.ICommandAccess#getCommandId()
*/
@Override
public String getCommandId() {
return ASSIST_ID;

View file

@ -45,9 +45,6 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
fRelevance= 8;
}
/*
* @see ICompletionProposal#apply(IDocument)
*/
@Override
public void apply(IDocument document) {
CRenameAction action= new CRenameAction();
@ -55,25 +52,16 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
action.run();
}
/*
* @see ICompletionProposal#getSelection(IDocument)
*/
@Override
public Point getSelection(IDocument document) {
return null;
}
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
@Override
public String getAdditionalProposalInfo() {
return CorrectionMessages.RenameRefactoringProposal_additionalInfo;
}
/*
* @see ICompletionProposal#getDisplayString()
*/
@Override
public String getDisplayString() {
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
@ -84,9 +72,6 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
return fLabel;
}
/*
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension6#getStyledDisplayString()
*/
@Override
public StyledString getStyledDisplayString() {
StyledString str= new StyledString(fLabel);
@ -100,41 +85,26 @@ public class RenameRefactoringProposal implements ICCompletionProposal, IComplet
return str;
}
/*
* @see ICompletionProposal#getImage()
*/
@Override
public Image getImage() {
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_LINKED_RENAME);
}
/*
* @see ICompletionProposal#getContextInformation()
*/
@Override
public IContextInformation getContextInformation() {
return null;
}
/*
* @see ICCompletionProposal#getRelevance()
*/
@Override
public int getRelevance() {
return fRelevance;
}
/*
* @see ICCompletionProposal#getIdString()
*/
@Override
public String getIdString() {
return getCommandId();
}
/*
* @see ICommandAccess#getCommandId()
*/
@Override
public String getCommandId() {
return ICEditorActionDefinitionIds.RENAME_ELEMENT;

View file

@ -63,7 +63,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.LinkedProposalModelPresenter;
* applied to the document when the proposal is evaluated.
* <p>
* The proposal takes care of the preview of the changes as proposal information.
* </p>
*
* @since 5.1
*/
public class TUCorrectionProposal extends ChangeCorrectionProposal {
@ -75,11 +75,11 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
*
* @param name the name that is displayed in the proposal selection dialog.
* @param tu the compilation unit on that the change works.
* @param change the change that is executed when the proposal is applied or <code>null</code>
* if implementors override {@link #addEdits(IDocument, TextEdit)} to provide
* the text edits or {@link #createTextChange()} to provide a text change.
* @param change the change that is executed when the proposal is applied or {@code null}
* if implementors override {@link #addEdits(IDocument, TextEdit)} to provide
* the text edits or {@link #createTextChange()} to provide a text change.
* @param relevance the relevance of this proposal.
* @param image the image that is displayed for this proposal or <code>null</code> if no
* @param image the image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
public TUCorrectionProposal(String name, ITranslationUnit tu, TextChange change, int relevance, Image image) {
@ -92,14 +92,14 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
/**
* Constructs a correction proposal working on a compilation unit.
* <p>Users have to override {@link #addEdits(IDocument, TextEdit)} to provide
* <p>
* Users have to override {@link #addEdits(IDocument, TextEdit)} to provide
* the text edits or {@link #createTextChange()} to provide a text change.
* </p>
*
*
* @param name The name that is displayed in the proposal selection dialog.
* @param tu The compilation unit on that the change works.
* @param relevance The relevance of this proposal.
* @param image The image that is displayed for this proposal or <code>null</code> if no
* @param image The image that is displayed for this proposal or {@code null} if no
* image is desired.
*/
protected TUCorrectionProposal(String name, ITranslationUnit tu, int relevance, Image image) {
@ -380,7 +380,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
}
/**
* Gets the text change that is invoked when the change is applied.
* Returns the text change that is invoked when the change is applied.
*
* @return returns the text change that is invoked when the change is applied.
* @throws CoreException throws an exception if accessing the change failed