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:
parent
01cad33ead
commit
f3a361e83a
1 changed files with 9 additions and 8 deletions
|
@ -10,7 +10,8 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
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.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
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.ParserException;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
|
import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
|
|
||||||
public class CModelBuilder {
|
public class CModelBuilder {
|
||||||
|
@ -82,6 +82,7 @@ public class CModelBuilder {
|
||||||
{
|
{
|
||||||
IProject currentProject = null;
|
IProject currentProject = null;
|
||||||
boolean hasCppNature = true;
|
boolean hasCppNature = true;
|
||||||
|
String code = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
// get the current project
|
// get the current project
|
||||||
if (translationUnit != null && translationUnit.getCProject() != null) {
|
if (translationUnit != null && translationUnit.getCProject() != null) {
|
||||||
|
@ -92,11 +93,11 @@ public class CModelBuilder {
|
||||||
{
|
{
|
||||||
hasCppNature = CoreModel.hasCCNature(currentProject);
|
hasCppNature = CoreModel.hasCCNature(currentProject);
|
||||||
}
|
}
|
||||||
|
// get the code to parse
|
||||||
|
try{
|
||||||
|
code = translationUnit.getBuffer().getContents();
|
||||||
|
} catch (CModelException e) {
|
||||||
|
|
||||||
Reader reader = null;
|
|
||||||
try {
|
|
||||||
reader = ParserUtil.createResourceReader( translationUnit.getResource() );
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
}
|
||||||
// use quick or structural parse mode
|
// use quick or structural parse mode
|
||||||
ParserMode mode = quickParseMode ? ParserMode.QUICK_PARSE : ParserMode.STRUCTURAL_PARSE;
|
ParserMode mode = quickParseMode ? ParserMode.QUICK_PARSE : ParserMode.STRUCTURAL_PARSE;
|
||||||
|
@ -124,7 +125,7 @@ public class CModelBuilder {
|
||||||
|
|
||||||
parser = ParserFactory.createParser(
|
parser = ParserFactory.createParser(
|
||||||
ParserFactory.createScanner(
|
ParserFactory.createScanner(
|
||||||
reader,
|
new BufferedReader( new StringReader( code ) ),
|
||||||
(translationUnit.getUnderlyingResource() != null ?
|
(translationUnit.getUnderlyingResource() != null ?
|
||||||
translationUnit.getUnderlyingResource().getLocation().toOSString() :
|
translationUnit.getUnderlyingResource().getLocation().toOSString() :
|
||||||
""), //$NON-NLS-1$
|
""), //$NON-NLS-1$
|
||||||
|
|
Loading…
Add table
Reference in a new issue