1
0
Fork 0
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:
Sergey Prigogin 2013-12-11 15:18:24 -08:00
parent bdde88fd2a
commit 2e0bd2e95b
6 changed files with 76 additions and 84 deletions

View file

@ -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,13 +12,13 @@
*******************************************************************************/
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.
*
@ -26,6 +26,8 @@ import org.eclipse.core.runtime.IPath;
* @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
*/
@ -170,7 +172,7 @@ public interface ICElement extends IAdaptable {
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;
@ -426,7 +428,6 @@ 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)

View file

@ -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 {

View file

@ -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:
@ -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 {
@ -301,7 +297,6 @@ public class SelectionConverter {
return candidate;
}
/**
* Converts the text selection provided by the given editor into an array of
* C elements. If the selection doesn't cover a C element and the selection's
@ -330,6 +325,5 @@ public class SelectionConverter {
if (editor == null)
return false;
return getInput(editor) != null;
}
}

View file

@ -381,7 +381,7 @@ public class CallHierarchyUI {
* 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);
}

View file

@ -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) {

View file

@ -26,7 +26,6 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
public class THHistoryDropDownAction extends Action implements IMenuCreator {
public static class ClearHistoryAction extends Action {
private THViewPart fView;
public ClearHistoryAction(THViewPart view) {
@ -36,7 +35,7 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
@Override
public void run() {
fView.setHistoryEntries(new ICElement[0]);
fView.setHistoryEntries(ICElement.EMPTY_ARRAY);
fView.setInput(null, null);
}
}
@ -93,11 +92,9 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
addActionToMenu(menu, action);
}
return checked;
}
protected void addActionToMenu(Menu parent, Action action) {
ActionContributionItem item= new ActionContributionItem(action);
item.fill(parent, -1);