mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Added a method that returns a complete include name. Intended for use by Add Include.
This commit is contained in:
parent
bd8ccf7396
commit
0d0465f611
2 changed files with 28 additions and 15 deletions
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
|
||||||
|
@ -57,8 +58,16 @@ public interface IIndexInclude {
|
||||||
String getName() throws CoreException;
|
String getName() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the character offset of the name of the include in its source file. The name does
|
* Returns the name of the include. The name does not include the enclosing quotes
|
||||||
* not include the enclosing quotes or angle brackets.
|
* or angle brackets. E.g.: for '<sys/types.h>' 'sys/types.h' will be returned.
|
||||||
|
* @throws CoreException
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
String getFullName() throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the character offset of the name of the include in its source file.
|
||||||
|
* The name does not include the enclosing quotes or angle brackets.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
int getNameOffset() throws CoreException;
|
int getNameOffset() throws CoreException;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
@ -26,7 +27,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PDOMInclude implements IIndexFragmentInclude {
|
public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
private final int record;
|
private final int record;
|
||||||
|
|
||||||
// cached fields
|
// cached fields
|
||||||
private String fName= null;
|
private String fName;
|
||||||
|
|
||||||
public PDOMInclude(PDOMLinkage pdom, int record) {
|
public PDOMInclude(PDOMLinkage pdom, int record) {
|
||||||
this.linkage = pdom;
|
this.linkage = pdom;
|
||||||
|
@ -95,8 +95,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
if (isResolved()) {
|
if (isResolved()) {
|
||||||
// Remove us from the includedBy chain
|
// Remove us from the includedBy chain
|
||||||
removeThisFromIncludedByChain();
|
removeThisFromIncludedByChain();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
getNameForUnresolved().delete();
|
getNameForUnresolved().delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,10 +106,11 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
private void removeThisFromIncludedByChain() throws CoreException {
|
private void removeThisFromIncludedByChain() throws CoreException {
|
||||||
PDOMInclude prevInclude = getPrevInIncludedBy();
|
PDOMInclude prevInclude = getPrevInIncludedBy();
|
||||||
PDOMInclude nextInclude = getNextInIncludedBy();
|
PDOMInclude nextInclude = getNextInIncludedBy();
|
||||||
if (prevInclude != null)
|
if (prevInclude != null) {
|
||||||
prevInclude.setNextInIncludedBy(nextInclude);
|
prevInclude.setNextInIncludedBy(nextInclude);
|
||||||
else
|
} else {
|
||||||
((PDOMFile) getIncludes()).setFirstIncludedBy(nextInclude);
|
((PDOMFile) getIncludes()).setFirstIncludedBy(nextInclude);
|
||||||
|
}
|
||||||
|
|
||||||
if (nextInclude != null)
|
if (nextInclude != null)
|
||||||
nextInclude.setPrevInIncludedBy(prevInclude);
|
nextInclude.setPrevInIncludedBy(prevInclude);
|
||||||
|
@ -136,8 +136,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
int rec= 0;
|
int rec= 0;
|
||||||
if (includes == null) {
|
if (includes == null) {
|
||||||
rec= linkage.getDB().newString(name).getRecord();
|
rec= linkage.getDB().newString(name).getRecord();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
rec= includes.getRecord();
|
rec= includes.getRecord();
|
||||||
}
|
}
|
||||||
linkage.getDB().putInt(record + INCLUDES_FILE_OR_NAME, rec);
|
linkage.getDB().putInt(record + INCLUDES_FILE_OR_NAME, rec);
|
||||||
|
@ -240,6 +239,13 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() throws CoreException {
|
public String getName() throws CoreException {
|
||||||
|
if (fName == null) {
|
||||||
|
computeName();
|
||||||
|
}
|
||||||
|
return fName.substring(fName.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFullName() throws CoreException {
|
||||||
if (fName == null) {
|
if (fName == null) {
|
||||||
computeName();
|
computeName();
|
||||||
}
|
}
|
||||||
|
@ -249,11 +255,9 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
||||||
private void computeName() throws CoreException {
|
private void computeName() throws CoreException {
|
||||||
if (isResolved()) {
|
if (isResolved()) {
|
||||||
fName= getIncludes().getLocation().getURI().getPath();
|
fName= getIncludes().getLocation().getURI().getPath();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fName= getNameForUnresolved().getString();
|
fName= getNameForUnresolved().getString();
|
||||||
}
|
}
|
||||||
fName= fName.substring(fName.lastIndexOf('/')+1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convertToUnresolved() throws CoreException {
|
public void convertToUnresolved() throws CoreException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue