mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Bug 306879: Headers duplicated via symbolic links.
This commit is contained in:
parent
d8c47d612a
commit
38da7f7ebd
3 changed files with 35 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2002, 2010 QNX Software Systems 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
|
||||
|
@ -550,6 +550,7 @@ public class CoreModelUtil {
|
|||
*/
|
||||
public static ITranslationUnit findTranslationUnitForLocation(IPath location, ICProject preferredProject) throws CModelException {
|
||||
IFile[] files= ResourceLookup.findFilesForLocation(location);
|
||||
ResourceLookup.sortFilesByRelevance(files, preferredProject != null ? preferredProject.getProject() : null);
|
||||
boolean oneExisting= false;
|
||||
if (files.length > 0) {
|
||||
for (IFile file : files) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2010 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
|
||||
|
@ -84,6 +84,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
|
|||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -221,15 +222,27 @@ public class IBViewPart extends ViewPart
|
|||
index.acquireReadLock();
|
||||
try {
|
||||
if (!IndexUI.isIndexed(index, input)) {
|
||||
final String msg = IndexUI.getFileNotIndexedMessage(input);
|
||||
display.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (fTreeViewer.getInput() == input) {
|
||||
setMessage(msg);
|
||||
fTreeViewer.setInput(null);
|
||||
// Bug 306879: Try to find an alternative translation unit for the file by the location.
|
||||
final ITranslationUnit alt= CoreModelUtil.findTranslationUnitForLocation(input.getLocation(), input.getCProject());
|
||||
if (alt != null && IndexUI.isIndexed(index, alt)) {
|
||||
display.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (fTreeViewer.getInput() == input) {
|
||||
setInput(alt);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
final String msg = IndexUI.getFileNotIndexedMessage(input);
|
||||
display.asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (fTreeViewer.getInput() == input) {
|
||||
setMessage(msg);
|
||||
fTreeViewer.setInput(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
} finally {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2010 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
|
||||
|
@ -33,7 +33,6 @@ import org.eclipse.ui.IEditorInput;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
|
@ -329,10 +328,19 @@ public class IndexUI {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ITranslationUnit getTranslationUnit(ICProject cproject, IName name) {
|
||||
public static ITranslationUnit getTranslationUnit(ICProject cproject, IASTName name) {
|
||||
return getTranslationUnit(cproject, name.getFileLocation());
|
||||
}
|
||||
|
||||
public static ITranslationUnit getTranslationUnit(ICProject cproject, IIndexName name) {
|
||||
try {
|
||||
return CoreModelUtil.findTranslationUnitForLocation(name.getFile().getLocation(), cproject);
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ITranslationUnit getTranslationUnit(ICProject cproject, final IASTFileLocation fileLocation) {
|
||||
if (fileLocation != null) {
|
||||
IPath path= Path.fromOSString(fileLocation.getFileName());
|
||||
|
|
Loading…
Add table
Reference in a new issue