diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index c76de054061..05e179a34fc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -741,9 +741,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit { CodeReader reader; reader = getCodeReader(); - ILanguage language= getLanguage(); - if (language != null) { - return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService()); + if (reader != null) { + ILanguage language= getLanguage(); + if (language != null) { + return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService()); + } } return null; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java index 73069ce54ba..b37adfd8ea2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java @@ -109,19 +109,24 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { //Obtain file handle 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()); - if (!linkFile.exists()) { - linkFile.createNewFile(); + if (linkFile.exists()) { + linkFile.delete(); } file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null); InputStream stream = new ByteArrayInputStream( contents.getBytes() ); //Create file input stream - if( file.exists() ) - file.setContents( stream, false, false, monitor ); + if( file.exists() ) { + long timestamp= file.getLocalTimeStamp(); + file.setContents( stream, false, false, monitor ); + if (file.getLocalTimeStamp() == timestamp) { + file.setLocalTimeStamp(timestamp+1000); + } + } else file.create( stream, false, monitor ); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java index 1e8d047e983..3de409cda0d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java @@ -107,12 +107,8 @@ public class CSelectionTestsNoIndexer extends TestCase { } public void cleanupProject() throws Exception { - try{ - project.delete( true, false, monitor ); - project = null; - } catch( Throwable e ){ - /*boo*/ - } + CProjectHelper.delete(cPrj); + project= null; } protected void tearDown() throws Exception { @@ -126,7 +122,7 @@ public class CSelectionTestsNoIndexer extends TestCase { if (members[i].getName().equals(".settings")) continue; try{ - members[i].delete( false, monitor ); + members[i].delete( true, monitor ); } catch( Throwable e ){ /*boo*/ } @@ -153,7 +149,7 @@ public class CSelectionTestsNoIndexer extends TestCase { //Obtain file handle 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()); if (!linkFile.exists()) { @@ -206,7 +202,7 @@ public class CSelectionTestsNoIndexer extends TestCase { //Obtain file handle 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()); if (!linkFile.exists()) { @@ -655,7 +651,7 @@ public class CSelectionTestsNoIndexer extends TestCase { String code = buffer.toString(); 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); assertTrue(decl instanceof IASTName); assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$