mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 01:45:33 +02:00
Provide viewer filter for absent C/C++ translation unit files
This commit is contained in:
parent
6e3d2da301
commit
8e5004827e
3 changed files with 39 additions and 0 deletions
|
@ -344,6 +344,9 @@ HideObjectFiles.description= Hides Object files
|
|||
HideNonCElements.label= Non-C elements
|
||||
HideNonCElements.description= Show only C elements
|
||||
|
||||
HideAbsentTranslationUnit.label=Absent C/C++ translation unit files
|
||||
HideAbsentTranslationUnit.description=Hides absent C/C++ translation unit files (eg source files of pre-built libraries)
|
||||
|
||||
HideNonCProjects.label = Non-C projects
|
||||
HideNonCProjects.description= Show only C projects
|
||||
|
||||
|
|
|
@ -4203,6 +4203,12 @@
|
|||
description="%HideNonCElements.description"
|
||||
id="org.eclipse.cdt.ui.navigator.filters.NonCElementFilter"
|
||||
name="%HideNonCElements.label"/>
|
||||
<commonFilter
|
||||
activeByDefault="true"
|
||||
class="org.eclipse.cdt.internal.ui.filters.AbsentTranslationUnitFilter"
|
||||
description="%HideAbsentTranslationUnit.description"
|
||||
id="org.eclipse.cdt.ui.navigator.filters.AbsentTranslationUnitFilter"
|
||||
name="%HideAbsentTranslationUnit.label"/>
|
||||
<commonFilter
|
||||
activeByDefault="true"
|
||||
class="org.eclipse.cdt.internal.ui.filters.AnonymousStructFilter"
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2023 John Dallaway and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* John Dallaway - initial implementation (#563)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.filters;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
|
||||
/**
|
||||
* Filters out translation unit source files that are not present locally
|
||||
*/
|
||||
public class AbsentTranslationUnitFilter extends ViewerFilter {
|
||||
|
||||
@Override
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
return !(element instanceof ITranslationUnit tu) || (null != tu.getResource()) || tu.exists();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue