mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.index;
|
||||
|
||||
|
@ -57,8 +58,16 @@ public interface IIndexInclude {
|
|||
String getName() 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.
|
||||
* Returns the name of the include. The name does not include the enclosing quotes
|
||||
* 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
|
||||
*/
|
||||
int getNameOffset() throws CoreException;
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
@ -26,7 +27,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMInclude implements IIndexFragmentInclude {
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
private final int record;
|
||||
|
||||
// cached fields
|
||||
private String fName= null;
|
||||
private String fName;
|
||||
|
||||
public PDOMInclude(PDOMLinkage pdom, int record) {
|
||||
this.linkage = pdom;
|
||||
|
@ -95,8 +95,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
if (isResolved()) {
|
||||
// Remove us from the includedBy chain
|
||||
removeThisFromIncludedByChain();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getNameForUnresolved().delete();
|
||||
}
|
||||
|
||||
|
@ -107,10 +106,11 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
private void removeThisFromIncludedByChain() throws CoreException {
|
||||
PDOMInclude prevInclude = getPrevInIncludedBy();
|
||||
PDOMInclude nextInclude = getNextInIncludedBy();
|
||||
if (prevInclude != null)
|
||||
if (prevInclude != null) {
|
||||
prevInclude.setNextInIncludedBy(nextInclude);
|
||||
else
|
||||
} else {
|
||||
((PDOMFile) getIncludes()).setFirstIncludedBy(nextInclude);
|
||||
}
|
||||
|
||||
if (nextInclude != null)
|
||||
nextInclude.setPrevInIncludedBy(prevInclude);
|
||||
|
@ -136,8 +136,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
int rec= 0;
|
||||
if (includes == null) {
|
||||
rec= linkage.getDB().newString(name).getRecord();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
rec= includes.getRecord();
|
||||
}
|
||||
linkage.getDB().putInt(record + INCLUDES_FILE_OR_NAME, rec);
|
||||
|
@ -240,6 +239,13 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
}
|
||||
|
||||
public String getName() throws CoreException {
|
||||
if (fName == null) {
|
||||
computeName();
|
||||
}
|
||||
return fName.substring(fName.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
public String getFullName() throws CoreException {
|
||||
if (fName == null) {
|
||||
computeName();
|
||||
}
|
||||
|
@ -249,11 +255,9 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
private void computeName() throws CoreException {
|
||||
if (isResolved()) {
|
||||
fName= getIncludes().getLocation().getURI().getPath();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fName= getNameForUnresolved().getString();
|
||||
}
|
||||
fName= fName.substring(fName.lastIndexOf('/')+1);
|
||||
}
|
||||
|
||||
public void convertToUnresolved() throws CoreException {
|
||||
|
|
Loading…
Add table
Reference in a new issue