Browse Source

Fixed possible exceptions in Boo code-completion.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1403 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
dfb3e6a5a4
  1. 16
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/InferredReturnType.cs
  2. 10
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ResolveVisitor.cs

16
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/InferredReturnType.cs

@ -100,19 +100,27 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -100,19 +100,27 @@ namespace Grunwald.BooBinding.CodeCompletion
public override void OnYieldStatement(YieldStatement node)
{
noReturnStatement = false;
IClass enumerable = ProjectContentRegistry.Mscorlib.GetClass("System.Collections.Generic.IEnumerable", 1);
IProjectContent pc = context != null ? context.ProjectContent : ParserService.CurrentProjectContent;
IReturnType enumerable = new GetClassReturnType(pc, "System.Collections.Generic.IEnumerable", 1);
// Prevent creating an infinite number of InferredReturnTypes in inferring cycles
parentReturnType.expression = new NullLiteralExpression();
IReturnType returnType = new BooResolver().GetTypeOfExpression(node.Expression, context);
returnType.GetUnderlyingClass(); // force to infer type
IReturnType returnType;
if (node.Expression == null)
returnType = ReflectionReturnType.Object;
else
returnType = new BooResolver().GetTypeOfExpression(node.Expression, context);
if (returnType != null) {
returnType.GetUnderlyingClass(); // force to infer type
}
if (parentReturnType.expression == null) {
// inferrence cycle with parentReturnType
returnType = new GetClassReturnType(context.ProjectContent, "?", 0);
}
parentReturnType.expression = null;
result = new ConstructedReturnType(enumerable.DefaultReturnType, new IReturnType[] { returnType });
result = new ConstructedReturnType(enumerable, new IReturnType[] { returnType });
}
public override void OnCallableBlockExpression(CallableBlockExpression node)

10
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ResolveVisitor.cs

@ -504,10 +504,12 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -504,10 +504,12 @@ namespace Grunwald.BooBinding.CodeCompletion
{
ClearResult();
Visit(node.Target);
Slice slice = node.Indices[0];
if (slice.End != null) {
// Boo slice, returns a part of the source -> same type as source
return;
if (node.Indices.Count > 0) {
Slice slice = node.Indices[0];
if (slice.End != null) {
// Boo slice, returns a part of the source -> same type as source
return;
}
}
IReturnType rt = (resolveResult != null) ? resolveResult.ResolvedType : null;
if (rt == null) {

Loading…
Cancel
Save