mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Fixes occasional failures of selection tests.
This commit is contained in:
parent
c5b863d340
commit
609472bf8f
3 changed files with 21 additions and 18 deletions
|
@ -741,10 +741,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
CodeReader reader;
|
CodeReader reader;
|
||||||
reader = getCodeReader();
|
reader = getCodeReader();
|
||||||
|
|
||||||
|
if (reader != null) {
|
||||||
ILanguage language= getLanguage();
|
ILanguage language= getLanguage();
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
|
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,19 +109,24 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
|
||||||
//Obtain file handle
|
//Obtain file handle
|
||||||
IFile file = fCProject.getProject().getFile(fileName);
|
IFile file = fCProject.getProject().getFile(fileName);
|
||||||
|
|
||||||
IPath location = new Path(fCProject.getProject().getLocation().removeLastSegments(1).toOSString() + File.separator + fileName); //$NON-NLS-1$
|
IPath location = new Path(fCProject.getProject().getLocation().removeLastSegments(1).toOSString() + File.separator + fileName);
|
||||||
|
|
||||||
File linkFile = new File(location.toOSString());
|
File linkFile = new File(location.toOSString());
|
||||||
if (!linkFile.exists()) {
|
if (linkFile.exists()) {
|
||||||
linkFile.createNewFile();
|
linkFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null);
|
file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null);
|
||||||
|
|
||||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
||||||
//Create file input stream
|
//Create file input stream
|
||||||
if( file.exists() )
|
if( file.exists() ) {
|
||||||
|
long timestamp= file.getLocalTimeStamp();
|
||||||
file.setContents( stream, false, false, monitor );
|
file.setContents( stream, false, false, monitor );
|
||||||
|
if (file.getLocalTimeStamp() == timestamp) {
|
||||||
|
file.setLocalTimeStamp(timestamp+1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
file.create( stream, false, monitor );
|
file.create( stream, false, monitor );
|
||||||
|
|
||||||
|
|
|
@ -107,12 +107,8 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupProject() throws Exception {
|
public void cleanupProject() throws Exception {
|
||||||
try{
|
CProjectHelper.delete(cPrj);
|
||||||
project.delete( true, false, monitor );
|
project= null;
|
||||||
project = null;
|
|
||||||
} catch( Throwable e ){
|
|
||||||
/*boo*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
@ -126,7 +122,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
||||||
if (members[i].getName().equals(".settings"))
|
if (members[i].getName().equals(".settings"))
|
||||||
continue;
|
continue;
|
||||||
try{
|
try{
|
||||||
members[i].delete( false, monitor );
|
members[i].delete( true, monitor );
|
||||||
} catch( Throwable e ){
|
} catch( Throwable e ){
|
||||||
/*boo*/
|
/*boo*/
|
||||||
}
|
}
|
||||||
|
@ -153,7 +149,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
||||||
//Obtain file handle
|
//Obtain file handle
|
||||||
IFile file = project.getProject().getFile(fileName);
|
IFile file = project.getProject().getFile(fileName);
|
||||||
|
|
||||||
IPath location = new Path(project.getLocation().removeLastSegments(1).toOSString() + File.separator + fileName); //$NON-NLS-1$
|
IPath location = new Path(project.getLocation().removeLastSegments(1).toOSString() + File.separator + fileName);
|
||||||
|
|
||||||
File linkFile = new File(location.toOSString());
|
File linkFile = new File(location.toOSString());
|
||||||
if (!linkFile.exists()) {
|
if (!linkFile.exists()) {
|
||||||
|
@ -206,7 +202,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
||||||
//Obtain file handle
|
//Obtain file handle
|
||||||
IFile file = project.getProject().getFile(fileName);
|
IFile file = project.getProject().getFile(fileName);
|
||||||
|
|
||||||
IPath location = new Path(folder.getLocation().toOSString() + File.separator + fileName); //$NON-NLS-1$
|
IPath location = new Path(folder.getLocation().toOSString() + File.separator + fileName);
|
||||||
|
|
||||||
File linkFile = new File(location.toOSString());
|
File linkFile = new File(location.toOSString());
|
||||||
if (!linkFile.exists()) {
|
if (!linkFile.exists()) {
|
||||||
|
@ -655,7 +651,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
||||||
String code = buffer.toString();
|
String code = buffer.toString();
|
||||||
IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$
|
IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$
|
||||||
|
|
||||||
int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$
|
int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$
|
||||||
IASTNode decl = testF3(file, offset);
|
IASTNode decl = testF3(file, offset);
|
||||||
assertTrue(decl instanceof IASTName);
|
assertTrue(decl instanceof IASTName);
|
||||||
assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$
|
assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$
|
||||||
|
|
Loading…
Add table
Reference in a new issue