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

Bug 47536: Add filter for forward declarations to Outline View, by Patrick Hofer.

This commit is contained in:
Markus Schorn 2010-10-06 13:46:44 +00:00
parent a0add23230
commit 3178c362a2
3 changed files with 72 additions and 0 deletions

View file

@ -319,6 +319,9 @@ HideUsingDirective.description= Hides using directives
HideMacroDirective.label= Macro directive
HideMacroDirective.description= Hides Macro directives
ForwardDeclarationFilter.label= Forward declaration
ForwardDeclarationFilter.description= Hides forward declarations, unless found in a header file.
#
WorkInProgress.name=Work In Progress
@ -553,6 +556,7 @@ preferenceKeywords.folding=editor folding section comment header function method
preferenceKeywords.markoccurrences=editor occurrence mark highlight
preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically
historyAction.label = History...
createScriptAction.label = Create Script...
applyScriptAction.label = Apply Script...

View file

@ -151,6 +151,14 @@
class="org.eclipse.cdt.internal.ui.filters.MacroDirectiveFilter"
id="org.eclipse.cdt.ui.COutlinePage.MacroDirectiveFilter">
</filter>
<filter
targetId="org.eclipse.cdt.ui.COutlinePage"
name="%ForwardDeclarationFilter.label"
enabled="false"
description="%ForwardDeclarationFilter.description"
class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter"
id="org.eclipse.cdt.ui.COutlinePage.ForwardDeclarationFilter">
</filter>
<!-- Asm Outline Page -->
<filter
targetId="org.eclipse.cdt.ui.AsmOutlinePage"

View file

@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2010 Eclipse CDT Project 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Patrick Hofer - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.filters;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* Filter for forward declarations
*/
public class ForwardDeclarationFilter extends ViewerFilter {
/*
* @see ViewerFilter
*/
@Override
public boolean select(Viewer viewer, Object parent, Object element) {
if (!(element instanceof ICElement))
return true;
final ICElement celem= (ICElement) element;
ICElement tu= celem;
while (tu != null && !(tu instanceof ITranslationUnit)) {
tu= tu.getParent();
}
// Don't filter forward declarations in header file
if (tu instanceof ITranslationUnit && ((ITranslationUnit) tu).isHeaderUnit())
return true;
switch (celem.getElementType()) {
case ICElement.C_FUNCTION_DECLARATION:
case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
case ICElement.C_STRUCT_DECLARATION:
case ICElement.C_UNION_DECLARATION:
case ICElement.C_CLASS_DECLARATION:
case ICElement.C_TEMPLATE_CLASS_DECLARATION:
case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
case ICElement.C_TEMPLATE_UNION_DECLARATION:
case ICElement.C_VARIABLE_DECLARATION:
return false;
}
return true;
}
}