mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
modified version of patch from Devin Steffler for bug 95202
This commit is contained in:
parent
6f27d5a71c
commit
793e00edda
3 changed files with 53 additions and 0 deletions
|
@ -957,4 +957,32 @@ public class CPPSelectionTestsNoIndexer extends TestCase {
|
||||||
assertEquals(((ASTNode)decl).getOffset(), 128);
|
assertEquals(((ASTNode)decl).getOffset(), 128);
|
||||||
assertEquals(((ASTNode)decl).getLength(), 3);
|
assertEquals(((ASTNode)decl).getLength(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug95202() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("struct A { }; // implicitlydeclared A::operator=\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct B : A {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("B& operator=(const B &);\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("B& B::operator=(const B& s) {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("this->B::operator=(s); // wellformed\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("return *this;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
String code = buffer.toString();
|
||||||
|
IFile file = importFile("testBug95202.cpp", code); //$NON-NLS-1$
|
||||||
|
|
||||||
|
int offset = code.indexOf("s); // wellformed"); //$NON-NLS-1$
|
||||||
|
IASTNode def = testF2(file, offset);
|
||||||
|
IASTNode decl = testF3(file, offset);
|
||||||
|
assertTrue(def instanceof IASTName);
|
||||||
|
assertTrue(decl instanceof IASTName);
|
||||||
|
assertEquals(((IASTName)decl).toString(), "s"); //$NON-NLS-1$
|
||||||
|
assertEquals(((ASTNode)decl).getOffset(), 117);
|
||||||
|
assertEquals(((ASTNode)decl).getLength(), 1);
|
||||||
|
assertEquals(((IASTName)def).toString(), "s"); //$NON-NLS-1$
|
||||||
|
assertEquals(((ASTNode)def).getOffset(), 117);
|
||||||
|
assertEquals(((ASTNode)def).getLength(), 1);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.search.DOMSearchUtil;
|
import org.eclipse.cdt.core.search.DOMSearchUtil;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.IMatch;
|
import org.eclipse.cdt.core.search.IMatch;
|
||||||
|
@ -129,6 +130,18 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
||||||
IASTName searchName = selectedNames[0];
|
IASTName searchName = selectedNames[0];
|
||||||
// step 2 starts here
|
// step 2 starts here
|
||||||
IASTName[] domNames = DOMSearchUtil.getNamesFromDOM(searchName, ICSearchConstants.DECLARATIONS);
|
IASTName[] domNames = DOMSearchUtil.getNamesFromDOM(searchName, ICSearchConstants.DECLARATIONS);
|
||||||
|
|
||||||
|
// make sure the names are clean (fix for 95202)
|
||||||
|
boolean modified=false;
|
||||||
|
for(int i=0; i<domNames.length; i++) {
|
||||||
|
if (domNames[i].toCharArray().length == 0) {
|
||||||
|
domNames[i] = null;
|
||||||
|
modified=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (modified)
|
||||||
|
domNames = (IASTName[])ArrayUtil.removeNulls(IASTName.class, domNames);
|
||||||
|
|
||||||
if (domNames != null && domNames.length > 0 && domNames[0] != null) {
|
if (domNames != null && domNames.length > 0 && domNames[0] != null) {
|
||||||
String fileName=null;
|
String fileName=null;
|
||||||
int start=0;
|
int start=0;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.search.DOMSearchUtil;
|
import org.eclipse.cdt.core.search.DOMSearchUtil;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.IMatch;
|
import org.eclipse.cdt.core.search.IMatch;
|
||||||
|
@ -142,6 +143,17 @@ public class OpenDefinitionAction extends SelectionParseAction implements
|
||||||
// step 2 starts here
|
// step 2 starts here
|
||||||
IASTName[] domNames = DOMSearchUtil.getNamesFromDOM(searchName, ICSearchConstants.DEFINITIONS);
|
IASTName[] domNames = DOMSearchUtil.getNamesFromDOM(searchName, ICSearchConstants.DEFINITIONS);
|
||||||
|
|
||||||
|
// make sure the names are clean (fix for 95202)
|
||||||
|
boolean modified=false;
|
||||||
|
for(int i=0; i<domNames.length; i++) {
|
||||||
|
if (domNames[i].toCharArray().length == 0) {
|
||||||
|
domNames[i] = null;
|
||||||
|
modified=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (modified)
|
||||||
|
domNames = (IASTName[])ArrayUtil.removeNulls(IASTName.class, domNames);
|
||||||
|
|
||||||
if (domNames != null && domNames.length > 0 && domNames[0] != null) {
|
if (domNames != null && domNames.length > 0 && domNames[0] != null) {
|
||||||
String fileName=null;
|
String fileName=null;
|
||||||
int start=0;
|
int start=0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue