Browse Source

Fixed forum-10355: Boo code completion fails using import statements from user assemblies.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5276 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
8033853d49
  1. 7
      src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj
  2. 3
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
  3. 25
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BindNamespacesWithoutRemovingErrors.cs
  4. 89
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs

7
src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Grunwald.BooBinding</RootNamespace>
@ -33,6 +34,9 @@ @@ -33,6 +34,9 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="Boo.Lang.Extensions">
<HintPath>..\..\RequiredLibraries\Boo.Lang.Extensions.dll</HintPath>
</Reference>
<Reference Include="Boo.Lang.Interpreter">
<HintPath>..\..\RequiredLibraries\Boo.Lang.Interpreter.dll</HintPath>
</Reference>
@ -67,6 +71,7 @@ @@ -67,6 +71,7 @@
<Compile Include="Src\BooProject.cs" />
<Compile Include="Src\BooLanguageBinding.cs" />
<Compile Include="Src\BooAmbience.cs" />
<Compile Include="Src\CodeCompletion\BindNamespacesWithoutRemovingErrors.cs" />
<Compile Include="Src\CodeCompletion\BooParser.cs" />
<Compile Include="Src\CodeCompletion\ExpressionFinder.cs" />
<Compile Include="Src\CodeCompletion\ConvertVisitor.cs" />

3
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs

@ -108,9 +108,12 @@ namespace Grunwald.BooBinding @@ -108,9 +108,12 @@ namespace Grunwald.BooBinding
pc.AddReferencedContent(ParserService.GetProjectContentForReference(systemItem));
ReferenceProjectItem booLangItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Builtins).Assembly.Location);
pc.AddReferencedContent(ParserService.GetProjectContentForReference(booLangItem));
ReferenceProjectItem booExtensionsItem = new ReferenceProjectItem(this, typeof(Boo.Lang.Extensions.PropertyAttribute).Assembly.Location);
pc.AddReferencedContent(ParserService.GetProjectContentForReference(booExtensionsItem));
pc.DefaultImports = new DefaultUsing(pc);
pc.DefaultImports.Usings.Add("Boo.Lang");
pc.DefaultImports.Usings.Add("Boo.Lang.Builtins");
pc.DefaultImports.Usings.Add("Boo.Lang.Extensions");
return pc;
}

25
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BindNamespacesWithoutRemovingErrors.cs

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using Boo.Lang.Compiler.Steps;
namespace Grunwald.BooBinding.CodeCompletion
{
/// <summary>
/// The Boo 'BindNamespaces' step will remove imports that cannot be resolved.
/// However, we need to keep those imports available for use inside SharpDevelop.
/// </summary>
public class BindNamespacesWithoutRemovingErrors : BindNamespaces
{
public override void OnImport(Boo.Lang.Compiler.Ast.Import import)
{
base.OnImport(import);
ReplaceCurrentNode(import); // prevent removal of import
}
}
}

89
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs

@ -160,24 +160,87 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -160,24 +160,87 @@ namespace Grunwald.BooBinding.CodeCompletion
compiler.Parameters.OutputWriter = new StringWriter();
compiler.Parameters.TraceLevel = System.Diagnostics.TraceLevel.Off;
Compile compilePipe = new Compile();
// Compile pipeline as of Boo 0.9.2:
// Boo.Lang.Compiler.Pipelines.Parse:
// Boo.Lang.Parser.BooParsingStep
// Boo.Lang.Compiler.Pipelines.ExpandMacros:
// Boo.Lang.Compiler.Steps.InitializeTypeSystemServices
// Boo.Lang.Compiler.Steps.PreErrorChecking
// Boo.Lang.Compiler.Steps.MergePartialClasses
// Boo.Lang.Compiler.Steps.InitializeNameResolutionService
// Boo.Lang.Compiler.Steps.IntroduceGlobalNamespaces
// Boo.Lang.Compiler.Steps.TransformCallableDefinitions
// Boo.Lang.Compiler.Steps.BindTypeDefinitions
// Boo.Lang.Compiler.Steps.BindGenericParameters
// Boo.Lang.Compiler.Steps.BindNamespaces
// Boo.Lang.Compiler.Steps.BindBaseTypes
// Boo.Lang.Compiler.Steps.MacroAndAttributeExpansion
// Boo.Lang.Compiler.Pipelines.ResolveExpressions:
// Boo.Lang.Compiler.Steps.ExpandAstLiterals
// Boo.Lang.Compiler.Steps.IntroduceModuleClasses
// Boo.Lang.Compiler.Steps.NormalizeStatementModifiers
// Boo.Lang.Compiler.Steps.NormalizeTypeAndMemberDefinitions
// Boo.Lang.Compiler.Steps.NormalizeOmittedExpressions
// Boo.Lang.Compiler.Steps.BindTypeDefinitions
// Boo.Lang.Compiler.Steps.BindGenericParameters
// Boo.Lang.Compiler.Steps.BindEnumMembers
// Boo.Lang.Compiler.Steps.BindBaseTypes
// Boo.Lang.Compiler.Steps.CheckMemberTypes
// Boo.Lang.Compiler.Steps.BindMethods
// Boo.Lang.Compiler.Steps.ResolveTypeReferences
// Boo.Lang.Compiler.Steps.BindTypeMembers
// Boo.Lang.Compiler.Steps.CheckGenericConstraints
// Boo.Lang.Compiler.Steps.ProcessInheritedAbstractMembers
// Boo.Lang.Compiler.Steps.CheckMemberNames
// Boo.Lang.Compiler.Steps.ProcessMethodBodiesWithDuckTyping
// Boo.Lang.Compiler.Steps.PreProcessExtensionMethods
// Boo.Lang.Compiler.Pipelines.Compile:
// Boo.Lang.Compiler.Steps.ConstantFolding
// Boo.Lang.Compiler.Steps.NormalizeLiterals
// Boo.Lang.Compiler.Steps.OptimizeIterationStatements
// Boo.Lang.Compiler.Steps.BranchChecking
// Boo.Lang.Compiler.Steps.CheckIdentifiers
// Boo.Lang.Compiler.Steps.StricterErrorChecking
// Boo.Lang.Compiler.Steps.CheckAttributesUsage
// Boo.Lang.Compiler.Steps.ExpandDuckTypedExpressions
// Boo.Lang.Compiler.Steps.ProcessAssignmentsToValueTypeMembers
// Boo.Lang.Compiler.Steps.ExpandProperties
// Boo.Lang.Compiler.Steps.RemoveDeadCode
// Boo.Lang.Compiler.Steps.CheckMembersProtectionLevel
// Boo.Lang.Compiler.Steps.NormalizeIterationStatements
// Boo.Lang.Compiler.Steps.ProcessSharedLocals
// Boo.Lang.Compiler.Steps.ProcessClosures
// Boo.Lang.Compiler.Steps.ProcessGenerators
// Boo.Lang.Compiler.Steps.ExpandVarArgsMethodInvocations
// Boo.Lang.Compiler.Steps.InjectCallableConversions
// Boo.Lang.Compiler.Steps.ImplementICallableOnCallableDefinitions
// Boo.Lang.Compiler.Steps.CheckNeverUsedMembers
// Boo.Lang.Compiler.Pipelines.CompileToMemory:
// Boo.Lang.Compiler.Steps.EmitAssembly
// Boo.Lang.Compiler.Pipelines.CompileToFile:
// Boo.Lang.Compiler.Steps.SaveAssembly
CompilerPipeline compilePipe = new Parse();
compilePipe.Add(new InitializeTypeSystemServices());
compilePipe.Add(new PreErrorChecking());
compilePipe.Add(new MergePartialClasses());
compilePipe.Add(new InitializeNameResolutionService());
compilePipe.Add(new IntroduceGlobalNamespaces());
// TransformCallableDefinitions: not used for CC
compilePipe.Add(new BindTypeDefinitions());
compilePipe.Add(new BindGenericParameters());
compilePipe.Add(new BindNamespacesWithoutRemovingErrors());
compilePipe.Add(new BindBaseTypes());
compilePipe.Add(new MacroAndAttributeExpansion());
compilePipe.Add(new IntroduceModuleClasses());
BooParsingStep parsingStep = (BooParsingStep)compilePipe[0];
parsingStep.TabSize = 1;
ConvertVisitor visitor = new ConvertVisitor(lineLength, projectContent);
visitor.Cu.FileName = fileName;
// Remove unneccessary compiler steps
int num = 1 + compilePipe.Find(typeof(NormalizeStatementModifiers));
compilePipe[num] = visitor;
while (compilePipe.Count > num + 1)
compilePipe.RemoveAt(compilePipe.Count - 1);
num = compilePipe.Find(typeof(TransformCallableDefinitions));
compilePipe.RemoveAt(num);
//for (int i = 0; i < compilePipe.Count; i++) {
// Console.WriteLine(compilePipe[i]);
//}
compilePipe.Add(visitor);
compilePipe.BreakOnErrors = false;
compiler.Parameters.Pipeline = compilePipe;

Loading…
Cancel
Save