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

Catch IndexOutOfBound

This commit is contained in:
Alain Magloire 2004-06-03 02:57:51 +00:00
parent 1193d6341a
commit d12ebf93d3
2 changed files with 24 additions and 23 deletions

View file

@ -62,7 +62,6 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.QuickParseCallback;
import org.eclipse.cdt.internal.core.parser.StructuralParseCallback;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -77,6 +76,25 @@ public class CModelBuilder {
// indicator if the unit has parse errors
private boolean hasNoErrors = false;
class ProblemCallback extends StructuralParseCallback {
IProblemRequestor problemRequestor;
public ProblemCallback(IProblemRequestor requestor) {
problemRequestor = requestor;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.QuickParseCallback#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
*/
public boolean acceptProblem(IProblem problem) {
// Do not worry for now about problems in other files.
if (inclusionLevel == 0) {
problemRequestor.acceptProblem(problem);
}
return true;
}
}
public CModelBuilder(org.eclipse.cdt.internal.core.model.TranslationUnit tu) {
this.translationUnit = tu ;
this.newElements = new HashMap();
@ -111,27 +129,7 @@ public class CModelBuilder {
quickParseCallback = (quickParseMode) ? ParserFactory.createQuickParseCallback() :
ParserFactory.createStructuralParseCallback();
} else {
if (quickParseMode) {
quickParseCallback = new QuickParseCallback() {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.QuickParseCallback#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
*/
public boolean acceptProblem(IProblem problem) {
problemRequestor.acceptProblem(problem);
return true;
}
};
} else {
quickParseCallback = new StructuralParseCallback() {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.QuickParseCallback#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
*/
public boolean acceptProblem(IProblem problem) {
problemRequestor.acceptProblem(problem);
return true;
}
};
}
quickParseCallback = new ProblemCallback(problemRequestor);
}
// pick the language

View file

@ -54,6 +54,9 @@ class SourceManipulationInfo extends CElementInfo {
}
} catch (IOException e) {
throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION);
} catch (StringIndexOutOfBoundsException bound) {
// This is not good we screwed up the offset some how
throw new CModelException(bound, ICModelStatusConstants.INDEX_OUT_OF_BOUNDS);
}
}
return ""; //$NON-NLS-1$