mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Cosmetics.
This commit is contained in:
parent
9d2804b6a0
commit
eaabc8eb34
7 changed files with 44 additions and 69 deletions
|
@ -123,14 +123,13 @@ public interface ILanguage extends IAdaptable {
|
|||
throws CoreException;
|
||||
|
||||
/**
|
||||
* Return the AST completion node for the given offset.
|
||||
* Returns the AST completion node for the given offset.
|
||||
* @since 5.2
|
||||
*/
|
||||
public IASTCompletionNode getCompletionNode(FileContent reader, IScannerInfo scanInfo,
|
||||
IncludeFileContentProvider fileCreator, IIndex index, IParserLogService log, int offset)
|
||||
throws CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Used to override the default model building behavior for a translation unit.
|
||||
*
|
||||
|
|
|
@ -468,11 +468,10 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException;
|
||||
|
||||
/**
|
||||
* Return the completion node using the given index and parsing style at the given offset.
|
||||
* Returns the completion node using the given index and parsing style at the given offset.
|
||||
*/
|
||||
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getSharedWorkingCopy(IProgressMonitor, IProblemRequestor)},
|
||||
* or CDTUITools.getWorkingCopyManager() instead.
|
||||
|
|
|
@ -213,7 +213,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Create the parser.
|
||||
* Creates the parser.
|
||||
*
|
||||
* @param scanner the IScanner to get tokens from
|
||||
* @param log the parser log service
|
||||
|
|
|
@ -57,7 +57,6 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationCo
|
|||
import org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer;
|
||||
|
||||
public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownDelegate2 {
|
||||
|
||||
public static final String SURROUND_WITH_QUICK_MENU_ACTION_ID= "org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"; //$NON-NLS-1$
|
||||
|
||||
private static final String C_TEMPLATE_PREFERENCE_PAGE_ID= "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
|
||||
|
@ -67,14 +66,10 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$
|
||||
|
||||
private static class ConfigureTemplatesAction extends Action {
|
||||
|
||||
public ConfigureTemplatesAction() {
|
||||
super(ActionMessages.SurroundWithTemplateMenuAction_ConfigureTemplatesActionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
PreferencesUtil.createPreferenceDialogOn(getShell(), C_TEMPLATE_PREFERENCE_PAGE_ID, new String[] {C_TEMPLATE_PREFERENCE_PAGE_ID}, null).open();
|
||||
|
@ -90,6 +85,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
public void run() {
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
|
@ -99,7 +95,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
private Menu fMenu;
|
||||
private IPartService fPartService;
|
||||
private IPartListener fPartListener= new IPartListener() {
|
||||
|
||||
@Override
|
||||
public void partActivated(IWorkbenchPart part) {
|
||||
}
|
||||
|
@ -135,9 +130,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Menu getMenu(Menu parent) {
|
||||
setMenu(new Menu(parent));
|
||||
|
@ -146,9 +138,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
return fMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Menu getMenu(Control parent) {
|
||||
setMenu(new Menu(parent));
|
||||
|
@ -171,9 +160,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
menu.add(new ConfigureTemplatesAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (fPartService != null) {
|
||||
|
@ -183,9 +169,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
setMenu(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void init(IWorkbenchWindow window) {
|
||||
if (fPartService != null) {
|
||||
|
@ -202,9 +185,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run(IAction action) {
|
||||
IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
|
||||
|
@ -221,9 +201,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
}.createMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
// Default do nothing
|
||||
|
@ -234,7 +211,6 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
* @param menu the menu to fill entries into it
|
||||
*/
|
||||
protected void fillMenu(Menu menu) {
|
||||
|
||||
IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
|
||||
if (!(activePart instanceof CEditor)) {
|
||||
ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
|
||||
|
@ -242,7 +218,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
return;
|
||||
}
|
||||
|
||||
CEditor editor= (CEditor)activePart;
|
||||
CEditor editor= (CEditor) activePart;
|
||||
IAction[] actions= getTemplateActions(editor);
|
||||
|
||||
if ( actions == null || actions.length <= 0) {
|
||||
|
@ -267,9 +243,9 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
fMenu.addMenuListener(new MenuAdapter() {
|
||||
@Override
|
||||
public void menuShown(MenuEvent e) {
|
||||
Menu m = (Menu)e.widget;
|
||||
Menu m = (Menu) e.widget;
|
||||
MenuItem[] items = m.getItems();
|
||||
for (int i=0; i < items.length; i++) {
|
||||
for (int i= 0; i < items.length; i++) {
|
||||
items[i].dispose();
|
||||
}
|
||||
fillMenu(m);
|
||||
|
@ -319,21 +295,19 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
return (ITextSelection)selection;
|
||||
}
|
||||
|
||||
private static IAction[] getActionsFromProposals(List<ICompletionProposal> proposals, final int offset, final ITextViewer viewer) {
|
||||
List<Action> result= new ArrayList<Action>();
|
||||
private static IAction[] getActionsFromProposals(List<ICompletionProposal> proposals, final int offset,
|
||||
final ITextViewer viewer) {
|
||||
List<Action> result= new ArrayList<>();
|
||||
int j = 1;
|
||||
for (Iterator<ICompletionProposal> it= proposals.iterator(); it.hasNext();) {
|
||||
final ICompletionProposal proposal= it.next();
|
||||
|
||||
StringBuffer actionName= new StringBuffer();
|
||||
StringBuilder actionName= new StringBuilder();
|
||||
if (j < 10) {
|
||||
actionName.append('&').append(j).append(' ');
|
||||
}
|
||||
actionName.append(proposal.getDisplayString());
|
||||
Action action= new Action(actionName.toString()) {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
applyProposal(proposal, viewer, (char)0, 0, offset);
|
||||
|
@ -343,19 +317,19 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD
|
|||
result.add(action);
|
||||
j++;
|
||||
}
|
||||
if (result.size() == 0)
|
||||
if (result.isEmpty())
|
||||
return null;
|
||||
|
||||
return result.toArray(new IAction[result.size()]);
|
||||
}
|
||||
|
||||
private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger, int stateMask, final int offset) {
|
||||
private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger,
|
||||
int stateMask, final int offset) {
|
||||
Assert.isTrue(proposal instanceof ICompletionProposalExtension2);
|
||||
|
||||
IRewriteTarget target= null;
|
||||
IEditingSupportRegistry registry= null;
|
||||
IEditingSupport helper= new IEditingSupport() {
|
||||
|
||||
@Override
|
||||
public boolean isOriginator(DocumentEvent event, IRegion focus) {
|
||||
return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset;
|
||||
|
|
|
@ -78,12 +78,17 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
|
|||
@Override
|
||||
protected IASTCompletionNode calculateValue() {
|
||||
int offset = getParseOffset();
|
||||
if (offset < 0) return null;
|
||||
if (offset < 0)
|
||||
return null;
|
||||
|
||||
ICProject proj= getProject();
|
||||
if (proj == null) return null;
|
||||
if (proj == null)
|
||||
return null;
|
||||
|
||||
try {
|
||||
if (fIndex != null)
|
||||
throw new IllegalStateException("The method should not be called multiple times."); //$NON-NLS-1$
|
||||
|
||||
IIndexManager manager= CCorePlugin.getIndexManager();
|
||||
fIndex = manager.getIndex(proj, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST);
|
||||
|
||||
|
@ -201,18 +206,19 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
|
|||
* @param editor the editor that content assist is invoked in
|
||||
* @param isAutoActivated indicates whether content assist was auto-activated
|
||||
*/
|
||||
public CContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor, boolean isCompletion, boolean isAutoActivated) {
|
||||
public CContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor,
|
||||
boolean isCompletion, boolean isAutoActivated) {
|
||||
super(viewer, offset);
|
||||
Assert.isNotNull(editor);
|
||||
fEditor= editor;
|
||||
fIsCompletion= isCompletion;
|
||||
fIsAutoActivated= isAutoActivated;
|
||||
fTU = new Lazy<ITranslationUnit>() {
|
||||
@Override
|
||||
protected ITranslationUnit calculateValue() {
|
||||
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
|
||||
}
|
||||
};
|
||||
@Override
|
||||
protected ITranslationUnit calculateValue() {
|
||||
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,13 +264,13 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
|
|||
|
||||
@Override
|
||||
public IASTCompletionNode getCompletionNode() {
|
||||
//for scalability
|
||||
// For scalability.
|
||||
if (fEditor != null && fEditor instanceof CEditor) {
|
||||
CEditor editor = (CEditor)fEditor;
|
||||
CEditor editor = (CEditor) fEditor;
|
||||
|
||||
// check to make sure we should attempt local parsing completions... for remote projects
|
||||
// we should not do this
|
||||
if(!editor.shouldProcessLocalParsingCompletions()) {
|
||||
// Check to make sure we should attempt local parsing completions... for remote projects
|
||||
// we should not do this.
|
||||
if (!editor.shouldProcessLocalParsingCompletions()) {
|
||||
return null;
|
||||
}
|
||||
if (editor.isEnableScalablilityMode()) {
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
/**
|
||||
* This class represents a field or variable which shall be initialized lazily when accessed the
|
||||
* first time. It's value is computed once by the <code>calculateValue()</code> method. The value is
|
||||
* accessed by <code>value()</code>.
|
||||
* This class represents a field or variable which shall be initialized lazily when accessed
|
||||
* the first time. It's value is computed once by the {@code calculateValue()} method. The value is
|
||||
* accessed by {@code value()}.
|
||||
*
|
||||
* This implementation is NOT thread-safe!
|
||||
*
|
||||
* @param <E> The type of the lazy initialized variable.
|
||||
*/
|
||||
public abstract class Lazy<E> {
|
||||
private final static Object NOT_INITIALIZED = new Object();
|
||||
private static final Object NOT_INITIALIZED = new Object();
|
||||
private Object value = NOT_INITIALIZED;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -35,8 +34,7 @@ import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
|
|||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public abstract class ParsingBasedProposalComputer implements ICompletionProposalComputer {
|
||||
|
||||
private String fErrorMessage = null;
|
||||
private String fErrorMessage;
|
||||
|
||||
@Override
|
||||
public List<ICompletionProposal> computeCompletionProposals(
|
||||
|
@ -72,8 +70,7 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
|
|||
public List<IContextInformation> computeContextInformation(
|
||||
ContentAssistInvocationContext context, IProgressMonitor monitor) {
|
||||
Collection<ICompletionProposal> proposals= computeCompletionProposals(context, monitor);
|
||||
// remove duplicates
|
||||
|
||||
// Remove duplicates
|
||||
proposals= (new LinkedHashSet<ICompletionProposal>(proposals));
|
||||
List<IContextInformation> result= new ArrayList<IContextInformation>();
|
||||
for (ICompletionProposal proposal : proposals) {
|
||||
|
@ -101,11 +98,11 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
|
|||
}
|
||||
|
||||
/**
|
||||
* Compute base relevance depending on quality of name / prefix match.
|
||||
* Computes base relevance depending on quality of name / prefix match.
|
||||
*
|
||||
* @param prefix the completion pefix
|
||||
* @param prefix the completion prefix
|
||||
* @param match the matching identifier
|
||||
* @return a relevance value inidicating the quality of the name match
|
||||
* @return a relevance value indicating the quality of the name match
|
||||
*/
|
||||
protected int computeBaseRelevance(String prefix, String match) {
|
||||
boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
|
||||
|
|
Loading…
Add table
Reference in a new issue