mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Added ICElement.EMPTY_ARRAY constant.
This commit is contained in:
parent
bdde88fd2a
commit
2e0bd2e95b
6 changed files with 76 additions and 84 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2013 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,23 +12,25 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Common protocol for all elements provided by the C model.
|
||||
*
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICElement extends IAdaptable {
|
||||
public static final ICElement[] EMPTY_ARRAY = {};
|
||||
|
||||
/**
|
||||
* IResource from 10-20
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constant representing a C Root workspace (IWorkspaceRoot object).
|
||||
|
@ -37,19 +39,19 @@ public interface ICElement extends IAdaptable {
|
|||
static final int C_MODEL = 10;
|
||||
|
||||
/**
|
||||
* Constant representing a C project(IProject object).
|
||||
* Constant representing a C project (IProject object).
|
||||
* A C element with this type can be safely cast to <code>ICProject</code>.
|
||||
*/
|
||||
static final int C_PROJECT = 11;
|
||||
|
||||
/**
|
||||
* Constant representing a folder(ICContainer object).
|
||||
* Constant representing a folder (ICContainer object).
|
||||
* A C element with this type can be safely cast to <code>ICContainer</code>.
|
||||
*/
|
||||
static final int C_CCONTAINER = 12;
|
||||
|
||||
static final int C_BINARY = 14;
|
||||
|
||||
|
||||
static final int C_ARCHIVE = 18;
|
||||
/**
|
||||
* Virtual container serving as a place holder.
|
||||
|
@ -103,7 +105,7 @@ public interface ICElement extends IAdaptable {
|
|||
* struct C;
|
||||
*/
|
||||
static final int C_UNION_DECLARATION = 68;
|
||||
|
||||
|
||||
/**
|
||||
* Constant representing a union structure.
|
||||
*/
|
||||
|
@ -163,14 +165,14 @@ public interface ICElement extends IAdaptable {
|
|||
* a Typedef.
|
||||
*/
|
||||
static final int C_TYPEDEF = 80;
|
||||
|
||||
|
||||
/**
|
||||
* Enumerator.
|
||||
*/
|
||||
static final int C_ENUMERATOR = 81;
|
||||
|
||||
/**
|
||||
* C++ template class declaration without a definiton.
|
||||
* C++ template class declaration without a definition.
|
||||
*/
|
||||
static final int C_TEMPLATE_CLASS_DECLARATION = 82;
|
||||
|
||||
|
@ -232,7 +234,7 @@ public interface ICElement extends IAdaptable {
|
|||
|
||||
/**
|
||||
* Assembly label.
|
||||
*
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
static final int ASM_LABEL= 94;
|
||||
|
@ -243,21 +245,21 @@ public interface ICElement extends IAdaptable {
|
|||
*/
|
||||
@Deprecated
|
||||
static final int C_CLASS_CTOR = 0x100;
|
||||
|
||||
|
||||
/**
|
||||
* Modifier indicating a class destructor
|
||||
* @deprecated use {@link IMethodDeclaration#isDestructor()}
|
||||
*/
|
||||
@Deprecated
|
||||
static final int C_CLASS_DTOR = 0x200;
|
||||
|
||||
|
||||
/**
|
||||
* Modifier indicating a static storage attribute
|
||||
* @deprecated use {@link IDeclaration#isStatic()}
|
||||
*/
|
||||
@Deprecated
|
||||
static final int C_STORAGE_STATIC = 0x400;
|
||||
|
||||
|
||||
/**
|
||||
* Modifier indicating an extern storage attribute
|
||||
* @deprecated not used anymore
|
||||
|
@ -351,19 +353,19 @@ public interface ICElement extends IAdaptable {
|
|||
ICElement getParent();
|
||||
|
||||
/**
|
||||
* Returns the path to the innermost resource enclosing this element.
|
||||
* If this element is not included in an external archive,
|
||||
* the path returned is the full, absolute path to the underlying resource,
|
||||
* relative to the workbench.
|
||||
* If this element is included in an external archive,
|
||||
* Returns the path to the innermost resource enclosing this element.
|
||||
* If this element is not included in an external archive,
|
||||
* the path returned is the full, absolute path to the underlying resource,
|
||||
* relative to the workbench.
|
||||
* If this element is included in an external archive,
|
||||
* the path returned is the absolute path to the archive in the file system.
|
||||
* This is a handle-only method.
|
||||
*/
|
||||
IPath getPath();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an absolute URI corresponding to the innermost file enclosing this element.
|
||||
*
|
||||
*
|
||||
* @since 5.0
|
||||
* @return the URI corresponding to the location
|
||||
*/
|
||||
|
@ -389,7 +391,7 @@ public interface ICElement extends IAdaptable {
|
|||
|
||||
/**
|
||||
* Returns whether this C element is read-only. An element is read-only
|
||||
* if its structure cannot be modified by the C model.
|
||||
* if its structure cannot be modified by the C model.
|
||||
*
|
||||
* @return {@code true} if this element is read-only
|
||||
*/
|
||||
|
@ -409,15 +411,15 @@ public interface ICElement extends IAdaptable {
|
|||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
boolean isStructureKnown() throws CModelException;
|
||||
|
||||
|
||||
/**
|
||||
* Accept a visitor and walk the ICElement tree with it.
|
||||
*
|
||||
*
|
||||
* @param visitor
|
||||
* @throws CModelException
|
||||
*/
|
||||
void accept(ICElementVisitor visitor) throws CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of this element handle. The format of the
|
||||
* string is not specified; however, the identifier is stable across
|
||||
|
@ -426,11 +428,10 @@ public interface ICElement extends IAdaptable {
|
|||
* <p>
|
||||
* Some element types, like binaries, do not support handle identifiers and
|
||||
* return {@code null}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return the string handle identifier, or {@code null} if the element type is not supported
|
||||
* @see CoreModel#create(java.lang.String)
|
||||
*
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
String getHandleIdentifier();
|
||||
|
|
|
@ -657,7 +657,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
binaries = getBinaries(cproject);
|
||||
archives = getArchives(cproject);
|
||||
} catch (CModelException e) {
|
||||
archives = binaries = new ICElement[0];
|
||||
archives = binaries = ICElement.EMPTY_ARRAY;
|
||||
}
|
||||
ISourceRoot[] roots = null;
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -42,9 +41,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
|
|||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||
|
||||
public class SelectionConverter {
|
||||
|
||||
protected static final ICElement[] EMPTY_RESULT= new ICElement[0];
|
||||
|
||||
/**
|
||||
* Converts the selection provided by the given part into a structured selection.
|
||||
* The following conversion rules are used:
|
||||
|
@ -70,7 +66,7 @@ public class SelectionConverter {
|
|||
|
||||
/**
|
||||
* Converts objects of a structured selection to c elements if possible.
|
||||
* This is a convenience method, fully equivalent to
|
||||
* This is a convenience method, fully equivalent to
|
||||
* <code>convertSelectionToCElements(s, false)</code>.
|
||||
* @param s The structured selection
|
||||
* @return The converted selection
|
||||
|
@ -148,7 +144,7 @@ public class SelectionConverter {
|
|||
/**
|
||||
* Returns the selection adapted to IResource. Returns null if any of the
|
||||
* entries are not adaptable.
|
||||
*
|
||||
*
|
||||
* @param selection
|
||||
* the selection
|
||||
* @param resourceMask
|
||||
|
@ -232,7 +228,7 @@ public class SelectionConverter {
|
|||
/**
|
||||
* Returns whether the type of the given resource is among the specified
|
||||
* resource types.
|
||||
*
|
||||
*
|
||||
* @param resource
|
||||
* the resource
|
||||
* @param resourceMask
|
||||
|
@ -282,12 +278,12 @@ public class SelectionConverter {
|
|||
}
|
||||
}
|
||||
}
|
||||
return EMPTY_RESULT;
|
||||
return ICElement.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the text selection provided by the given editor a Java element by
|
||||
* asking the user if code reolve returned more than one result. If the selection
|
||||
* asking the user if code resolve returned more than one result. If the selection
|
||||
* doesn't cover a Java element <code>null</code> is returned.
|
||||
*/
|
||||
public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
|
||||
|
@ -300,7 +296,6 @@ public class SelectionConverter {
|
|||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the text selection provided by the given editor into an array of
|
||||
|
@ -325,11 +320,10 @@ public class SelectionConverter {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean canOperateOn(CEditor editor) {
|
||||
if (editor == null)
|
||||
return false;
|
||||
return getInput(editor) != null;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ public class CallHierarchyUI {
|
|||
*/
|
||||
private static List<CHViewPart> fLRUCallHierarchyViews= new ArrayList<CHViewPart>();
|
||||
private static int fViewCount;
|
||||
|
||||
|
||||
private static final int MAX_HISTORY_SIZE = 10;
|
||||
private static List<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
||||
|
||||
|
||||
public static void setIsJUnitTest(boolean val) {
|
||||
sIsJUnitTest= val;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class CallHierarchyUI {
|
|||
} else {
|
||||
secondaryId = viewPart.getViewSite().getSecondaryId();
|
||||
}
|
||||
|
||||
|
||||
viewPart = (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
|
||||
viewPart.setInput(input);
|
||||
return viewPart;
|
||||
|
@ -321,7 +321,7 @@ public class CallHierarchyUI {
|
|||
binding instanceof IEnumerator ||
|
||||
binding instanceof IFunction)
|
||||
return true;
|
||||
|
||||
|
||||
if (binding instanceof IVariable) {
|
||||
try {
|
||||
final IScope scope = binding.getScope();
|
||||
|
@ -356,11 +356,11 @@ public class CallHierarchyUI {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the activated view part to the head of the list.
|
||||
*
|
||||
*
|
||||
* @param view the Call Hierarchy view part
|
||||
*/
|
||||
static void callHierarchyViewActivated(CHViewPart view) {
|
||||
|
@ -370,26 +370,26 @@ public class CallHierarchyUI {
|
|||
|
||||
/**
|
||||
* Removes the closed view part from the list.
|
||||
*
|
||||
*
|
||||
* @param view the closed view part
|
||||
*/
|
||||
static void callHierarchyViewClosed(CHViewPart view) {
|
||||
fLRUCallHierarchyViews.remove(view);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the history and updates all the open views.
|
||||
*/
|
||||
static void clearHistory() {
|
||||
setHistoryEntries(new ICElement[0]);
|
||||
setHistoryEntries(ICElement.EMPTY_ARRAY);
|
||||
for (CHViewPart part : fLRUCallHierarchyViews) {
|
||||
part.setInput(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first Call Hierarchy view part instance that is not pinned.
|
||||
*
|
||||
*
|
||||
* @param page the active page
|
||||
* @return the Call Hierarchy view part to open or <code>null</code> if none found
|
||||
*/
|
||||
|
@ -417,16 +417,16 @@ public class CallHierarchyUI {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static public ICElement[] getHistoryEntries() {
|
||||
return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
|
||||
}
|
||||
|
||||
|
||||
static public void setHistoryEntries(ICElement[] remaining) {
|
||||
fHistoryEntries.clear();
|
||||
fHistoryEntries.addAll(Arrays.asList(remaining));
|
||||
}
|
||||
|
||||
|
||||
static public void updateHistory(ICElement input) {
|
||||
if (input != null) {
|
||||
fHistoryEntries.remove(input);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.search.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,24 +29,24 @@ import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
|||
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||
|
||||
public abstract class FindInWorkingSetAction extends FindAction {
|
||||
|
||||
|
||||
private IWorkingSet[] fWorkingSets;
|
||||
private String scopeDescription = ""; //$NON-NLS-1$
|
||||
|
||||
|
||||
public FindInWorkingSetAction(CEditor editor, String label, String tooltip, IWorkingSet[] workingSets) {
|
||||
super(editor);
|
||||
setText(label);
|
||||
setToolTipText(tooltip);
|
||||
setText(label);
|
||||
setToolTipText(tooltip);
|
||||
fWorkingSets = workingSets;
|
||||
}
|
||||
|
||||
|
||||
public FindInWorkingSetAction(IWorkbenchSite site, String label, String tooltip, IWorkingSet[] workingSets){
|
||||
super(site);
|
||||
setText(label);
|
||||
setToolTipText(tooltip);
|
||||
setText(label);
|
||||
setToolTipText(tooltip);
|
||||
fWorkingSets= workingSets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
final public void run() {
|
||||
IWorkingSet[] initial= fWorkingSets;
|
||||
|
@ -54,7 +54,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
|||
fWorkingSets= askForWorkingSets();
|
||||
}
|
||||
if (fWorkingSets != null) {
|
||||
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(fWorkingSets));
|
||||
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(fWorkingSets));
|
||||
super.run();
|
||||
}
|
||||
fWorkingSets= initial;
|
||||
|
@ -68,7 +68,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
|||
@Override
|
||||
final protected ICElement[] getScope() {
|
||||
if (fWorkingSets == null) {
|
||||
return new ICElement[0];
|
||||
return ICElement.EMPTY_ARRAY;
|
||||
}
|
||||
List<ICElement> scope = new ArrayList<ICElement>();
|
||||
for (int i = 0; i < fWorkingSets.length; ++i) {
|
||||
|
@ -79,13 +79,13 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
|||
scope.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return scope.toArray(new ICElement[scope.size()]);
|
||||
}
|
||||
|
||||
|
||||
private IWorkingSet[] askForWorkingSets() {
|
||||
IWorkingSetManager wsm= PlatformUI.getWorkbench().getWorkingSetManager();
|
||||
IWorkingSetSelectionDialog dlg=
|
||||
IWorkingSetSelectionDialog dlg=
|
||||
wsm.createWorkingSetSelectionDialog(getSite().getShell(), true);
|
||||
IWorkingSet[] mru= wsm.getRecentWorkingSets();
|
||||
if (mru != null && mru.length > 0) {
|
||||
|
|
|
@ -24,19 +24,18 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
|
||||
public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
||||
|
||||
public static class ClearHistoryAction extends Action {
|
||||
|
||||
public static class ClearHistoryAction extends Action {
|
||||
private THViewPart fView;
|
||||
|
||||
|
||||
public ClearHistoryAction(THViewPart view) {
|
||||
super(Messages.THHistoryDropDownAction_ClearHistory);
|
||||
fView= view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
fView.setHistoryEntries(new ICElement[0]);
|
||||
fView.setHistoryEntries(ICElement.EMPTY_ARRAY);
|
||||
fView.setInput(null, null);
|
||||
}
|
||||
}
|
||||
|
@ -45,11 +44,11 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
|||
|
||||
private THViewPart fHierarchyView;
|
||||
private Menu fMenu;
|
||||
|
||||
|
||||
public THHistoryDropDownAction(THViewPart viewPart) {
|
||||
fHierarchyView= viewPart;
|
||||
fMenu= null;
|
||||
setToolTipText(Messages.THHistoryDropDownAction_tooltip);
|
||||
setToolTipText(Messages.THHistoryDropDownAction_tooltip);
|
||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
|
||||
setMenuCreator(this);
|
||||
}
|
||||
|
@ -81,10 +80,10 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
|||
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
|
||||
return fMenu;
|
||||
}
|
||||
|
||||
|
||||
private boolean addEntries(Menu menu, ICElement[] elements) {
|
||||
boolean checked= false;
|
||||
|
||||
|
||||
int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
|
||||
for (int i= 0; i < min; i++) {
|
||||
THHistoryAction action= new THHistoryAction(fHierarchyView, elements[i]);
|
||||
|
@ -92,11 +91,9 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
|||
checked= checked || action.isChecked();
|
||||
addActionToMenu(menu, action);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return checked;
|
||||
}
|
||||
|
||||
|
||||
protected void addActionToMenu(Menu parent, Action action) {
|
||||
ActionContributionItem item= new ActionContributionItem(action);
|
||||
|
|
Loading…
Add table
Reference in a new issue