mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Bug 417616 - IndexedFilesLabelProvider does work on non-CDT projects
Change-Id: Iee639c9ecb6daca06946e57546b0ec9f501655e4 Reviewed-on: https://git.eclipse.org/r/16695 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Chris Recoskie <recoskie@ca.ibm.com> Tested-by: Chris Recoskie <recoskie@ca.ibm.com> Reviewed-by: Chris Recoskie <recoskie@ca.ibm.com>
This commit is contained in:
parent
44514db3fb
commit
2001e49bf3
1 changed files with 17 additions and 4 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,17 +7,21 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.viewsupport;
|
package org.eclipse.cdt.internal.ui.viewsupport;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.viewers.IDecoration;
|
import org.eclipse.jface.viewers.IDecoration;
|
||||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||||
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
|
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
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.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -64,15 +68,24 @@ public class IndexedFilesLabelProvider implements ILightweightLabelDecorator {
|
||||||
IProject project= null;
|
IProject project= null;
|
||||||
if (element instanceof IFile) {
|
if (element instanceof IFile) {
|
||||||
final IFile file = (IFile) element;
|
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) {
|
else if (element instanceof ITranslationUnit) {
|
||||||
final ITranslationUnit tu = (ITranslationUnit) element;
|
final ITranslationUnit tu = (ITranslationUnit) element;
|
||||||
ifl= IndexLocationFactory.getIFL(tu);
|
ifl= IndexLocationFactory.getIFL(tu);
|
||||||
project= tu.getCProject().getProject();
|
project= tu.getCProject().getProject();
|
||||||
}
|
}
|
||||||
if (isIndexed(project, ifl)) {
|
if (ifl != null && isIndexed(project, ifl)) {
|
||||||
decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT);
|
decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue