mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix inclusion proposal for project local includes
This commit is contained in:
parent
5107c20849
commit
1ed39d8cea
2 changed files with 16 additions and 3 deletions
|
@ -990,6 +990,14 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
};
|
};
|
||||||
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
|
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
|
||||||
|
|
||||||
|
createFile(fProject, "inc113568.h", "");
|
||||||
|
expected= new String[] {
|
||||||
|
"\"inc1.h",
|
||||||
|
"\"inc113568.h",
|
||||||
|
"\"inc2.h"
|
||||||
|
};
|
||||||
|
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
|
||||||
|
|
||||||
getDocument().replace(fCursorOffset-1, 1, "sub1/");
|
getDocument().replace(fCursorOffset-1, 1, "sub1/");
|
||||||
expected= new String[] {
|
expected= new String[] {
|
||||||
"\"sub1/inc11.h"
|
"\"sub1/inc11.h"
|
||||||
|
@ -1028,4 +1036,5 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
}
|
}
|
||||||
TestScannerProvider.sIncludes= (String[]) includeDirs.toArray(new String[includeDirs.size()]);
|
TestScannerProvider.sIncludes= (String[]) includeDirs.toArray(new String[includeDirs.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,9 +304,13 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
final IProject project= tu.getCProject().getProject();
|
final IProject project= tu.getCProject().getProject();
|
||||||
parent.accept(new IResourceProxyVisitor() {
|
parent.accept(new IResourceProxyVisitor() {
|
||||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||||
|
final int type= proxy.getType();
|
||||||
|
if (type == IResource.PROJECT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
final String name= proxy.getName();
|
final String name= proxy.getName();
|
||||||
if (name.length() < prefixLength && namePrefix.equalsIgnoreCase(name.substring(0, prefixLength))) {
|
if (name.length() >= prefixLength && namePrefix.equalsIgnoreCase(name.substring(0, prefixLength))) {
|
||||||
if (proxy.getType() == IResource.FILE) {
|
if (type == IResource.FILE) {
|
||||||
if (isCpp) {
|
if (isCpp) {
|
||||||
if (CoreModel.isValidCXXHeaderUnitName(project, name)) {
|
if (CoreModel.isValidCXXHeaderUnitName(project, name)) {
|
||||||
includeFiles.add(cPrefixPath.append(name).toString());
|
includeFiles.add(cPrefixPath.append(name).toString());
|
||||||
|
@ -316,7 +320,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
|
||||||
includeFiles.add(cPrefixPath.append(name).toString());
|
includeFiles.add(cPrefixPath.append(name).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (proxy.getType() == IResource.FOLDER) {
|
} else if (type == IResource.FOLDER) {
|
||||||
includeFiles.add(cPrefixPath.append(name).addTrailingSeparator().toString());
|
includeFiles.add(cPrefixPath.append(name).addTrailingSeparator().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue