Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide viewer filter for absent C/C++ translation unit files #597

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/org.eclipse.cdt.ui/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions core/org.eclipse.cdt.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4203,6 +4203,12 @@
description="%HideNonCElements.description"
id="org.eclipse.cdt.ui.navigator.filters.NonCElementFilter"
name="%HideNonCElements.label"/>
<commonFilter
activeByDefault="true"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonahgraham how shall we proceed on a final decision regarding default activation state of this filter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no one objects, I think active by default as the change makes it visible and it is easy enough to restore old behavior. It is hard for users to discover new features, and if we don't activate by default most people won't find it.

If someone objects, then we can have a formal vote on cdt-dev.

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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

}