mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fix and NPE in the IncludeEntry
This commit is contained in:
parent
9cc4fa6e5a
commit
be49f6a48f
7 changed files with 52 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2004-04-28 Alain Magloire
|
||||||
|
|
||||||
|
NPE in the PathEntry.
|
||||||
|
|
||||||
2004-04-28 Alain Magloire
|
2004-04-28 Alain Magloire
|
||||||
|
|
||||||
Work in Progress for the PathEntry API
|
Work in Progress for the PathEntry API
|
||||||
|
|
|
@ -70,4 +70,11 @@ public interface ILibraryEntry extends IPathEntry {
|
||||||
*/
|
*/
|
||||||
IPath getBaseReference();
|
IPath getBaseReference();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the complete path, equivalent to:
|
||||||
|
* getBasepath().append(getPath());
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPath getFullLibraryPath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
||||||
|
@ -22,7 +24,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
||||||
public IncludeEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includePath, boolean isSystemInclude,
|
public IncludeEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includePath, boolean isSystemInclude,
|
||||||
IPath[] exclusionPatterns, boolean isExported) {
|
IPath[] exclusionPatterns, boolean isExported) {
|
||||||
super(IIncludeEntry.CDT_INCLUDE, basePath, baseRef, resourcePath, exclusionPatterns, isExported);
|
super(IIncludeEntry.CDT_INCLUDE, basePath, baseRef, resourcePath, exclusionPatterns, isExported);
|
||||||
this.includePath = includePath;
|
this.includePath = (includePath == null) ? EMPTY_PATH : includePath;
|
||||||
this.isSystemInclude = isSystemInclude;
|
this.isSystemInclude = isSystemInclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +82,18 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
||||||
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
|
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
|
||||||
*/
|
*/
|
||||||
public IPath getFullIncludePath() {
|
public IPath getFullIncludePath() {
|
||||||
return basePath.append(includePath);
|
IPath p = (!basePath.isEmpty()) ? basePath.append(includePath) : includePath;
|
||||||
|
if (p.isAbsolute()) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p);
|
||||||
|
if (res != null) {
|
||||||
|
IPath location = res.getLocation();
|
||||||
|
if (location != null) {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
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.CoreModelUtil;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -40,7 +41,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public IncludeReference(ICProject cproject, IIncludeEntry entry) {
|
public IncludeReference(ICProject cproject, IIncludeEntry entry) {
|
||||||
this(cproject, entry, entry.getIncludePath());
|
this(cproject, entry, entry.getFullIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IncludeReference(ICElement celement, IIncludeEntry entry, IPath path) {
|
public IncludeReference(ICElement celement, IIncludeEntry entry, IPath path) {
|
||||||
|
@ -94,7 +95,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
if (fPath != null) {
|
if (fPath != null) {
|
||||||
file = fPath.toFile();
|
file = fPath.toFile();
|
||||||
} else if (fIncludeEntry != null) {
|
} else if (fIncludeEntry != null) {
|
||||||
file = fIncludeEntry.getIncludePath().toFile();
|
file = fIncludeEntry.getFullIncludePath().toFile();
|
||||||
}
|
}
|
||||||
String[] names = null;
|
String[] names = null;
|
||||||
if (file != null && file.isDirectory()) {
|
if (file != null && file.isDirectory()) {
|
||||||
|
@ -108,7 +109,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
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 (CoreModel.isValidTranslationUnitName(names[i]) && child.isFile()) {
|
||||||
celement = new ExternalTranslationUnit(this, path.append(names[i]));
|
celement = new ExternalTranslationUnit(this, path.append(names[i]));
|
||||||
}
|
}
|
||||||
if (celement != null) {
|
if (celement != null) {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class LibraryEntry extends APathEntry implements ILibraryEntry {
|
public class LibraryEntry extends APathEntry implements ILibraryEntry {
|
||||||
|
@ -119,7 +121,20 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPath getFullLibaryPath() {
|
public IPath getFullLibraryPath() {
|
||||||
return basePath.append(getPath());
|
IPath lib = getPath();
|
||||||
|
IPath p = (!basePath.isEmpty()) ? basePath.append(lib) : lib;
|
||||||
|
if (p.isAbsolute()) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(p);
|
||||||
|
if (res != null) {
|
||||||
|
IPath location = res.getLocation();
|
||||||
|
if (location != null) {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc
|
||||||
ILibraryEntry entry;
|
ILibraryEntry entry;
|
||||||
|
|
||||||
public LibraryReferenceArchive(ICElement parent, ILibraryEntry e, IBinaryArchive ar) {
|
public LibraryReferenceArchive(ICElement parent, ILibraryEntry e, IBinaryArchive ar) {
|
||||||
super(parent, e.getPath(), ar);
|
super(parent, e.getFullLibraryPath(), ar);
|
||||||
entry = e;
|
entry = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc
|
||||||
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
||||||
*/
|
*/
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
return entry.getPath();
|
return entry.getFullLibraryPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LibraryReferenceShared extends Binary implements ILibraryReference
|
||||||
ILibraryEntry entry;
|
ILibraryEntry entry;
|
||||||
|
|
||||||
public LibraryReferenceShared(ICElement parent, ILibraryEntry e, IBinaryObject bin) {
|
public LibraryReferenceShared(ICElement parent, ILibraryEntry e, IBinaryObject bin) {
|
||||||
super(parent, e.getPath(), bin);
|
super(parent, e.getFullLibraryPath(), bin);
|
||||||
entry = e;
|
entry = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class LibraryReferenceShared extends Binary implements ILibraryReference
|
||||||
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
||||||
*/
|
*/
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
return entry.getPath();
|
return entry.getFullLibraryPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue