mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Include Browser: Drop support for external files.
This commit is contained in:
parent
2156961db1
commit
3a46db2f34
2 changed files with 25 additions and 6 deletions
|
@ -159,12 +159,15 @@ public class CModelUtil {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CoreModel coreModel = CoreModel.getDefault();
|
CoreModel coreModel = CoreModel.getDefault();
|
||||||
ITranslationUnit tu= coreModel.createTranslationUnitFrom(preferredProject, location);
|
ITranslationUnit tu= null;
|
||||||
|
if (preferredProject != null) {
|
||||||
|
tu= coreModel.createTranslationUnitFrom(preferredProject, location);
|
||||||
|
}
|
||||||
if (tu == null) {
|
if (tu == null) {
|
||||||
ICProject[] projects= coreModel.getCModel().getCProjects();
|
ICProject[] projects= coreModel.getCModel().getCProjects();
|
||||||
for (int i = 0; i < projects.length && tu == null; i++) {
|
for (int i = 0; i < projects.length && tu == null; i++) {
|
||||||
ICProject project = projects[i];
|
ICProject project = projects[i];
|
||||||
if (!preferredProject.equals(project)) {
|
if (!project.equals(preferredProject)) {
|
||||||
tu= coreModel.createTranslationUnitFrom(project, location);
|
tu= coreModel.createTranslationUnitFrom(project, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,14 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.editors.text.ILocationProvider;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.util.CModelUtil;
|
import org.eclipse.cdt.internal.corext.util.CModelUtil;
|
||||||
|
|
||||||
|
@ -55,6 +59,9 @@ public class IBConversions {
|
||||||
if (object instanceof ITranslationUnit) {
|
if (object instanceof ITranslationUnit) {
|
||||||
return (ITranslationUnit) object;
|
return (ITranslationUnit) object;
|
||||||
}
|
}
|
||||||
|
if (object instanceof IFile) {
|
||||||
|
return CModelUtil.findTranslationUnit((IFile) object);
|
||||||
|
}
|
||||||
if (object instanceof IAdaptable) {
|
if (object instanceof IAdaptable) {
|
||||||
IAdaptable adaptable = (IAdaptable) object;
|
IAdaptable adaptable = (IAdaptable) object;
|
||||||
ITranslationUnit result= (ITranslationUnit) adaptable.getAdapter(ITranslationUnit.class);
|
ITranslationUnit result= (ITranslationUnit) adaptable.getAdapter(ITranslationUnit.class);
|
||||||
|
@ -63,9 +70,18 @@ public class IBConversions {
|
||||||
}
|
}
|
||||||
IFile file= (IFile) adaptable.getAdapter(IFile.class);
|
IFile file= (IFile) adaptable.getAdapter(IFile.class);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
result= CModelUtil.findTranslationUnit(file);
|
return CModelUtil.findTranslationUnit(file);
|
||||||
if (result != null) {
|
}
|
||||||
return result;
|
|
||||||
|
ILocationProvider locProvider= (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
|
||||||
|
if (locProvider != null) {
|
||||||
|
IPath path= locProvider.getPath(locProvider);
|
||||||
|
if (path != null) {
|
||||||
|
try {
|
||||||
|
return CModelUtil.findTranslationUnitForLocation(path, null);
|
||||||
|
} catch (CModelException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue