1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixing CModelBuilder to use contents() rather than ResourceReader. :-(

This commit is contained in:
John Camelon 2004-05-20 17:30:43 +00:00
parent 01cad33ead
commit f3a361e83a

View file

@ -10,7 +10,8 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import java.io.Reader;
import java.io.BufferedReader;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -61,7 +62,6 @@ import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
public class CModelBuilder {
@ -82,6 +82,7 @@ public class CModelBuilder {
{
IProject currentProject = null;
boolean hasCppNature = true;
String code = ""; //$NON-NLS-1$
// get the current project
if (translationUnit != null && translationUnit.getCProject() != null) {
@ -92,11 +93,11 @@ public class CModelBuilder {
{
hasCppNature = CoreModel.hasCCNature(currentProject);
}
Reader reader = null;
try {
reader = ParserUtil.createResourceReader( translationUnit.getResource() );
} catch (CoreException e) {
// get the code to parse
try{
code = translationUnit.getBuffer().getContents();
} catch (CModelException e) {
}
// use quick or structural parse mode
ParserMode mode = quickParseMode ? ParserMode.QUICK_PARSE : ParserMode.STRUCTURAL_PARSE;
@ -124,7 +125,7 @@ public class CModelBuilder {
parser = ParserFactory.createParser(
ParserFactory.createScanner(
reader,
new BufferedReader( new StringReader( code ) ),
(translationUnit.getUnderlyingResource() != null ?
translationUnit.getUnderlyingResource().getLocation().toOSString() :
""), //$NON-NLS-1$