From 054ddfbf3985dd35c2ce6e9c62e01592b3792d01 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Mon, 11 Aug 2014 11:33:45 -0700 Subject: [PATCH] Calculate parameter scope in a less stupid way thereby fixing go-to-declaration with parameters --- conversion/first.d | 8 ++------ conversion/second.d | 6 ------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/conversion/first.d b/conversion/first.d index 0e17fe6..ba62897 100644 --- a/conversion/first.d +++ b/conversion/first.d @@ -129,11 +129,7 @@ final class FirstPass : ASTVisitor if (dec.functionBody !is null) { import std.algorithm; - size_t scopeBegin = min( - dec.functionBody.inStatement is null ? size_t.max : dec.functionBody.inStatement.blockStatement.startLocation, - dec.functionBody.outStatement is null ? size_t.max : dec.functionBody.outStatement.blockStatement.startLocation, - dec.functionBody.blockStatement is null ? size_t.max : dec.functionBody.blockStatement.startLocation, - dec.functionBody.bodyStatement is null ? size_t.max : dec.functionBody.bodyStatement.blockStatement.startLocation); + size_t scopeBegin = dec.name.index; size_t scopeEnd = max( dec.functionBody.inStatement is null ? 0 : dec.functionBody.inStatement.blockStatement.endLocation, dec.functionBody.outStatement is null ? 0 : dec.functionBody.outStatement.blockStatement.endLocation, @@ -508,7 +504,7 @@ private: { SemanticSymbol* parameter = allocateSemanticSymbol( p.name.text, CompletionKind.variableName, symbolFile, - size_t.max, p.type); + p.name.index, p.type); symbol.addChild(parameter); parameter.parent = symbol; } diff --git a/conversion/second.d b/conversion/second.d index 4b68445..a7362e4 100644 --- a/conversion/second.d +++ b/conversion/second.d @@ -59,12 +59,6 @@ private: void assignToScopes(ACSymbol* currentSymbol) { Scope* s = moduleScope.getScopeByCursor(currentSymbol.location); - // Look for a parent scope whose start location equals this scope's - // start location. This only happens in the case of functions with - // contracts. Use this outer scope that covers the in, out, and body - // instead of the smaller scope found by getScopeByCursor. - if (s.parent !is null && s.parent.startLocation == s.startLocation) - s = s.parent; if (currentSymbol.kind != CompletionKind.moduleName) s.symbols.insert(currentSymbol); foreach (part; currentSymbol.parts[])