1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Decorate absent external translation units

This commit is contained in:
John Dallaway 2023-10-10 17:43:09 +01:00
parent b0317c09ed
commit 4036cd3084
3 changed files with 57 additions and 0 deletions

View file

@ -655,6 +655,8 @@ ShiftLeftAction.label= S&hift Left
# Decorators
indexedFilesDecorator.label = C/C++ Indexed Files
indexedFilesDecorator.description = Decorates files indexed by C/C++ Indexer.
translationUnitDecorator.label = C/C++ Translation Units
translationUnitDecorator.description = Decorates C/C++ translation unit source and header files.
excludedFile.name = C/C++ Files and Folders Excluded from Build
excludedFile.description = Decorates source files and folders excluded from C/C++ build.
includeFolderDecorator.name = C/C++ Missing Include Folders

View file

@ -4428,6 +4428,17 @@
</or>
</enablement>
</decorator>
<decorator
class="org.eclipse.cdt.internal.ui.viewsupport.TranslationUnitDecorator"
id="org.eclipse.cdt.ui.translationUnit"
label="%translationUnitDecorator.label"
lightweight="true"
state="true">
<description>%translationUnitDecorator.description</description>
<enablement>
<objectClass name="org.eclipse.cdt.core.model.ITranslationUnit"/>
</enablement>
</decorator>
<decorator
adaptable="true"
class="org.eclipse.cdt.internal.ui.viewsupport.ExcludedFileDecorator"

View file

@ -0,0 +1,44 @@
/*******************************************************************************
* 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.viewsupport;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.jface.preference.JFacePreferences;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.eclipse.swt.graphics.Color;
/**
* Decorates translation unit source and header files
*/
public final class TranslationUnitDecorator extends BaseLabelProvider implements ILightweightLabelDecorator {
@Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
@Override
public void decorate(Object element, IDecoration decoration) {
// if an external translation unit source file that is not present locally
if (element instanceof ITranslationUnit tu && (null == tu.getResource()) && !tu.exists()) {
// decorate label to indicate file is absent
Color color = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
decoration.setForegroundColor(color);
}
}
}