1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 01:36: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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,13 +12,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
import java.net.URI;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import java.net.URI;
/** /**
* Common protocol for all elements provided by the C model. * 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICElement extends IAdaptable { public interface ICElement extends IAdaptable {
public static final ICElement[] EMPTY_ARRAY = {};
/** /**
* IResource from 10-20 * IResource from 10-20
*/ */
@ -37,13 +39,13 @@ public interface ICElement extends IAdaptable {
static final int C_MODEL = 10; 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>. * A C element with this type can be safely cast to <code>ICProject</code>.
*/ */
static final int C_PROJECT = 11; 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>. * A C element with this type can be safely cast to <code>ICContainer</code>.
*/ */
static final int C_CCONTAINER = 12; static final int C_CCONTAINER = 12;
@ -170,7 +172,7 @@ public interface ICElement extends IAdaptable {
static final int C_ENUMERATOR = 81; 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; static final int C_TEMPLATE_CLASS_DECLARATION = 82;
@ -426,7 +428,6 @@ public interface ICElement extends IAdaptable {
* <p> * <p>
* Some element types, like binaries, do not support handle identifiers and * Some element types, like binaries, do not support handle identifiers and
* return {@code null}. * return {@code null}.
* </p>
* *
* @return the string handle identifier, or {@code null} if the element type is not supported * @return the string handle identifier, or {@code null} if the element type is not supported
* @see CoreModel#create(java.lang.String) * @see CoreModel#create(java.lang.String)

View file

@ -657,7 +657,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
binaries = getBinaries(cproject); binaries = getBinaries(cproject);
archives = getArchives(cproject); archives = getArchives(cproject);
} catch (CModelException e) { } catch (CModelException e) {
archives = binaries = new ICElement[0]; archives = binaries = ICElement.EMPTY_ARRAY;
} }
ISourceRoot[] roots = null; ISourceRoot[] roots = null;
try { try {

View file

@ -10,7 +10,6 @@
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.actions; package org.eclipse.cdt.internal.ui.actions;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,9 +41,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
public class SelectionConverter { public class SelectionConverter {
protected static final ICElement[] EMPTY_RESULT= new ICElement[0];
/** /**
* Converts the selection provided by the given part into a structured selection. * Converts the selection provided by the given part into a structured selection.
* The following conversion rules are used: * 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 * 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. * 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 { public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
@ -301,7 +297,6 @@ public class SelectionConverter {
return candidate; return candidate;
} }
/** /**
* Converts the text selection provided by the given editor into an array of * 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 * 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) if (editor == null)
return false; return false;
return getInput(editor) != null; return getInput(editor) != null;
} }
} }

View file

@ -381,7 +381,7 @@ public class CallHierarchyUI {
* Clears the history and updates all the open views. * Clears the history and updates all the open views.
*/ */
static void clearHistory() { static void clearHistory() {
setHistoryEntries(new ICElement[0]); setHistoryEntries(ICElement.EMPTY_ARRAY);
for (CHViewPart part : fLRUCallHierarchyViews) { for (CHViewPart part : fLRUCallHierarchyViews) {
part.setInput(null); part.setInput(null);
} }

View file

@ -68,7 +68,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
@Override @Override
final protected ICElement[] getScope() { final protected ICElement[] getScope() {
if (fWorkingSets == null) { if (fWorkingSets == null) {
return new ICElement[0]; return ICElement.EMPTY_ARRAY;
} }
List<ICElement> scope = new ArrayList<ICElement>(); List<ICElement> scope = new ArrayList<ICElement>();
for (int i = 0; i < fWorkingSets.length; ++i) { 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 class THHistoryDropDownAction extends Action implements IMenuCreator {
public static class ClearHistoryAction extends Action { public static class ClearHistoryAction extends Action {
private THViewPart fView; private THViewPart fView;
public ClearHistoryAction(THViewPart view) { public ClearHistoryAction(THViewPart view) {
@ -36,7 +35,7 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
@Override @Override
public void run() { public void run() {
fView.setHistoryEntries(new ICElement[0]); fView.setHistoryEntries(ICElement.EMPTY_ARRAY);
fView.setInput(null, null); fView.setInput(null, null);
} }
} }
@ -93,11 +92,9 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
addActionToMenu(menu, action); addActionToMenu(menu, action);
} }
return checked; return checked;
} }
protected void addActionToMenu(Menu parent, Action action) { protected void addActionToMenu(Menu parent, Action action) {
ActionContributionItem item= new ActionContributionItem(action); ActionContributionItem item= new ActionContributionItem(action);
item.fill(parent, -1); item.fill(parent, -1);