1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 15:55:47 +02:00

Bug 314551 - [patch] Avoid creating children of IncludeReference when editor is closed

This commit is contained in:
Anton Leherbauer 2010-05-28 09:39:47 +00:00
parent b73f4d0539
commit c3257001ea

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2008 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems 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
@ -38,8 +38,8 @@ import org.eclipse.core.runtime.Path;
*/ */
public class IncludeReference extends Openable implements IIncludeReference { public class IncludeReference extends Openable implements IIncludeReference {
IIncludeEntry fIncludeEntry; final IIncludeEntry fIncludeEntry;
IPath fPath; final IPath fPath;
public IncludeReference(ICProject cproject, IIncludeEntry entry) { public IncludeReference(ICProject cproject, IIncludeEntry entry) {
this(cproject, entry, entry.getFullIncludePath()); this(cproject, entry, entry.getFullIncludePath());
@ -59,6 +59,20 @@ public class IncludeReference extends Openable implements IIncludeReference {
return null; return null;
} }
/*
* @see org.eclipse.cdt.internal.core.model.CElement#exists()
*/
@Override
public boolean exists() {
File file = null;
if (fPath != null) {
file = fPath.toFile();
} else if (fIncludeEntry != null) {
file = fIncludeEntry.getFullIncludePath().toFile();
}
return file != null && file.isDirectory();
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo() * @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo()
*/ */
@ -93,39 +107,39 @@ public class IncludeReference extends Openable implements IIncludeReference {
* @see org.eclipse.cdt.internal.core.model.CContainer#computeChildren(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.resources.IResource) * @see org.eclipse.cdt.internal.core.model.CContainer#computeChildren(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.resources.IResource)
*/ */
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
ArrayList<ICElement> vChildren = new ArrayList<ICElement>(); ArrayList<ICElement> vChildren = new ArrayList<ICElement>();
File file = null; File file = null;
if (fPath != null) { if (fPath != null) {
file = fPath.toFile(); file = fPath.toFile();
} else if (fIncludeEntry != null) { } else if (fIncludeEntry != null) {
file = fIncludeEntry.getFullIncludePath().toFile(); file = fIncludeEntry.getFullIncludePath().toFile();
} }
String[] names = null; String[] names = null;
if (file != null && file.isDirectory()) { if (file != null && file.isDirectory()) {
names = file.list(); names = file.list();
if (names != null) { if (names != null) {
IPath path = new Path(file.getAbsolutePath()); IPath path = new Path(file.getAbsolutePath());
for (String name : names) { for (String name : names) {
File child = new File(file, name); File child = new File(file, name);
ICElement celement = null; ICElement celement = null;
if (child.isDirectory()) { if (child.isDirectory()) {
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath())); celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
} else if (child.isFile()){ } else if (child.isFile()){
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), name); String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), name);
if (id != null) { if (id != null) {
// TODO: should use URI // TODO: should use URI
celement = new ExternalTranslationUnit(this, URIUtil.toURI(path.append(name)), id); celement = new ExternalTranslationUnit(this, URIUtil.toURI(path.append(name)), id);
}
}
if (celement != null) {
vChildren.add(celement);
} }
} }
if (celement != null) {
vChildren.add(celement);
}
} }
} }
info.setChildren(vChildren); }
return true; info.setChildren(vChildren);
return true;
} }
/* (non-Javadoc) /* (non-Javadoc)