From 2001e49bf37585ec6d0b38f0efc8d52918041dd1 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Mon, 23 Sep 2013 10:54:33 -0400 Subject: [PATCH] Bug 417616 - IndexedFilesLabelProvider does work on non-CDT projects Change-Id: Iee639c9ecb6daca06946e57546b0ec9f501655e4 Reviewed-on: https://git.eclipse.org/r/16695 Reviewed-by: Sergey Prigogin IP-Clean: Chris Recoskie Tested-by: Chris Recoskie Reviewed-by: Chris Recoskie --- .../IndexedFilesLabelProvider.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java index c163f9cf9a0..79dc1e7e7f7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2013 Wind River Systems, Inc. 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 @@ -7,17 +7,21 @@ * * Contributors: * Markus Schorn - initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.internal.ui.viewsupport; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ILightweightLabelDecorator; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.cdt.core.CCProjectNature; +import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -64,15 +68,24 @@ public class IndexedFilesLabelProvider implements ILightweightLabelDecorator { IProject project= null; if (element instanceof IFile) { final IFile file = (IFile) element; - ifl= IndexLocationFactory.getWorkspaceIFL(file); - project= file.getProject(); + project= file.getProject(); + + try { + if (project.hasNature(CProjectNature.C_NATURE_ID) + || project.hasNature(CCProjectNature.CC_NATURE_ID)) { + ifl = IndexLocationFactory.getWorkspaceIFL(file); + } + } catch (CoreException e) { + CUIPlugin.log(e); + } + } else if (element instanceof ITranslationUnit) { final ITranslationUnit tu = (ITranslationUnit) element; ifl= IndexLocationFactory.getIFL(tu); project= tu.getCProject().getProject(); } - if (isIndexed(project, ifl)) { + if (ifl != null && isIndexed(project, ifl)) { decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT); } }