├── src ├── Boo.Ide.Tests │ ├── .gitignore │ ├── Globals.boo │ ├── ImportsTest.boo │ ├── ProjectIndexTest.boo │ ├── MethodsTest.boo │ ├── LocalsTest.boo │ ├── Boo.Ide.Tests.booproj │ ├── DotCompletionTest.boo │ └── TargetLookupTest.boo ├── Boo.MonoDevelop.Tests │ ├── .gitignore │ ├── BooParserTest.boo │ ├── MonoDevelopTestBase.boo │ ├── BooResolverTest.boo │ ├── Util.boo │ ├── tests │ │ └── BooParserTest │ │ │ └── BooParserTest.booproj │ └── Boo.MonoDevelop.Tests.booproj ├── UnityScript.Ide.Tests │ ├── .gitignore │ ├── ImportsTest.boo │ ├── MethodsTest.boo │ ├── LocalsTest.boo │ ├── UnityScriptProjectIndexFactoryTest.boo │ └── UnityScript.Ide.Tests.booproj ├── Boo.MonoDevelop │ ├── ProjectModel │ │ ├── Consts.boo │ │ ├── BooProjectParameters.boo │ │ ├── BooResolver.boo │ │ ├── BooCompilationParameters.boo │ │ ├── GUI │ │ │ └── BooCompilationParametersPanel.boo │ │ ├── BooParser.boo │ │ ├── BooLanguageBinding.boo │ │ ├── BooCompiler.boo │ │ └── DomConversionVisitor.boo │ ├── Icons │ │ ├── BooFile.png │ │ ├── Boo.File.Form │ │ ├── BooBinding.Base │ │ ├── Boo.File.EmptyFile │ │ ├── BooProjectDecoration.png │ │ └── BooProjectStockIcon.png │ ├── Boo.MonoDevelop.mdw │ ├── IO.boo │ ├── Templates │ │ ├── EmptyBooFile.xft.xml │ │ ├── ConsoleProject.xpt.xml │ │ └── LibraryProject.xpt.xml │ ├── Highlighting │ │ └── BooSyntaxMode.boo │ ├── .monolipse │ ├── Editor │ │ └── BooIndentation.boo │ ├── Completion │ │ ├── BooParameterDataProvider.boo │ │ └── BooEditorCompletion.boo │ ├── Boo.MonoDevelop.addin.xml │ ├── Boo.MonoDevelop.booproj │ └── Boo.MonoDevelop.sln ├── UnityScript.MonoDevelop │ ├── Icons │ │ ├── UnityScriptFile32.png │ │ ├── UnityScriptFile128.png │ │ ├── UnityScriptProject.png │ │ └── UnityScriptProject32.png │ ├── UnityScriptFiles.boo │ ├── ProjectModel │ │ ├── UnityScriptProjectParameters.boo │ │ ├── UnityScriptCodeGenerator.boo │ │ ├── UnityScriptCodeDomProvider.boo │ │ ├── UnityScriptCompilationParameters.boo │ │ ├── GUI │ │ │ └── UnityScriptCompilationParametersPanel.boo │ │ ├── UnityScriptParser.boo │ │ ├── UnityScriptLanguageBinding.boo │ │ ├── UnityScriptCompiler.boo │ │ └── DomConversionVisitor.boo │ ├── CommandHandlers │ │ └── withAtomicUndoOn.boo │ ├── Templates │ │ ├── EmptyUnityScriptFile.xft.xml │ │ └── ConsoleProject.xpt.xml │ ├── .monolipse │ ├── Completion │ │ ├── UnityScriptParameterDataProvider.boo │ │ └── UnityScriptEditorCompletion.boo │ ├── UnityScript.MonoDevelop.booproj │ └── UnityScript.MonoDevelop.addin.xml ├── Boo.Ide │ ├── MethodDescriptor.boo │ ├── CursorLocationFinder.boo │ ├── MethodInvocationFinder.boo │ ├── LocalAccumulator.boo │ ├── CompletionProposer.boo │ ├── Boo.Ide.booproj │ ├── ProjectIndex.boo │ └── TargetLookup.boo ├── Boo.MonoDevelop.Util │ ├── ConfigurationItemPropertyMacro.boo │ ├── BooCompletionDataList.boo │ ├── ProjectIndexFactory.boo │ ├── MixedProjectIndex.boo │ ├── CompilationUnitDataProvider.boo │ ├── IBooIdeLanguageBinding.boo │ ├── Boo.MonoDevelop.Util.booproj │ └── DataProvider.boo └── UnityScript.Ide │ ├── ResolveMonoBehaviourType.boo │ ├── UnityScriptProjectIndexFactory.boo │ └── UnityScript.Ide.booproj ├── .gitignore ├── TODO ├── nunit.inc ├── .project ├── README.md ├── .settings └── org.eclipse.core.resources.prefs ├── LICENSE.txt └── default.build /src/Boo.Ide.Tests/.gitignore: -------------------------------------------------------------------------------- 1 | test-results 2 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/.gitignore: -------------------------------------------------------------------------------- 1 | test-results 2 | -------------------------------------------------------------------------------- /src/UnityScript.Ide.Tests/.gitignore: -------------------------------------------------------------------------------- 1 | test-results 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | build 3 | build.properties 4 | *.pidb 5 | *.userprefs 6 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/Consts.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import Boo.Adt 4 | 5 | let BooMimeType = "text/x-boo" -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Icons/BooFile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/Boo.MonoDevelop/Icons/BooFile.png -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Icons/Boo.File.Form: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/Boo.MonoDevelop/Icons/Boo.File.Form -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Icons/BooBinding.Base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/Boo.MonoDevelop/Icons/BooBinding.Base -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Icons/Boo.File.EmptyFile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/Boo.MonoDevelop/Icons/Boo.File.EmptyFile -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Icons/BooProjectDecoration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/Boo.MonoDevelop/Icons/BooProjectDecoration.png -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Icons/BooProjectStockIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/Boo.MonoDevelop/Icons/BooProjectStockIcon.png -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Icons/UnityScriptFile32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/UnityScript.MonoDevelop/Icons/UnityScriptFile32.png -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Icons/UnityScriptFile128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/UnityScript.MonoDevelop/Icons/UnityScriptFile128.png -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Icons/UnityScriptProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/UnityScript.MonoDevelop/Icons/UnityScriptProject.png -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Icons/UnityScriptProject32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/boo-md-addins/unity-staging/src/UnityScript.MonoDevelop/Icons/UnityScriptProject32.png -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/BooProjectParameters.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Projects 4 | 5 | class BooProjectParameters(ProjectParameters): 6 | pass -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/UnityScriptFiles.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop 2 | 3 | def IsUnityScriptFile(fileName as string): 4 | return System.IO.Path.GetExtension(fileName).ToLower() in (".us", ".js") 5 | 6 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptProjectParameters.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Projects 4 | 5 | class UnityScriptProjectParameters(ProjectParameters): 6 | pass -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * implement ITextEditorResolverProvider 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Boo.MonoDevelop.mdw: -------------------------------------------------------------------------------- 1 | 2 | 3 | Boo.MonoDevelop.sln 4 | ../../../../mono/monodevelop/main/Main.sln 5 | 6 | -------------------------------------------------------------------------------- /nunit.inc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/CommandHandlers/withAtomicUndoOn.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.CommandHandlers 2 | 3 | import Boo.Lang.Compiler 4 | import Boo.Lang.Compiler.Ast 5 | import Boo.Lang.PatternMatching 6 | 7 | macro withAtomicUndoOn(buffer as Expression): 8 | yield [| $buffer.BeginAtomicUndo() |] 9 | yield [| 10 | try: 11 | $(withAtomicUndoOn.Body) 12 | ensure: 13 | $buffer.EndAtomicUndo() 14 | |] 15 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | boo-extensions 4 | 5 | 6 | 7 | 8 | 9 | monolipse.core.booBuilder 10 | 11 | 12 | 13 | 14 | 15 | monolipse.core.booNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeGenerator.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import System.CodeDom.Compiler 4 | 5 | class UnityScriptCodeGenerator(CodeGenerator): 6 | 7 | override def Supports(supports as GeneratorSupport): 8 | return false 9 | 10 | override def CreateEscapedIdentifier(value as string): 11 | return value 12 | 13 | override def CreateValidIdentifier(value as string): 14 | return value -------------------------------------------------------------------------------- /src/Boo.Ide/MethodDescriptor.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import System 4 | 5 | import Boo.Lang.Compiler.TypeSystem 6 | 7 | class MethodDescriptor: 8 | [getter(Name)] _name as string 9 | [getter(Arguments)] _arguments as string* 10 | [getter(ReturnType)] _returnType as string 11 | 12 | def constructor(method as IMethod): 13 | _name = method.Name 14 | _arguments = List of string("${param.Name} as ${param.Type}" for param in method.GetParameters()) 15 | _returnType = "${method.ReturnType}" 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Building # 2 | 3 | git clone git://github.com/bamboo/boo 4 | 5 | git clone git://github.com/bamboo/boo-extensions 6 | 7 | git clone git://github.com/bamboo/boo-md-addins 8 | 9 | cd boo-md-addins 10 | 11 | cat > build.properties 12 | 13 | 14 | 15 | 16 | 17 | 18 | nant 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/IO.boo: -------------------------------------------------------------------------------- 1 | import System.IO 2 | 3 | def PathCombine(*paths as (string)): 4 | path = paths[0] 5 | for part in paths[1:]: 6 | path = Path.Combine(path, part) 7 | return path 8 | 9 | def CopyNewerFileToDirectory(fileName as string, outputDir as string): 10 | targetFile = Path.Combine(outputDir, Path.GetFileName(fileName)) 11 | if File.Exists(targetFile) and (File.GetLastWriteTime(targetFile) >= File.GetLastWriteTime(fileName)): 12 | return false 13 | File.Copy(fileName, targetFile, true) 14 | return true 15 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/ConfigurationItemPropertyMacro.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util 2 | 3 | import Boo.Lang.Compiler.Ast 4 | 5 | macro ConfigurationItemProperty: 6 | case [| ConfigurationItemProperty $(ReferenceExpression(Name: name)) = $initialValue |]: 7 | 8 | backingField = ReferenceExpression(Name: "_$name") 9 | yield [| 10 | private $backingField = $initialValue 11 | |] 12 | yield [| 13 | [ItemProperty($(name.ToLower()))] 14 | $name: 15 | get: return $backingField 16 | set: $backingField = value 17 | |] 18 | -------------------------------------------------------------------------------- /src/Boo.Ide/CursorLocationFinder.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import Boo.Lang.Compiler.Ast 4 | import Boo.Adt 5 | 6 | let CursorLocation = "__cursor_location__" 7 | 8 | class CursorLocationFinder(DepthFirstVisitor): 9 | 10 | _node as Expression 11 | 12 | def FindIn(root as Node): 13 | VisitAllowingCancellation(root) 14 | return _node 15 | 16 | override def LeaveMemberReferenceExpression(node as MemberReferenceExpression): 17 | if node.Name == CursorLocation: 18 | Found(node) 19 | 20 | protected def Found(node): 21 | _node = node 22 | Cancel() 23 | 24 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCodeDomProvider.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import System 4 | import System.CodeDom.Compiler 5 | 6 | class UnityScriptCodeDomProvider(CodeDomProvider): 7 | 8 | override FileExtension: 9 | get: return "js" 10 | 11 | override def CreateCompiler(): 12 | raise NotImplementedException() 13 | 14 | override def CreateGenerator(): 15 | return UnityScriptCodeGenerator() 16 | 17 | override def GetConverter(type as Type) as System.ComponentModel.TypeConverter: 18 | raise NotImplementedException() 19 | 20 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Templates/EmptyBooFile.xft.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Templates/EmptyUnityScriptFile.xft.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/Globals.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import System.Linq.Enumerable 4 | 5 | def SystemObjectMemberNames(): 6 | return "Equals", "GetHashCode", "GetType", "ToString" 7 | 8 | def ReIndent(code as string): 9 | lines = code.Replace("\r\n", "\n").Split(char('\n')) 10 | nonEmptyLines = line for line in lines if len(line.Trim()) 11 | 12 | indentation = /(\s*)/.Match(nonEmptyLines.First()).Groups[0].Value 13 | return code if len(indentation) == 0 14 | 15 | buffer = System.Text.StringBuilder() 16 | for line in lines: 17 | if line.StartsWith(indentation): 18 | buffer.AppendLine(line[len(indentation):]) 19 | else: 20 | buffer.AppendLine(line) 21 | return buffer.ToString() -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/BooParserTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Tests 2 | 3 | import NUnit.Framework 4 | import MonoDevelop.Projects 5 | import MonoDevelop.Projects.Dom 6 | 7 | [TestFixture] 8 | class BooParserTest(MonoDevelopTestBase): 9 | 10 | [Test] 11 | def SingleTypeModule(): 12 | 13 | code = """namespace BooParserTest 14 | class Foo: 15 | def Bar(): 16 | pass 17 | """ 18 | 19 | project as DotNetProject = CreateSingleFileProject("BooParserTest", code) 20 | dom = GetProjectDom(project) 21 | 22 | foo = dom.GetType("BooParserTest.Foo") 23 | assert foo is not null 24 | 25 | methods = List[of IMethod](foo.Methods) 26 | assert 1 == len(methods) 27 | Assert.AreEqual("Bar", methods[0].Name) 28 | Assert.AreEqual("void", methods[0].ReturnType.Name) 29 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Highlighting/BooSyntaxMode.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Highlighting 2 | 3 | import Mono.TextEditor 4 | import Mono.TextEditor.Highlighting 5 | import System.Collections.Generic 6 | 7 | class BooSyntaxMode(SyntaxMode): 8 | def constructor(): 9 | provider = ResourceXmlProvider(GetType().Assembly, "BooSyntaxMode.xml") 10 | using reader = provider.Open(): 11 | baseMode = SyntaxMode.Read(reader) 12 | self.rules = List[of Rule](baseMode.Rules) 13 | self.keywords = List[of Keywords](baseMode.Keywords) 14 | self.spans = baseMode.Spans 15 | self.matches = baseMode.Matches 16 | self.prevMarker = baseMode.PrevMarker 17 | self.SemanticRules = List[of SemanticRule](baseMode.SemanticRules) 18 | self.keywordTable = baseMode.keywordTable 19 | self.properties = baseMode.Properties 20 | 21 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/ImportsTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import System.Linq 4 | import NUnit.Framework 5 | 6 | import Boo.Ide 7 | 8 | [TestFixture] 9 | class ImportsTest: 10 | [Test] 11 | def ReturnsEmptyListForScriptWithNoImports(): 12 | index = ProjectIndex() 13 | code = ReIndent(""" 14 | class Foo: 15 | pass 16 | """) 17 | imports = index.ImportsFor("blah.boo", code) 18 | Assert.IsNotNull(imports) 19 | Assert.AreEqual(2, Enumerable.Count(imports)) 20 | 21 | [Test] 22 | def ReturnsNonEmptyListForScriptWithImports(): 23 | index = ProjectIndex() 24 | code = ReIndent(""" 25 | import System 26 | import System.Collections.Generic 27 | 28 | class Foo: 29 | pass 30 | """) 31 | imports = index.ImportsFor("blah.boo", code) 32 | Assert.IsNotNull(imports) 33 | Assert.AreEqual(4, Enumerable.Count(imports)) -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Mon Oct 12 23:06:46 BRT 2009 2 | eclipse.preferences.version=1 3 | encoding//examples/expressions/.monolipse=utf-8 4 | encoding//extensions/examples/ometa/calculator/.monolipse=utf-8 5 | encoding//extensions/examples/ometa/metaboo/.monolipse=utf-8 6 | encoding//extensions/examples/ometa/speed/.monolipse=utf-8 7 | encoding//extensions/examples/pegs/miniboo/.monolipse=utf-8 8 | encoding//extensions/src/Boo.MonoDevelop/.monolipse=utf-8 9 | encoding//extensions/src/Boo.OMeta.Parser.Tests/.monolipse=utf-8 10 | encoding//extensions/src/Boo.OMeta.Parser/.monolipse=utf-8 11 | encoding//extensions/src/Boo.OMeta.Tests/.monolipse=utf-8 12 | encoding//extensions/src/Boo.OMeta/.monolipse=utf-8 13 | encoding//extensions/src/Boo.Pegs.Tests/.monolipse=utf-8 14 | encoding//extensions/src/Boo.Pegs/.monolipse=utf-8 15 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/.monolipse: -------------------------------------------------------------------------------- 1 | 2 | boo 3 | library 4 | 5 | 6 | /boo-extensions/src/Boo.Adt 7 | 8 | 9 | /MonoDevelop/bin/MonoDevelop.Core.dll 10 | 11 | 12 | /MonoDevelop/bin/MonoDevelop.Ide.dll 13 | 14 | 15 | /boo-extensions/bin 16 | 17 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/ProjectIndexTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import Boo.Lang.Environments 4 | 5 | import Boo.Lang.Compiler 6 | import Boo.Lang.Compiler.Ast 7 | import Boo.Lang.Compiler.Steps 8 | 9 | import NUnit.Framework 10 | 11 | import Boo.Ide 12 | 13 | [TestFixture] 14 | class ProjectIndexTest: 15 | 16 | [Test] 17 | def CustomParserAndProposalCompiler(): 18 | 19 | m = Module(LexicalInfo("code.js")) 20 | parser = BooCompiler() 21 | parser.Parameters.Pipeline = CompilerPipeline() { ActionStep({ my(CompileUnit).Modules.Add(m) }) } 22 | 23 | compiled = false 24 | compiler = BooCompiler() 25 | compiler.Parameters.Pipeline = CompilerPipeline() { ActionStep({ compiled = true }) } 26 | 27 | index = ProjectIndex(compiler, parser, ["UnityEngine"]) 28 | assert index.ProposalsFor("code.js", "") is not null 29 | assert compiled 30 | 31 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/MethodsTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import NUnit.Framework 4 | 5 | import Boo.Ide 6 | 7 | [TestFixture] 8 | class MethodsTest: 9 | [Test] 10 | def ReturnsCorrectNumberOfOverloads(): 11 | index = ProjectIndex() 12 | code = ReIndent(""" 13 | class Foo: 14 | def blah(): 15 | foo = System.Collections.Generic.List of string() 16 | foo.CopyTo() 17 | """) 18 | methods = index.MethodsFor("/foo.boo", code, "CopyTo", 5) 19 | Assert.AreEqual(3, methods.Count) # List<>.CopyTo has 3 overloads 20 | 21 | [Test] 22 | def ReturnsNoMethodsWhenInvalid(): 23 | index = ProjectIndex() 24 | code = ReIndent(""" 25 | class Foo: 26 | def blah(): 27 | foo = string.Empty 28 | foo.ThisMethodDoesNotAndNeverWillExist() 29 | """) 30 | methods = index.MethodsFor("/foo.boo", code, "ThisMethodDoesNotAndNeverWillExist", 5) 31 | Assert.AreEqual(0, methods.Count) 32 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/MonoDevelopTestBase.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Tests 2 | 3 | import System 4 | import NUnit.Framework 5 | import MonoDevelop 6 | import MonoDevelop.Core.Assemblies 7 | import MonoDevelop.Projects.Dom.Parser 8 | import MonoDevelop.Ide 9 | import Gtk from "gtk-sharp" as Gtk 10 | 11 | class MonoDevelopTestBase: 12 | 13 | static firstRun = true 14 | 15 | [TestFixtureSetUp] 16 | virtual def SetUp(): 17 | if not firstRun: 18 | return 19 | 20 | firstRun = false 21 | 22 | Core.Runtime.Initialize(true) 23 | Gtk.Application.Init() 24 | ProjectDomService.TrackFileChanges = true 25 | DesktopService.Initialize() 26 | MonoDevelop.Projects.Services.ProjectService.DefaultTargetFramework = Core.Runtime.SystemAssemblyService.GetTargetFramework(TargetFrameworkMoniker("2.0")) 27 | 28 | [TestFixtureTearDown] 29 | virtual def TearDown(): 30 | pass 31 | -------------------------------------------------------------------------------- /src/UnityScript.Ide.Tests/ImportsTest.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.Ide.Tests 2 | 3 | import System.Linq.Enumerable 4 | import NUnit.Framework 5 | import UnityScript.Ide 6 | 7 | [TestFixture] 8 | class ImportsTest: 9 | [Test] 10 | def ReturnsEmptyListForScriptWithNoImports(): 11 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 12 | code = """ 13 | class Foo{} 14 | """ 15 | imports = index.ImportsFor("blah.js", code) 16 | Assert.IsNotNull(imports) 17 | Assert.AreEqual(3, imports.Count()) 18 | 19 | [Test] 20 | def ReturnsNonEmptyListForScriptWithImports(): 21 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 22 | code = """ 23 | import System; 24 | import System.Collections.Generic; 25 | 26 | class Foo{} 27 | """ 28 | imports = index.ImportsFor("blah.js", code) 29 | Assert.IsNotNull(imports) 30 | Assert.AreEqual(5, imports.Count()) -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/BooResolverTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Tests 2 | 3 | import MonoDevelop.Projects.Dom 4 | import NUnit.Framework 5 | import Boo.MonoDevelop.ProjectModel 6 | 7 | [TestFixture] 8 | class BooResolverTest(MonoDevelopTestBase): 9 | 10 | [Test] 11 | def CursorAtClassHeaderResolvesToClass(): 12 | code = """namespace BooResolverTest 13 | class Foo: 14 | def Bar(): 15 | pass 16 | """ 17 | 18 | project = CreateSingleFileProject("BooResolverTest", code) 19 | dom = GetProjectDom(project) 20 | type = dom.GetType("BooResolverTest.Foo") 21 | assert type is not null 22 | 23 | result = BooResolver(dom, type.CompilationUnit, "Foo.boo").Resolve( 24 | ExpressionResult("class Foo:\n"), 25 | DomLocation(2, 8)) as MemberResolveResult 26 | 27 | assert result is not null 28 | Assert.AreEqual(type.FullName, result.ResolvedMember.FullName) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/BooResolver.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Ide.TypeSystem 4 | 5 | import ICSharpCode.NRefactory 6 | import ICSharpCode.NRefactory.CSharp 7 | import ICSharpCode.NRefactory.CSharp.Completion 8 | 9 | class BooResolver: 10 | _compilationUnit as SyntaxTree 11 | 12 | def constructor(compilationUnit as SyntaxTree, fileName as string): 13 | _compilationUnit = compilationUnit 14 | 15 | def Resolve(result as CSharpCompletionEngineBase.ExpressionResult, location as TextLocation): 16 | # type = TypeAt(location) 17 | # if type is not null: 18 | # return MemberResolveResult(type) 19 | return null 20 | 21 | private def TypeAt(location as TextLocation): 22 | if _compilationUnit is null: 23 | return null 24 | 25 | # for type in _compilationUnit.Types: 26 | # if type.BodyRegion.Contains(location): 27 | # return type 28 | return null -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/BooCompletionDataList.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util.Completion 2 | 3 | import System 4 | import MonoDevelop.Ide.CodeCompletion 5 | 6 | class BooCompletionDataList(CompletionDataList, IMutableCompletionDataList): 7 | event Changed as EventHandler 8 | event Changing as EventHandler 9 | 10 | _isChanging as bool 11 | 12 | public IsChanging as bool: 13 | get: return _isChanging 14 | set: 15 | wasChanging = _isChanging 16 | _isChanging = value 17 | if _isChanging and not wasChanging: 18 | OnChanging(self, null) 19 | elif wasChanging and not _isChanging: 20 | OnChanged(self, null) 21 | 22 | def Dispose(): 23 | pass 24 | 25 | protected virtual def OnChanging(sender, args as EventArgs): 26 | Gtk.Application.Invoke ({ Changing (sender, args) }) 27 | 28 | protected virtual def OnChanged(sender, args as EventArgs): 29 | Gtk.Application.Invoke ({ Changed (sender, args) }) 30 | 31 | -------------------------------------------------------------------------------- /src/UnityScript.Ide/ResolveMonoBehaviourType.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.Ide 2 | 3 | import UnityScript 4 | import Boo.Lang.Compiler.Steps 5 | 6 | import System.Linq.Enumerable 7 | 8 | class ResolveMonoBehaviourType(AbstractCompilerStep): 9 | 10 | override def Run(): 11 | unityScriptParameters = Parameters as UnityScriptCompilerParameters 12 | scriptBaseType = unityScriptParameters.ScriptBaseType 13 | if scriptBaseType is not null and scriptBaseType.Name == "MonoBehaviour": 14 | print "ScriptBaseType is already set" 15 | return 16 | 17 | type = FindReferencedType("UnityEngine.MonoBehaviour") 18 | unityScriptParameters.ScriptBaseType = type or object 19 | 20 | def FindReferencedType(typeName as string): 21 | for assemblyRef in Parameters.References.OfType[of Boo.Lang.Compiler.TypeSystem.Reflection.IAssemblyReference](): 22 | type = assemblyRef.Assembly.GetType(typeName) 23 | if type is not null: 24 | return type 25 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/Util.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Tests 2 | 3 | import MonoDevelop.Projects 4 | import MonoDevelop.Projects.Dom.Parser 5 | 6 | import System.IO 7 | import Boo.Adt 8 | 9 | let TmpDir = Path.GetTempPath() 10 | 11 | def CreateSingleFileProject(projectName as string, code as string): 12 | tempFile = PathCombine(TmpDir, "Boo.MonoDevelop", projectName, projectName + ".boo") 13 | Directory.CreateDirectory(Path.GetDirectoryName(tempFile)) 14 | File.WriteAllText(tempFile, code) 15 | project = DotNetAssemblyProject("Boo") 16 | project.FileName = PathCombine(TmpDir, projectName + ".booproj") 17 | project.AddFile(tempFile) 18 | return project 19 | 20 | def PathCombine(*parts as (string)): 21 | path = parts[0] 22 | for part in parts[1:]: 23 | path = Path.Combine(path, part) 24 | return path 25 | 26 | def GetProjectDom([required] project as Project): 27 | ProjectDomService.Load(project) 28 | dom = ProjectDomService.GetProjectDom(project) 29 | dom.ForceUpdate(true) 30 | return dom 31 | -------------------------------------------------------------------------------- /src/UnityScript.Ide.Tests/MethodsTest.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.Ide.Tests 2 | 3 | import NUnit.Framework 4 | import UnityScript.Ide 5 | 6 | [TestFixture] 7 | class MethodsTest: 8 | 9 | [Test] 10 | def ReturnsCorrectNumberOfOverloads(): 11 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 12 | code = """ 13 | class Foo{ 14 | function blah(){ 15 | var foo = new System.Collections.Generic.List.(); 16 | foo.CopyTo(); 17 | } 18 | } 19 | """ 20 | methods = index.MethodsFor("foo.js", code, "CopyTo", 5) 21 | Assert.AreEqual(3, methods.Count) # List<>.CopyTo has 3 overloads 22 | 23 | [Test] 24 | def ReturnsNoMethodsWhenInvalid(): 25 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 26 | code = """ 27 | class Foo{ 28 | function blah(){ 29 | var foo = 5; 30 | foo.ThisMethodDoesNotAndNeverWillExist(); 31 | } 32 | } 33 | """ 34 | methods = index.MethodsFor("foo.js", code, "ThisMethodDoesNotAndNeverWillExist", 5) 35 | Assert.AreEqual(0, methods.Count) 36 | -------------------------------------------------------------------------------- /src/Boo.Ide/MethodInvocationFinder.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import System 4 | 5 | import Boo.Lang.Compiler.Ast 6 | 7 | class MethodInvocationFinder(DepthFirstVisitor): 8 | _node as MethodInvocationExpression 9 | _name as string 10 | _file as string 11 | _line as int 12 | 13 | def constructor(name as string, file as string, line as int): 14 | _name = name 15 | _file = file 16 | _line = line 17 | 18 | def FindIn(root as Node): 19 | VisitAllowingCancellation(root) 20 | return _node 21 | 22 | override def LeaveMethodInvocationExpression(expression as MethodInvocationExpression): 23 | if expression.LexicalInfo is null or expression.Target is null or expression.Target.Entity is null: 24 | return 25 | if not (expression.LexicalInfo.FileName.Equals(_file, StringComparison.OrdinalIgnoreCase) and \ 26 | expression.Target.Entity.Name == _name and \ 27 | expression.LexicalInfo.Line == _line): 28 | return 29 | Found(expression) 30 | 31 | protected def Found(node as MethodInvocationExpression): 32 | _node = node 33 | Cancel() 34 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 Rodrigo B. de Oliveira 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompilationParameters.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import System 4 | import MonoDevelop.Projects 5 | import MonoDevelop.Core.Serialization 6 | 7 | class UnityScriptCompilationParameters(ConfigurationParameters): 8 | static DefineSeparator = ";" 9 | 10 | [ItemProperty] 11 | DefineConstants as string: 12 | get: return string.Join (DefineSeparator, _defines.ToArray ()) 13 | set: 14 | if (string.IsNullOrEmpty (value)): 15 | _defines = System.Collections.Generic.List of string() 16 | else: 17 | _defines = System.Collections.Generic.List of string(value.Split ((DefineSeparator,), StringSplitOptions.RemoveEmptyEntries)) 18 | private _defines = System.Collections.Generic.List of string() 19 | 20 | DefineSymbols: 21 | get: return _defines 22 | 23 | override def AddDefineSymbol (symbol as string): 24 | _defines.Add (symbol) unless _defines.Contains (symbol) 25 | 26 | override def RemoveDefineSymbol (symbol as string): 27 | _defines.Remove (symbol) if _defines.Contains (symbol) 28 | 29 | override def HasDefineSymbol (symbol as string): 30 | return _defines.Contains (symbol) 31 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/ProjectIndexFactory.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util 2 | 3 | import MonoDevelop.Projects 4 | import Boo.Ide 5 | import UnityScript.Ide 6 | 7 | static class ProjectIndexFactory: 8 | indices = System.Collections.Generic.Dictionary[of DotNetProject, ProjectIndex]() 9 | 10 | def ForProject(project as DotNetProject): 11 | if project is null: 12 | return ProjectIndex() 13 | 14 | if indices.ContainsKey(project): 15 | return indices[project] 16 | 17 | index = CreateIndexFor(project) 18 | indices[project] = index 19 | return index 20 | 21 | private def CreateIndexFor(project as DotNetProject): 22 | booLanguageBinding = project.LanguageBinding as IBooIdeLanguageBinding 23 | if booLanguageBinding is not null: 24 | return booLanguageBinding.ProjectIndexFor(project) 25 | 26 | # This should never happen now that Unity is generating proper projects 27 | MonoDevelop.Core.LoggingService.LogWarning ("Unknown project type {0}!", project.LanguageBinding) 28 | return MixedProjectIndex(project, ProjectIndex(), UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex()) 29 | 30 | def LogError(x): 31 | System.Console.Error.WriteLine(x) 32 | -------------------------------------------------------------------------------- /src/Boo.Ide/LocalAccumulator.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import System 4 | import System.Collections.Generic 5 | import Boo.Lang.Compiler.Ast 6 | 7 | class LocalAccumulator(DepthFirstVisitor): 8 | _filename as string 9 | _line as int 10 | _enabled as Stack of bool 11 | _results as System.Collections.Generic.List of string 12 | 13 | def constructor(filename as string, line as int): 14 | _filename = System.IO.Path.GetFullPath(filename) 15 | _line = line 16 | 17 | [lock] 18 | def FindIn(root as Node): 19 | _results = System.Collections.Generic.List of string() 20 | _enabled = Stack of bool() 21 | Visit(root) 22 | return _results 23 | 24 | override def LeaveMethod(method as Method): 25 | AddMethodParams(method) 26 | 27 | override def LeaveConstructor(method as Constructor): 28 | AddMethodParams(method) 29 | 30 | private def AddMethodParams(method as Method): 31 | if method.LexicalInfo is null: return 32 | if not method.LexicalInfo.FullPath.Equals(_filename, StringComparison.OrdinalIgnoreCase): return 33 | if _line < method.LexicalInfo.Line or _line > method.EndSourceLocation.Line: return 34 | 35 | for local in method.Locals: 36 | _results.Add(local.Name) 37 | for param in method.Parameters: 38 | _results.Add(param.Name) 39 | 40 | -------------------------------------------------------------------------------- /src/UnityScript.Ide/UnityScriptProjectIndexFactory.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.Ide 2 | 3 | import Boo.Ide 4 | import Boo.Lang.Compiler 5 | import UnityScript 6 | 7 | static class UnityScriptProjectIndexFactory: 8 | 9 | final ScriptMainMethod = "Main" 10 | final ImplicitImports = List[of string]() { "UnityEngine", "UnityEditor", "System.Collections" } 11 | 12 | def CreateUnityScriptProjectIndex() as ProjectIndex: 13 | return ProjectIndex(CreateCompiler(), CreateParser(), []) 14 | 15 | private def CreateCompiler(): 16 | pipeline = UnityScriptCompiler.Pipelines.AdjustBooPipeline(Boo.Lang.Compiler.Pipelines.ResolveExpressions()) 17 | pipeline.InsertAfter(UnityScript.Steps.Parse, ResolveMonoBehaviourType()) 18 | pipeline.BreakOnErrors = false 19 | return CompilerWithPipeline(pipeline) 20 | 21 | private def CreateParser(): 22 | pipeline = UnityScriptCompiler.Pipelines.Parse() 23 | pipeline.InsertAfter(UnityScript.Steps.Parse, ResolveMonoBehaviourType()) 24 | pipeline.BreakOnErrors = false 25 | return CompilerWithPipeline(pipeline) 26 | 27 | private def CompilerWithPipeline(pipeline): 28 | parameters = UnityScriptCompilerParameters(ScriptMainMethod: ScriptMainMethod, Pipeline: pipeline) 29 | parameters.Imports = ImplicitImports 30 | return BooCompiler(parameters) 31 | 32 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/GUI/UnityScriptCompilationParametersPanel.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel.GUI 2 | 3 | import MonoDevelop.Projects 4 | import MonoDevelop.Ide.Gui.Dialogs 5 | 6 | import UnityScript.MonoDevelop.ProjectModel 7 | import Gtk from "gtk-sharp" 8 | 9 | class UnityScriptCompilationParametersPanel(MultiConfigItemOptionsPanel): 10 | 11 | override def CreatePanelWidget(): 12 | vbox = VBox () 13 | definesHbox = HBox () 14 | _definesEntry = Entry () 15 | definesLabel = Label ("Define Symbols: ") 16 | definesHbox.PackStart (definesLabel, false, false, 5) 17 | definesHbox.PackStart (_definesEntry, true , true, 5) 18 | vbox.PackStart (definesHbox, true, true, 5) 19 | vbox.ShowAll () 20 | return vbox 21 | 22 | override def LoadConfigData(): 23 | _definesEntry.Text = UnityScriptCompilationParameters.DefineConstants 24 | 25 | override def ValidateChanges(): 26 | return true 27 | 28 | override def ApplyChanges(): 29 | UnityScriptCompilationParameters.DefineConstants = _definesEntry.Text 30 | 31 | UnityScriptCompilationParameters as UnityScriptCompilationParameters: 32 | get: 33 | config as DotNetProjectConfiguration = self.CurrentConfiguration 34 | return config.CompilationParameters 35 | 36 | _definesEntry as Gtk.Entry 37 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/BooCompilationParameters.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import System 4 | import MonoDevelop.Projects 5 | import MonoDevelop.Core.Serialization 6 | 7 | import Boo.MonoDevelop.Util 8 | 9 | class BooCompilationParameters(ConfigurationParameters): 10 | static DefineSeparator = ";" 11 | 12 | ConfigurationItemProperty GenWarnings = false 13 | ConfigurationItemProperty Ducky = false 14 | ConfigurationItemProperty Culture = "" 15 | ConfigurationItemProperty NoStdLib = false 16 | 17 | [ItemProperty] 18 | DefineConstants as string: 19 | get: return string.Join (DefineSeparator, _defines.ToArray ()) 20 | set: 21 | if (string.IsNullOrEmpty (value)): 22 | _defines = System.Collections.Generic.List of string() 23 | else: 24 | _defines = System.Collections.Generic.List of string(value.Split ((DefineSeparator,), StringSplitOptions.RemoveEmptyEntries)) 25 | private _defines = System.Collections.Generic.List of string() 26 | 27 | DefineSymbols: 28 | get: return _defines 29 | 30 | override def AddDefineSymbol (symbol as string): 31 | _defines.Add (symbol) unless _defines.Contains (symbol) 32 | 33 | override def RemoveDefineSymbol (symbol as string): 34 | _defines.Remove (symbol) if _defines.Contains (symbol) 35 | 36 | override def HasDefineSymbol (symbol as string): 37 | return _defines.Contains (symbol) 38 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Templates/ConsoleProject.xpt.xml: -------------------------------------------------------------------------------- 1 | 2 | 42 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptParser.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import System 4 | import System.IO 5 | 6 | import MonoDevelop.Projects 7 | import MonoDevelop.Ide.TypeSystem 8 | 9 | import ICSharpCode.NRefactory.CSharp 10 | 11 | import Boo.MonoDevelop.Util 12 | import UnityScript.MonoDevelop 13 | 14 | class UnityScriptParser(TypeSystemParser): 15 | 16 | public static final MimeType = "text/x-unityscript" 17 | 18 | def constructor(): 19 | super() 20 | 21 | # override def CanParse(fileName as string): 22 | # return IsUnityScriptFile(fileName) 23 | 24 | override def Parse(storeAst as bool, fileName as string, reader as TextReader, project as Project): 25 | result = ParseUnityScript(fileName, reader.ReadToEnd ()) 26 | document = DefaultParsedDocument(fileName, Ast: SyntaxTree (FileName: fileName)) 27 | 28 | try: 29 | result.CompileUnit.Accept(DomConversionVisitor(document.GetAst of SyntaxTree ())) 30 | except e: 31 | LogError e 32 | 33 | return document 34 | 35 | def ParseUnityScript(fileName as string, content as string): 36 | compiler = UnityScript.UnityScriptCompiler() 37 | compiler.Parameters.ScriptMainMethod = "Awake" 38 | compiler.Parameters.ScriptBaseType = object 39 | compiler.Parameters.Pipeline = UnityScript.UnityScriptCompiler.Pipelines.Parse() 40 | compiler.Parameters.Input.Add(Boo.Lang.Compiler.IO.StringInput(fileName, content)) 41 | return compiler.Run() 42 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/tests/BooParserTest/BooParserTest.booproj: -------------------------------------------------------------------------------- 1 | Debug AnyCPU 9.0.21022 2.0 {C52F1A1D-F054-43FA-9BA9-1CFC2A38177D} Library BooParserTest false BooParserTest v3.5 true full bin\Debug prompt false false none bin\Release prompt false false -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Templates/ConsoleProject.xpt.xml: -------------------------------------------------------------------------------- 1 | 2 | 43 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/GUI/BooCompilationParametersPanel.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel.GUI 2 | 3 | import MonoDevelop.Projects 4 | import MonoDevelop.Ide.Gui.Dialogs 5 | 6 | import Boo.MonoDevelop.ProjectModel 7 | import Gtk from "gtk-sharp" 8 | 9 | class BooCompilationParametersPanel(MultiConfigItemOptionsPanel): 10 | 11 | override def CreatePanelWidget(): 12 | vbox = VBox () 13 | definesHbox = HBox () 14 | _noStdLibCheckButton = CheckButton.NewWithLabel("No standard libraries") 15 | vbox.PackStart (_noStdLibCheckButton, false, true, 5) 16 | _definesEntry = Entry () 17 | definesLabel = Label ("Define Symbols: ") 18 | definesHbox.PackStart (definesLabel, false, false, 5) 19 | definesHbox.PackStart (_definesEntry, true , true, 5) 20 | vbox.PackStart (definesHbox, true, true, 5) 21 | vbox.ShowAll () 22 | return vbox 23 | 24 | override def LoadConfigData(): 25 | _noStdLibCheckButton.Active = BooCompilationParameters.NoStdLib 26 | _definesEntry.Text = BooCompilationParameters.DefineConstants 27 | 28 | override def ValidateChanges(): 29 | return true 30 | 31 | override def ApplyChanges(): 32 | BooCompilationParameters.NoStdLib = _noStdLibCheckButton.Active 33 | BooCompilationParameters.DefineConstants = _definesEntry.Text 34 | 35 | BooCompilationParameters as BooCompilationParameters: 36 | get: 37 | config as DotNetProjectConfiguration = self.CurrentConfiguration 38 | return config.CompilationParameters 39 | 40 | _noStdLibCheckButton as Gtk.CheckButton 41 | _definesEntry as Gtk.Entry 42 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/BooParser.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import System 4 | import System.IO 5 | 6 | import MonoDevelop.Projects 7 | import MonoDevelop.Core 8 | import MonoDevelop.Ide.TypeSystem 9 | 10 | import ICSharpCode.NRefactory.CSharp 11 | 12 | import Boo.Lang.Compiler 13 | 14 | import Boo.MonoDevelop.Util 15 | 16 | class BooParser(TypeSystemParser): 17 | 18 | _compiler = Boo.Lang.Compiler.BooCompiler() 19 | 20 | def constructor(): 21 | pipeline = CompilerPipeline() { Steps.IntroduceModuleClasses() } 22 | _compiler.Parameters.Pipeline = pipeline 23 | 24 | override def Parse(storeAst as bool, fileName as string, reader as TextReader, project as Project): 25 | # LoggingService.LogError ("Parsing {0}", fileName) 26 | document = DefaultParsedDocument(fileName, Ast: SyntaxTree (FileName: fileName)) 27 | 28 | try: 29 | index = ProjectIndexFactory.ForProject(project) 30 | assert index is not null 31 | module = index.Parse(fileName, reader.ReadToEnd ()) 32 | IntroduceModuleClasses(module).Accept(DomConversionVisitor(document.GetAst of SyntaxTree ())) 33 | except e: 34 | LoggingService.LogError ("Parse error", e) 35 | 36 | return document 37 | 38 | # override def CreateResolver(dom as SyntaxTree, editor, fileName as string): 39 | # doc = cast(MonoDevelop.Ide.Gui.Document, editor) 40 | # return BooResolver(dom, doc.CompilationUnit, fileName) 41 | 42 | private def IntroduceModuleClasses(module as Ast.Module): 43 | return _compiler.Run(Ast.CompileUnit(module.CloneNode())).CompileUnit 44 | 45 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/MixedProjectIndex.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util 2 | 3 | import System 4 | import Boo.Ide 5 | import MonoDevelop.Projects 6 | 7 | class MixedProjectIndex(ProjectIndex): 8 | _booIndex as ProjectIndex 9 | _usIndex as ProjectIndex 10 | _project as DotNetProject 11 | 12 | def constructor(project as DotNetProject, booIndex as ProjectIndex, usIndex as ProjectIndex): 13 | _project = project 14 | _booIndex = booIndex 15 | _usIndex = usIndex 16 | 17 | override def ProposalsFor(filename as string, code as string): 18 | return IndexForSourceFile(filename).ProposalsFor(filename, code) 19 | 20 | override def MethodsFor(filename as string, code as string, methodName as string, methodLine as int): 21 | return IndexForSourceFile(filename).MethodsFor(filename, code, methodName, methodLine) 22 | 23 | override def ImportsFor(filename as string, code as string): 24 | return IndexForSourceFile(filename).ImportsFor(filename, code) 25 | 26 | override def AddReference(reference as System.Reflection.Assembly): 27 | _usIndex.AddReference(reference) 28 | _booIndex.AddReference(reference) 29 | 30 | override def AddReference(reference as string): 31 | _booIndex.AddReference(reference) 32 | _usIndex.AddReference(reference) 33 | 34 | override def LocalsAt(filename as string, code as string, line as int): 35 | return IndexForSourceFile(filename).LocalsAt(filename, code, line) 36 | 37 | def IndexForSourceFile(filename as string): 38 | if filename.EndsWith(".js", StringComparison.OrdinalIgnoreCase): return _usIndex 39 | return _booIndex -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Templates/LibraryProject.xpt.xml: -------------------------------------------------------------------------------- 1 | 2 | 44 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/LocalsTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import NUnit.Framework 4 | import Boo.Ide 5 | 6 | [TestFixture] 7 | class LocalsTest: 8 | [Test] 9 | def ReturnsNoLocals(): 10 | code = ReIndent(""" 11 | class Foo: 12 | baz = 4.2 13 | def Bar(): 14 | cursorgoeshere 15 | 16 | def Blah() 17 | blah = 12 18 | """) 19 | index = ProjectIndex() 20 | locals = index.LocalsAt("/foo.boo", code, 5) 21 | Assert.IsEmpty(locals) 22 | 23 | [Test] 24 | def ReturnsCorrectLocals(): 25 | code = ReIndent(""" 26 | class Foo: 27 | def Bar(): 28 | baz = 4.2 29 | cursorgoeshere 30 | 31 | def Blah() 32 | blah = 12 33 | """) 34 | index = ProjectIndex() 35 | locals = index.LocalsAt("/foo.boo", code, 5) 36 | Assert.Contains("baz", locals) 37 | Assert.IsFalse(locals.Contains("blah")) 38 | 39 | [Test] 40 | def ReturnsMethodParams(): 41 | code = ReIndent(""" 42 | class Foo: 43 | def Bar(baz as int): 44 | foo = 4.2 45 | cursorgoeshere 46 | 47 | def Blah(blah as int) 48 | blah = 12 49 | """) 50 | index = ProjectIndex() 51 | locals = index.LocalsAt("/foo.boo", code, 5) 52 | Assert.Contains("baz", locals) 53 | Assert.IsFalse(locals.Contains("blah")) 54 | 55 | [Test] 56 | def ReturnsConstructorParams(): 57 | code = ReIndent(""" 58 | class Foo: 59 | def constructor(baz as int): 60 | baz = 4.2 61 | cursorgoeshere 62 | 63 | def Blah(blah as int) 64 | blah = 12 65 | """) 66 | index = ProjectIndex() 67 | locals = index.LocalsAt("/foo.boo", code, 5) 68 | Assert.Contains("baz", locals) 69 | Assert.IsFalse(locals.Contains("blah")) 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/.monolipse: -------------------------------------------------------------------------------- 1 | 2 | boo 3 | library 4 | 5 | 6 | /UnityScript/src/UnityScript.Lang 7 | 8 | 9 | /UnityScript/src/UnityScript 10 | 11 | 12 | /MonoDevelop/bin/MonoDevelop.Core.dll 13 | 14 | 15 | /MonoDevelop/bin/MonoDevelop.Ide.dll 16 | 17 | 18 | /MonoDevelop/bin/MonoDevelop.Projects.dll 19 | 20 | 21 | /MonoDevelop/bin/Mono.TextEditor.dll 22 | 23 | 24 | /MonoDevelop/AddIns/MonoDevelop.SourceEditor2.dll 25 | 26 | 27 | /UnityScript/bin 28 | 29 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/CompilationUnitDataProvider.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util.Completion 2 | 3 | import System 4 | import System.Linq.Enumerable 5 | 6 | import MonoDevelop.Ide 7 | import MonoDevelop.Ide.Gui 8 | import MonoDevelop.Ide.TypeSystem 9 | import MonoDevelop.Ide.Gui.Content 10 | import MonoDevelop.Components 11 | 12 | class CompilationUnitDataProvider(DropDownBoxListWindow.IListDataProvider): 13 | private _document as Document 14 | 15 | internal static Pixbuf as Gdk.Pixbuf: 16 | get: 17 | return ImageService.GetPixbuf(Gtk.Stock.Add, Gtk.IconSize.Menu) 18 | 19 | public IconCount: 20 | get: 21 | if(_document.ParsedDocument != null): 22 | return _document.ParsedDocument.UserRegions.Count() 23 | return 0 24 | 25 | def constructor(document as Document): 26 | _document = document 27 | 28 | def GetText(position as int) as string: 29 | return (WorkaroundElementAt(_document.ParsedDocument.UserRegions, position) as FoldingRegion).Name 30 | 31 | def GetMarkup(position as int) as string: 32 | return GetText (position) 33 | 34 | def GetIcon(position as int) as Gdk.Pixbuf: 35 | return Pixbuf 36 | 37 | def GetTag(position as int) as object: 38 | return WorkaroundElementAt(_document.ParsedDocument.UserRegions, (position)) 39 | 40 | def ActivateItem(position as int): 41 | region = WorkaroundElementAt(_document.ParsedDocument.UserRegions, position) as FoldingRegion 42 | editor = _document.GetContent of IExtensibleTextEditor() 43 | if(editor != null): 44 | editor.SetCaretTo(Math.Max(1, region.Region.BeginLine), region.Region.BeginColumn) 45 | 46 | def Reset(): 47 | pass 48 | 49 | private def WorkaroundElementAt(items, index): 50 | i = 0 51 | for item in items: 52 | if(i == index): 53 | return item 54 | ++i 55 | return null 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/UnityScript.Ide.Tests/LocalsTest.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.Ide.Tests 2 | 3 | import NUnit.Framework 4 | import UnityScript.Ide 5 | 6 | [TestFixture] 7 | class LocalsTest: 8 | [Test] 9 | def ReturnsNoLocals(): 10 | code = """ 11 | class Foo{ 12 | var baz = 4.2; 13 | function Bar(){ 14 | cursorgoeshere 15 | } 16 | 17 | function Blah(){ 18 | var blah = 12; 19 | } 20 | } 21 | """ 22 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 23 | locals = index.LocalsAt("/foo.js", code, 5) 24 | Assert.IsEmpty(locals) 25 | 26 | [Test] 27 | def ReturnsCorrectLocals(): 28 | code = """ 29 | class Foo{ 30 | function Bar(){ 31 | baz = 4.2; 32 | cursorgoeshere 33 | } 34 | 35 | function Blah(){ 36 | blah = 12; 37 | } 38 | } 39 | """ 40 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 41 | locals = index.LocalsAt("/foo.js", code, 5) 42 | Assert.Contains("baz", locals) 43 | Assert.IsFalse(locals.Contains("blah")) 44 | 45 | [Test] 46 | def ReturnsMethodParams(): 47 | code = """ 48 | class Foo{ 49 | function Bar(baz: int){ 50 | baz = 4.2; 51 | cursorgoeshere 52 | } 53 | 54 | function Blah(blah: int){ 55 | blah = 12; 56 | } 57 | } 58 | """ 59 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 60 | locals = index.LocalsAt("/foo.js", code, 5) 61 | Assert.Contains("baz", locals) 62 | Assert.IsFalse(locals.Contains("blah")) 63 | 64 | [Test] 65 | def ReturnsConstructorParams(): 66 | code = """ 67 | class Foo{ 68 | function Foo(baz: int){ 69 | baz = 4.2; 70 | cursorgoeshere 71 | } 72 | 73 | function Blah(blah: int){ 74 | blah = 12; 75 | } 76 | } 77 | """ 78 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 79 | locals = index.LocalsAt("/foo.js", code, 5) 80 | Assert.Contains("baz", locals) 81 | Assert.IsFalse(locals.Contains("blah")) 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/BooLanguageBinding.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Core 4 | import MonoDevelop.Projects 5 | import System.Xml 6 | 7 | import Boo.Ide 8 | import Boo.MonoDevelop.Util 9 | 10 | class BooLanguageBinding(BooIdeLanguageBinding, IDotNetLanguageBinding): 11 | 12 | ProjectStockIcon: 13 | get: return "md-boo-project" 14 | 15 | SingleLineCommentTag: 16 | get: return "#" 17 | 18 | BlockCommentStartTag: 19 | get: return "/*" 20 | 21 | BlockCommentEndTag: 22 | get: return "*/" 23 | 24 | Refactorer: 25 | get: return null 26 | 27 | Parser: 28 | get: return null 29 | 30 | Language: 31 | get: return "Boo" 32 | 33 | static def IsBooFile(fileName as string): 34 | return fileName.ToLower().EndsWith(".boo") 35 | 36 | def IsSourceCodeFile(fileName as FilePath): 37 | return IsBooFile(fileName) 38 | 39 | def IsSourceCodeFile(fileName as string): 40 | return IsBooFile(fileName) 41 | 42 | def GetFileName(baseName as FilePath): 43 | return baseName + ".boo" 44 | 45 | def GetFileName(baseName as string): 46 | return baseName + ".boo" 47 | 48 | def GetCodeDomProvider(): 49 | return Boo.Lang.CodeDom.BooCodeProvider() 50 | 51 | def CreateProjectParameters(projectOptions as XmlElement): 52 | return BooProjectParameters() 53 | 54 | def CreateCompilationParameters(projectOptions as XmlElement): 55 | return BooCompilationParameters() 56 | 57 | def GetSupportedClrVersions(): 58 | return (ClrVersion.Net_1_1, ClrVersion.Net_2_0, ClrVersion.Clr_2_1, ClrVersion.Net_4_0) 59 | 60 | def Compile(items as ProjectItemCollection, 61 | config as DotNetProjectConfiguration, 62 | selector as ConfigurationSelector, 63 | progressMonitor as IProgressMonitor): 64 | return BooCompiler(config, selector, items, progressMonitor).Run() 65 | 66 | override def CreateProjectIndex(): 67 | return ProjectIndex() 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptLanguageBinding.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Core 4 | import MonoDevelop.Projects 5 | import System.Xml 6 | 7 | import UnityScript.MonoDevelop 8 | 9 | import Boo.MonoDevelop.Util 10 | 11 | class UnityScriptLanguageBinding(BooIdeLanguageBinding, IDotNetLanguageBinding): 12 | 13 | ProjectStockIcon: 14 | get: return "md-unityscript-project" 15 | 16 | SingleLineCommentTag: 17 | get: return "//" 18 | 19 | BlockCommentStartTag: 20 | get: return "/*" 21 | 22 | BlockCommentEndTag: 23 | get: return "*/" 24 | 25 | Refactorer: 26 | get: return null 27 | 28 | Parser: 29 | get: return null 30 | 31 | Language: 32 | get: return "UnityScript" 33 | 34 | def IsSourceCodeFile(fileName as string): 35 | return IsUnityScriptFile(fileName) 36 | 37 | def IsSourceCodeFile(fileName as FilePath): 38 | return IsUnityScriptFile(fileName) 39 | 40 | def GetFileName(baseName as string): 41 | return baseName + ".js" 42 | 43 | def GetFileName(baseName as FilePath): 44 | return baseName + ".js" 45 | 46 | def GetCodeDomProvider(): 47 | return null 48 | 49 | def CreateProjectParameters(projectOptions as XmlElement): 50 | return UnityScriptProjectParameters() 51 | 52 | def CreateCompilationParameters(projectOptions as XmlElement): 53 | return UnityScriptCompilationParameters() 54 | 55 | def GetSupportedClrVersions(): 56 | return (ClrVersion.Net_1_1, ClrVersion.Net_2_0, ClrVersion.Clr_2_1, ClrVersion.Net_4_0) 57 | 58 | def Compile(items as ProjectItemCollection, 59 | config as DotNetProjectConfiguration, 60 | selector as ConfigurationSelector, 61 | progressMonitor as IProgressMonitor): 62 | return UnityScriptCompiler(config, selector, items, progressMonitor).Run() 63 | 64 | override def CreateProjectIndex(): 65 | return UnityScript.Ide.UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 66 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/IBooIdeLanguageBinding.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util 2 | 3 | import Boo.Ide 4 | import MonoDevelop.Projects 5 | import Boo.Lang.Compiler.Util 6 | 7 | import System.IO 8 | import System.Linq.Enumerable 9 | import System.Reflection 10 | 11 | interface IBooIdeLanguageBinding: 12 | def ProjectIndexFor(project as DotNetProject) as ProjectIndex 13 | 14 | class BooIdeLanguageBinding(IBooIdeLanguageBinding): 15 | 16 | _projectIndexFor = MemoizedFunction[of DotNetProject, ProjectIndex](NewProjectIndexFor) 17 | 18 | def constructor(): 19 | LogError "$(GetType())()" 20 | 21 | [lock] 22 | def ProjectIndexFor(project as DotNetProject): 23 | return _projectIndexFor.Invoke(project) 24 | 25 | protected abstract def CreateProjectIndex() as ProjectIndex: 26 | pass 27 | 28 | protected def NewProjectIndexFor(project as DotNetProject): 29 | LogError "NewProjectIndexFor($project)" 30 | index = CreateProjectIndex() 31 | AddReferencesTo(index, project) 32 | return index 33 | 34 | protected def AddReferencesTo(index as ProjectIndex, project as DotNetProject): 35 | for reference in project.References: 36 | AddReferenceTo(index, reference) 37 | 38 | protected def AddReferenceTo(index as ProjectIndex, reference as ProjectReference): 39 | if ReferenceType.Project == reference.ReferenceType: 40 | return 41 | 42 | for file in reference.GetReferencedFileNames(Workspace.ActiveConfiguration): 43 | assembly = LoadAssembly(file) 44 | index.AddReference(assembly) if assembly is not null 45 | 46 | protected def ProjectIndexFor(projectName as string) as ProjectIndex: 47 | return ProjectIndexFor(Workspace.GetAllProjects().FirstOrDefault({ p as Project | p.Name == projectName })) 48 | 49 | Workspace: 50 | get: return MonoDevelop.Ide.IdeApp.Workspace 51 | 52 | def LoadAssembly(file as string): 53 | try: 54 | if File.Exists(file): 55 | return Assembly.LoadFrom(file) 56 | return Assembly.Load(file) 57 | except x: 58 | LogError x 59 | return null 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Editor/BooIndentation.boo: -------------------------------------------------------------------------------- 1 | 2 | // Adapted from PythonEditorIndentation.cs 3 | // Copyright (c) 2008 Christian Hergert 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | namespace Boo.MonoDevelop.Editing 24 | 25 | import System 26 | import MonoDevelop.Ide.Gui.Content 27 | import Gdk from "gdk-sharp" 28 | 29 | class BooEditorIndentation(TextEditorExtension): 30 | 31 | override def KeyPress(key as Key, keyChar as char, modifier as ModifierType): 32 | if key != Gdk.Key.Return: 33 | return super(key, keyChar, modifier) 34 | 35 | lastLine = Editor.GetLineText(Editor.Caret.Line) 36 | if ShouldIndentAfter(lastLine): 37 | super(key, keyChar, modifier) 38 | Editor.InsertAtCaret ("\t") 39 | return false 40 | return super(key, keyChar, modifier) 41 | 42 | private def ShouldIndentAfter(line as string): 43 | trimmed = line.Trim() 44 | if trimmed.EndsWith(":"): 45 | return true 46 | if trimmed.StartsWith("if ") or trimmed.StartsWith("def "): 47 | openCount = line.Split(char('(')).Length 48 | closeCount = line.Split(char(')')).Length 49 | return openCount > closeCount 50 | return false -------------------------------------------------------------------------------- /src/Boo.Ide/CompletionProposer.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import Boo.Lang.Compiler.Ast 4 | 5 | import Boo.Lang.Compiler.TypeSystem 6 | import Boo.Lang.Compiler.TypeSystem.Core 7 | 8 | import Boo.Lang.Environments 9 | import Boo.Lang.PatternMatching 10 | 11 | import System.Linq.Enumerable 12 | 13 | class CompletionProposal: 14 | [getter(Entity)] _entity as IEntity 15 | [getter(Name)] _name as string 16 | [getter(EntityType)] _entityType as EntityType 17 | [getter(Description)] _description as string 18 | 19 | def constructor(entity as IEntity): 20 | _entity = entity 21 | _name = entity.Name 22 | _entityType = entity.EntityType 23 | ambiguous = entity as Ambiguous 24 | if ambiguous is not null: 25 | _description = "${ambiguous.Entities[0]} (${ambiguous.Entities.Length} overloads)" 26 | else: 27 | _description = entity.ToString() 28 | 29 | static class CompletionProposer: 30 | 31 | def ForExpression(expression as Expression): 32 | match expression: 33 | case MemberReferenceExpression(Target: target=Expression(ExpressionType)): 34 | match target.Entity: 35 | case IType(): 36 | members = StaticMembersOf(ExpressionType) 37 | case ns=INamespace(EntityType: EntityType.Namespace): 38 | members = ns.GetMembers() 39 | otherwise: 40 | members = InstanceMembersOf(ExpressionType) 41 | 42 | membersByName = members.GroupBy({ member | member.Name }) 43 | for member in membersByName: 44 | yield CompletionProposal(Entities.EntityFromList(member.ToList())) 45 | otherwise: 46 | pass 47 | 48 | def InstanceMembersOf(type as IType): 49 | for member in AccessibleMembersOf(type): 50 | match member: 51 | case IAccessibleMember(IsStatic): 52 | yield member unless IsStatic 53 | otherwise: 54 | yield member 55 | 56 | def StaticMembersOf(type as IType): 57 | for member in AccessibleMembersOf(type): 58 | match member: 59 | case IAccessibleMember(IsStatic): 60 | yield member if IsStatic 61 | otherwise: 62 | yield member 63 | 64 | def AccessibleMembersOf(type as IType): 65 | currentType = type 66 | while currentType is not null: 67 | for member in currentType.GetMembers(): 68 | if IsSpecialName(member.Name): 69 | continue 70 | match member: 71 | case IConstructor(): 72 | continue 73 | case IEvent(): 74 | yield member 75 | case IAccessibleMember(IsPublic): 76 | if IsPublic: 77 | yield member 78 | otherwise: 79 | continue 80 | if currentType.IsInterface: 81 | currentType = (currentType.GetInterfaces() as IType*).FirstOrDefault() or my(TypeSystemServices).ObjectType 82 | else: 83 | currentType = currentType.BaseType 84 | 85 | _specialPrefixes = { "get_": 1, "set_": 1, "add_": 1, "remove_": 1, "op_": 1 } 86 | 87 | def IsSpecialName(name as string): 88 | index = name.IndexOf('_') 89 | return false if index < 0 90 | 91 | prefix = name[:index + 1] 92 | return prefix in _specialPrefixes 93 | 94 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Completion/UnityScriptParameterDataProvider.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.Completion 2 | 3 | import System.Linq 4 | import MonoDevelop.Ide.Gui 5 | import MonoDevelop.Ide.CodeCompletion 6 | import ICSharpCode.NRefactory.Completion 7 | import ICSharpCode.NRefactory.CSharp.Completion 8 | import Boo.Ide 9 | 10 | class UnityScriptParameterDataProvider(ParameterDataProvider): 11 | _methods as List of MethodDescriptor 12 | _document as Document 13 | 14 | def constructor(document as Document, methods as List of MethodDescriptor): 15 | _methods = methods 16 | _document = document 17 | 18 | Count: 19 | get: return _methods.Count 20 | 21 | def GetCurrentParameterIndex(widget as ICompletionWidget, context as CodeCompletionContext): 22 | line = _document.Editor.GetLineText(context.TriggerLine) 23 | offset = _document.Editor.Caret.Column-2 24 | if(0 <= offset and offset < line.Length): 25 | stack = 0 26 | for i in range(offset, -1, -1): 27 | current = line[i:i+1] 28 | if (')' == current): --stack 29 | elif('(' == current): ++stack 30 | if (1 == stack): 31 | return /,/.Split(line[0:offset+1]).Length 32 | return -1 33 | 34 | def GetHeading (overloadIndex as int, parameterMarkup as (string), currentParameterIndex as int): 35 | return GetMethodMarkup (overloadIndex, parameterMarkup, currentParameterIndex) 36 | 37 | def GetMethodMarkup(overloadIndex as int, parameterMarkup as (string), currentParameterIndex as int): 38 | method = _methods[overloadIndex] 39 | methodName = System.Security.SecurityElement.Escape(method.Name) 40 | methodReturnType = System.Security.SecurityElement.Escape(method.ReturnType) 41 | return "${methodName}(${string.Join(',',parameterMarkup)}): ${methodReturnType}" 42 | 43 | def GetParameterName (overloadIndex as int, parameterIndex as int): 44 | return GetParameterMarkup (overloadIndex, parameterIndex) 45 | 46 | def GetParameterDescription (overloadIndex as int, parameterIndex as int): 47 | return GetParameterMarkup (overloadIndex, parameterIndex) 48 | 49 | def GetDescription (overloadIndex as int, parameterIndex as int): 50 | return GetParameterMarkup (overloadIndex, parameterIndex) 51 | 52 | def GetParameterMarkup(overloadIndex as int, parameterIndex as int): 53 | return Enumerable.ElementAt(_methods[overloadIndex].Arguments, parameterIndex).Replace (" as ", ": ") 54 | 55 | def GetParameterCount(overloadIndex as int): 56 | return Enumerable.Count(_methods[overloadIndex].Arguments) 57 | 58 | def AllowParameterList (overloadIndex as int): 59 | return true 60 | 61 | override def CreateTooltipInformation (overloadIndex as int, parameterIndex as int, smartWrap as bool) as TooltipInformation: 62 | info = TooltipInformation () 63 | parameterMarkup = System.Collections.Generic.List of string () 64 | for i in range(0, GetParameterCount (overloadIndex), 1): 65 | parameterMarkup.Add (GetParameterMarkup (overloadIndex, i)) 66 | info.SignatureMarkup = GetMethodMarkup (overloadIndex, parameterMarkup.ToArray (), parameterIndex) 67 | return info 68 | 69 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Completion/BooParameterDataProvider.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Completion 2 | 3 | import System 4 | import System.Linq 5 | 6 | import MonoDevelop.Ide.Gui 7 | import MonoDevelop.Ide.CodeCompletion 8 | import ICSharpCode.NRefactory.Completion 9 | import ICSharpCode.NRefactory.CSharp.Completion 10 | import Boo.Ide 11 | 12 | class BooParameterDataProvider(ParameterDataProvider): 13 | _methods as List of MethodDescriptor 14 | _document as Document 15 | 16 | def constructor(document as Document, methods as List of MethodDescriptor): 17 | _methods = methods 18 | _document = document 19 | 20 | Count: 21 | get: return _methods.Count 22 | 23 | def GetCurrentParameterIndex(widget as ICompletionWidget, context as CodeCompletionContext): 24 | line = _document.Editor.GetLineText(context.TriggerLine) 25 | offset = _document.Editor.Caret.Column-2 26 | if(0 <= offset and offset < line.Length): 27 | stack = 0 28 | for i in range(offset, -1, -1): 29 | current = line[i:i+1] 30 | if (')' == current): --stack 31 | elif('(' == current): ++stack 32 | if (1 == stack): 33 | return /,/.Split(line[0:offset+1]).Length 34 | return -1 35 | 36 | def GetHeading (overloadIndex as int, parameterMarkup as (string), currentParameterIndex as int): 37 | return GetMethodMarkup (overloadIndex, parameterMarkup, currentParameterIndex) 38 | 39 | def GetMethodMarkup(overloadIndex as int, parameterMarkup as (string), currentParameterIndex as int): 40 | methodName = System.Security.SecurityElement.Escape(_methods[overloadIndex].Name) 41 | methodReturnType = System.Security.SecurityElement.Escape(_methods[overloadIndex].ReturnType) 42 | return "${methodName}(${string.Join(',',parameterMarkup)}) as ${methodReturnType}" 43 | 44 | def GetParameterName (overloadIndex as int, parameterIndex as int): 45 | return GetParameterMarkup (overloadIndex, parameterIndex) 46 | 47 | def GetParameterDescription (overloadIndex as int, parameterIndex as int): 48 | return GetParameterMarkup (overloadIndex, parameterIndex) 49 | 50 | def GetDescription (overloadIndex as int, parameterIndex as int): 51 | return GetParameterMarkup (overloadIndex, parameterIndex) 52 | 53 | def GetParameterMarkup(overloadIndex as int, parameterIndex as int): 54 | return System.Security.SecurityElement.Escape(Enumerable.ElementAt(_methods[overloadIndex].Arguments, parameterIndex)) 55 | 56 | def GetParameterCount(overloadIndex as int): 57 | return Enumerable.Count(_methods[overloadIndex].Arguments) 58 | 59 | def AllowParameterList (overloadIndex as int): 60 | return true 61 | 62 | override def CreateTooltipInformation (overloadIndex as int, parameterIndex as int, smartWrap as bool) as TooltipInformation: 63 | info = TooltipInformation () 64 | parameterMarkup = System.Collections.Generic.List of string () 65 | for i in range(0, GetParameterCount (overloadIndex), 1): 66 | parameterMarkup.Add (GetParameterMarkup (overloadIndex, i)) 67 | info.SignatureMarkup = GetMethodMarkup (overloadIndex, parameterMarkup.ToArray (), parameterIndex) 68 | return info 69 | 70 | -------------------------------------------------------------------------------- /src/UnityScript.Ide/UnityScript.Ide.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {53D5E189-64E0-49A6-A8F3-505599E84639} 9 | Library 10 | UnityScript.Ide 11 | false 12 | UnityScript.Ide 13 | v4.0 14 | 15 | 16 | true 17 | full 18 | bin\Debug 19 | prompt 20 | false 21 | 22 | false 23 | false 24 | false 25 | 26 | 27 | none 28 | bin\Release 29 | prompt 30 | false 31 | 32 | false 33 | false 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 51 | Boo.Ide 52 | 53 | 54 | {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB} 55 | UnityScript 56 | 57 | 58 | {2784E7F4-5206-4BF9-99CD-96B1D94D0E19} 59 | UnityScript.Lang 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/Boo.Ide.Tests.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {0006C2FE-E307-4180-8DBE-89392174228E} 9 | Library 10 | Boo.Ide.Tests 11 | false 12 | Boo.Ide.Tests 13 | v4.0 14 | 15 | 16 | true 17 | full 18 | bin\Debug 19 | prompt 20 | false 21 | 22 | false 23 | false 24 | false 25 | 26 | 27 | none 28 | bin\Release 29 | prompt 30 | false 31 | 32 | false 33 | false 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 58 | Boo.Ide 59 | 60 | 61 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F} 62 | Boo.Adt 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/UnityScript.Ide.Tests/UnityScriptProjectIndexFactoryTest.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.Ide.Tests 2 | 3 | import System.Reflection 4 | 5 | import NUnit.Framework 6 | import UnityScript.Ide 7 | 8 | import Boo.Ide 9 | import Boo.Ide.Tests 10 | 11 | [TestFixture] 12 | class UnityScriptProjectIndexFactoryTest: 13 | 14 | [Test] 15 | def ProposalsForUnityScriptCode(): 16 | 17 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 18 | proposals = index.ProposalsFor("code.js", "class Foo { function Bar() {} }; new Foo().$CursorLocation") 19 | expected = ("Bar",) + SystemObjectMemberNames() 20 | AssertProposalNames(expected, proposals) 21 | 22 | [Test] 23 | [Ignore("Work in progress")] 24 | def ParseReturnsCodeWithUnityScriptSemantics(): 25 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 26 | module = index.Parse("Code.js", "function foo() {}") 27 | expected = [| 28 | import UnityEngine 29 | import UnityEditor 30 | import System.Collections 31 | 32 | partial public class Code(Object): 33 | public virtual def foo() as void: 34 | pass 35 | public virtual def Main() as void: 36 | pass 37 | public def constructor(): 38 | super() 39 | |] 40 | Assert.AreEqual(expected.ToCodeString(), module.ToCodeString()) 41 | 42 | [Test] 43 | def ProposalsForExternalReferences(): 44 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 45 | index.AddReference(Assembly.Load("System.Xml")) 46 | code = """ 47 | import System.Xml; 48 | 49 | class Foo 50 | { 51 | static function foo() { 52 | new XmlDocument().$CursorLocation 53 | } 54 | } 55 | """ 56 | proposals = index.ProposalsFor("code.js", code) 57 | for proposal in proposals: 58 | if(proposal.Entity.Name == "CreateXmlDeclaration"): return 59 | Assert.Fail("CreateXmlDeclaration not found in XmlDocument") 60 | 61 | [Test] 62 | def ProposalsForThis(): 63 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 64 | code = """ 65 | function foo() { 66 | this.$CursorLocation 67 | } 68 | """ 69 | proposals = index.ProposalsFor("code.js", code) 70 | expected = ("foo",) + MonoBehaviourMemberNames() 71 | AssertProposalNames(expected, proposals) 72 | 73 | 74 | [Test] 75 | def ProposalsForMembersOfImplicitlyImportedTypes(): 76 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 77 | code = """ 78 | class Foo 79 | { 80 | function foo() { 81 | ArrayList.$CursorLocation 82 | } 83 | } 84 | """ 85 | proposals = index.ProposalsFor("code.js", code) 86 | expected = ("Adapter","Synchronized","ReadOnly","FixedSize","Repeat","Equals","ReferenceEquals") 87 | AssertProposalNames(expected, proposals) 88 | 89 | [Test] 90 | def ProposalsForTypeReferenceIncludeOnlyStaticMethods(): 91 | index = UnityScriptProjectIndexFactory.CreateUnityScriptProjectIndex() 92 | code = """ 93 | class Foo { 94 | static function NewInstance(): Foo { return null; } 95 | function Bar(){} 96 | } 97 | Foo.$CursorLocation 98 | """ 99 | proposals = index.ProposalsFor("code.js", code) 100 | expected = ("NewInstance", "Equals", "ReferenceEquals") 101 | AssertProposalNames(expected, proposals) 102 | 103 | def MonoBehaviourMemberNames(): 104 | return ("Main",) + SystemObjectMemberNames() -------------------------------------------------------------------------------- /src/Boo.Ide/Boo.Ide.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 9 | Library 10 | Boo.Ide 11 | false 12 | Boo.Ide 13 | v4.0 14 | 15 | 16 | true 17 | full 18 | bin\Debug 19 | prompt 20 | false 21 | 22 | false 23 | false 24 | false 25 | 26 | 27 | none 28 | bin\Release 29 | prompt 30 | false 31 | 32 | false 33 | false 34 | false 35 | 36 | 37 | 38 | 39 | 40 | False 41 | ..\..\..\boo\build\Boo.Lang.dll 42 | 43 | 44 | False 45 | ..\..\..\boo\build\Boo.Lang.Compiler.dll 46 | 47 | 48 | False 49 | ..\..\..\boo\build\Boo.Lang.Parser.dll 50 | 51 | 52 | False 53 | ..\..\..\boo\build\Boo.Lang.PatternMatching.dll 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F} 68 | Boo.Adt 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/UnityScript.Ide.Tests/UnityScript.Ide.Tests.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {A0F2C421-3C9C-45F1-9CA1-839C73D2B953} 9 | Library 10 | UnityScript.Ide.Tests 11 | false 12 | UnityScript.Ide.Tests 13 | v4.0 14 | 15 | 16 | true 17 | full 18 | bin\Debug 19 | prompt 20 | false 21 | 22 | false 23 | false 24 | false 25 | 26 | 27 | none 28 | bin\Release 29 | prompt 30 | false 31 | 32 | false 33 | false 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {53D5E189-64E0-49A6-A8F3-505599E84639} 55 | UnityScript.Ide 56 | 57 | 58 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 59 | Boo.Ide 60 | 61 | 62 | {0006C2FE-E307-4180-8DBE-89392174228E} 63 | Boo.Ide.Tests 64 | 65 | 66 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F} 67 | Boo.Adt 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/DotCompletionTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import NUnit.Framework 4 | 5 | import Boo.Ide 6 | import Boo.Lang.Compiler.MetaProgramming 7 | 8 | [TestFixture] 9 | class DotCompletionTest: 10 | 11 | [Test] 12 | def ProposalsForTypeInferredLocalVariable(): 13 | 14 | code = """ 15 | class Foo: 16 | def Bar(): 17 | pass 18 | 19 | f = Foo() 20 | f.$CursorLocation 21 | """ 22 | 23 | proposals = ProposalsFor(code) 24 | expected = ("Bar",) + SystemObjectMemberNames() 25 | AssertProposalNames(expected, proposals) 26 | 27 | [Test] 28 | def ProposalsForTypeReferenceIncludeOnlyStaticMethods(): 29 | code = """ 30 | class Foo: 31 | static def NewInstance() as Foo: 32 | pass 33 | def Bar(): 34 | pass 35 | Foo.$CursorLocation 36 | """ 37 | proposals = ProposalsFor(code) 38 | expected = ("NewInstance", "Equals", "ReferenceEquals") 39 | AssertProposalNames(expected, proposals) 40 | 41 | [Test] 42 | def ProposalsForNamespace(): 43 | 44 | code = [| 45 | namespace MyLib 46 | class Foo: 47 | pass 48 | |] 49 | index = ProjectIndex() 50 | index.AddReference(compile(code)) 51 | proposals = index.ProposalsFor("code.boo", "MyLib.$CursorLocation") 52 | AssertProposalNames(("Foo",), proposals) 53 | 54 | [Test] 55 | def ProposalsForInterfacesIncludeSuperInterfaceMembers(): 56 | index = ProjectIndex() 57 | index.AddReference(typeof(ISub).Assembly) 58 | 59 | code = ReIndent(""" 60 | v as $(typeof(ISub).BooTypeName()) 61 | v.$CursorLocation 62 | """) 63 | proposals = index.ProposalsFor("code.boo", code) 64 | expected = ("SubMethod", "SuperMethod") + SystemObjectMemberNames() 65 | AssertProposalNames(expected, proposals) 66 | 67 | interface ISuper: 68 | def SuperMethod() 69 | 70 | interface ISub(ISuper): 71 | def SubMethod() 72 | 73 | [Test] 74 | def ProposalsForSubClassDontIncludeInaccessibleMembersFromSuper(): 75 | 76 | code = """ 77 | class Super: 78 | def Foo(): 79 | pass 80 | private def Bar(): 81 | pass 82 | 83 | class Sub(Super): 84 | def constructor(): 85 | self.$CursorLocation # can't access Bar from here 86 | """ 87 | 88 | proposals = ProposalsFor(code) 89 | expected = ("Foo",) + SystemObjectMemberNames() 90 | AssertProposalNames(expected, proposals) 91 | 92 | [Test] 93 | def ProposalsForOverloadedMethodsAppearOnlyOnceAsAnAmbiguousEntity(): 94 | code = """ 95 | class Super: 96 | virtual def Foo(): 97 | pass 98 | 99 | class Sub(Super): 100 | override def Foo(): 101 | pass 102 | 103 | def Foo(value as int): 104 | pass 105 | 106 | Sub().$CursorLocation 107 | """ 108 | proposals = ProposalsFor(code) 109 | expected = ("Foo",) + SystemObjectMemberNames() 110 | AssertProposalNames(expected, proposals) 111 | 112 | [Test] 113 | def ProposalsDontIncludeSpeciallyNamedMethods(): 114 | index = ProjectIndex() 115 | index.AddReference(typeof(TypeWithSpecialMembers).Assembly) 116 | proposals = index.ProposalsFor("code.boo", "$(typeof(TypeWithSpecialMembers).BooTypeName())().$CursorLocation") 117 | expected = ("Name", "NameChanged") + SystemObjectMemberNames() 118 | AssertProposalNames(expected, proposals) 119 | 120 | class TypeWithSpecialMembers: 121 | Name: 122 | get: return "" 123 | event NameChanged as System.EventHandler 124 | 125 | [Test] 126 | def ProposalsForTypeInReferencedAssembly(): 127 | 128 | subject = ProjectIndex() 129 | subject.AddReference(typeof(Foo).Assembly) 130 | 131 | proposals = subject.ProposalsFor("code.boo", "$(typeof(Foo).BooTypeName())().$CursorLocation") 132 | 133 | expected = ("Bar",) + SystemObjectMemberNames() 134 | AssertProposalNames(expected, proposals) 135 | 136 | class Foo: 137 | def Bar(): 138 | pass 139 | 140 | [Extension] def BooTypeName(this as System.Type): 141 | return this.FullName.Replace('+', '.') 142 | 143 | def ProposalsFor(code as string): 144 | index = ProjectIndex() 145 | return index.ProposalsFor("code.boo", ReIndent(code)) 146 | 147 | def AssertProposalNames(expected as (string), actual as (CompletionProposal)): 148 | actualNames = array(p.Entity.Name for p in actual) 149 | System.Array.Sort(expected) 150 | System.Array.Sort(actualNames) 151 | Assert.AreEqual(expected, actualNames) 152 | 153 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Tests/Boo.MonoDevelop.Tests.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {DA18FECD-4F5B-4A02-B36B-876838F6B7A3} 9 | Library 10 | Boo.MonoDevelop.Tests 11 | false 12 | Boo.MonoDevelop.Tests 13 | v4.0 14 | 15 | 16 | true 17 | full 18 | bin\Debug 19 | prompt 20 | false 21 | 22 | false 23 | false 24 | 25 | 26 | none 27 | bin\Debug 28 | prompt 29 | false 30 | 31 | false 32 | false 33 | 34 | 35 | 36 | 37 | False 38 | ..\..\..\monodevelop\main\build\bin\Mono.Debugging.dll 39 | 40 | 41 | False 42 | ..\..\..\monodevelop\main\build\bin\MonoDevelop.Core.dll 43 | 44 | 45 | False 46 | ..\..\..\monodevelop\main\build\bin\MonoDevelop.Ide.dll 47 | 48 | 49 | False 50 | ..\..\..\monodevelop\main\build\bin\Mono.TextEditor.dll 51 | 52 | 53 | False 54 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.SourceEditor2.dll 55 | 56 | 57 | 58 | 59 | 60 | False 61 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll 62 | 63 | 64 | 65 | 66 | {A154F6EB-6808-4816-B9C1-C5412663E0F1} 67 | Boo.MonoDevelop 68 | 69 | 70 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F} 71 | Boo.Adt 72 | 73 | 74 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1} 75 | Boo.MonoDevelop.Util 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/Boo.MonoDevelop.Util.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1} 9 | Library 10 | Boo.MonoDevelop.Util 11 | False 12 | Boo.MonoDevelop.Util 13 | v4.0 14 | 15 | 16 | True 17 | full 18 | bin\Debug 19 | prompt 20 | False 21 | 22 | False 23 | False 24 | False 25 | 26 | 27 | none 28 | bin\Release 29 | prompt 30 | False 31 | 32 | False 33 | False 34 | False 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | ..\..\..\boo\build\Boo.Lang.Parser.dll 43 | 44 | 45 | ..\..\..\boo\build\Boo.Lang.Compiler.dll 46 | 47 | 48 | ..\..\..\monodevelop\main\build\bin\MonoDevelop.Core.dll 49 | 50 | 51 | ..\..\..\monodevelop\main\build\bin\MonoDevelop.Ide.dll 52 | 53 | 54 | ..\..\..\monodevelop\main\build\bin\Mono.TextEditor.dll 55 | 56 | 57 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.Refactoring\MonoDevelop.Refactoring.dll 58 | 59 | 60 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.SourceEditor2.dll 61 | 62 | 63 | ..\..\..\monodevelop\main\build\bin\ICSharpCode.NRefactory.dll 64 | 65 | 66 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll 67 | 68 | 69 | ..\..\..\monodevelop\main\build\bin\ICSharpCode.NRefactory.CSharp.dll 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 85 | Boo.Ide 86 | 87 | 88 | {53D5E189-64E0-49A6-A8F3-505599E84639} 89 | UnityScript.Ide 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/Boo.Ide.Tests/TargetLookupTest.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide.Tests 2 | 3 | import System 4 | 5 | import NUnit.Framework 6 | 7 | import Boo.Ide 8 | 9 | [TestFixture] 10 | class TargetLookupTest: 11 | 12 | [Test] 13 | def LookupLocalMethod (): 14 | index = ProjectIndex() 15 | file = "/foo.boo" 16 | expectedLine = 9 17 | expectedColumn = 9 18 | code = ReIndent(""" 19 | class Foo: 20 | def blah(): 21 | System.Console.WriteLine("foo") 22 | System.Console.WriteLine("bar") 23 | System.Console.WriteLine("baz") 24 | bleh() 25 | 26 | def bleh(): 27 | System.Console.WriteLine("bleh") 28 | """) 29 | location = index.TargetOf (file, code, 7, 10) 30 | 31 | Assert.IsNotNull (location, "Method lookup failed") 32 | Assert.AreEqual (file, location.File, "Filename mismatch") 33 | Assert.AreEqual (expectedLine, location.Line, "Line mismatch") 34 | Assert.AreEqual (expectedColumn, location.Column, "Column mismatch") 35 | 36 | [Test] 37 | def LookupLocalType (): 38 | index = ProjectIndex() 39 | file = "/foo.boo" 40 | expectedTypeName = "Bar" 41 | code = ReIndent(""" 42 | class Foo: 43 | def blah(): 44 | bar = null as Bar 45 | 46 | class Bar: 47 | static def bleh(): 48 | System.Console.WriteLine("bleh") 49 | """) 50 | 51 | location = index.TargetOf (file, code, 4, 24) 52 | 53 | Assert.IsNotNull (location, "Type lookup failed") 54 | Assert.AreEqual (expectedTypeName, location.TypeName, "Type mismatch") 55 | 56 | [Test] 57 | def LookupLocalProperty (): 58 | index = ProjectIndex() 59 | file = "/foo.boo" 60 | expectedLine = 9 61 | expectedColumn = 5 62 | code = ReIndent(""" 63 | class Foo: 64 | def blah(): 65 | System.Console.WriteLine("foo") 66 | System.Console.WriteLine("bar") 67 | System.Console.WriteLine("baz") 68 | System.Console.WriteLine(self.bleh) 69 | 70 | bleh as int: 71 | get: return 0 72 | """) 73 | location = index.TargetOf (file, code, 7, 40) 74 | 75 | Assert.IsNotNull (location, "Property lookup failed") 76 | Assert.AreEqual (file, location.File, "Filename mismatch") 77 | Assert.AreEqual (expectedLine, location.Line, "Line mismatch") 78 | Assert.AreEqual (expectedColumn, location.Column, "Column mismatch") 79 | 80 | [Test] 81 | def LookupExternalType (): 82 | index = ProjectIndex() 83 | file = "/foo.boo" 84 | expectedTypeName = "System.Reflection.Assembly" 85 | code = ReIndent(""" 86 | import System.Reflection 87 | 88 | class Foo: 89 | def blah(): 90 | bar = null as Assembly 91 | 92 | class Bar: 93 | static def bleh(): 94 | System.Console.WriteLine("bleh") 95 | """) 96 | 97 | location = index.TargetOf (file, code, 6, 20) 98 | 99 | Assert.IsNotNull (location, "Type lookup failed") 100 | Assert.AreEqual (expectedTypeName, location.TypeName, "Type mismatch") 101 | 102 | [Test] 103 | def LookupExternalMethod (): 104 | index = ProjectIndex() 105 | file = "/foo.boo" 106 | expectedName = "Add" 107 | expectedTypeFullName = "Boo.Lang.List" 108 | code = ReIndent(""" 109 | class Foo: 110 | def blah(): 111 | list = List[of string]() 112 | list.Add("foo") 113 | list.Add("bar") 114 | list.Add("baz") 115 | 116 | class Bar: 117 | static def bleh(): 118 | System.Console.WriteLine("bleh") 119 | """) 120 | 121 | location = index.TargetOf (file, code, 6, 20) 122 | 123 | Assert.IsNotNull (location, "Method lookup failed") 124 | Assert.IsNotNull (location.MemberInfo, "External method lookup didn't return external reference") 125 | Assert.AreEqual (expectedName, location.MemberInfo.Name, "Method name mismatch") 126 | Assert.IsTrue (location.MemberInfo.DeclaringType.FullName.StartsWith (expectedTypeFullName), "Method declaring type mismatch") 127 | 128 | [Test] 129 | def LookupExternalProperty (): 130 | index = ProjectIndex() 131 | file = "/foo.boo" 132 | expectedName = "Count" 133 | expectedTypeFullName = "Boo.Lang.List" 134 | code = ReIndent(""" 135 | class Foo: 136 | def blah(): 137 | list = List[of string]() 138 | list.Add("foo") 139 | print(list.Count) 140 | list.Add("bar") 141 | 142 | class Bar: 143 | static def bleh(): 144 | System.Console.WriteLine("bleh") 145 | """) 146 | 147 | location = index.TargetOf (file, code, 6, 20) 148 | 149 | Assert.IsNotNull (location, "Property lookup failed") 150 | Assert.IsNotNull (location.MemberInfo, "External property lookup didn't return external reference") 151 | Assert.AreEqual (expectedName, location.MemberInfo.Name, "Property name mismatch") 152 | Assert.IsTrue (location.MemberInfo.DeclaringType.FullName.StartsWith (expectedTypeFullName), "Property declaring type mismatch") 153 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop.Util/DataProvider.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Util.Completion 2 | 3 | import System 4 | import System.Linq 5 | import System.Text 6 | import System.Collections.Generic 7 | 8 | import MonoDevelop.Ide 9 | import MonoDevelop.Ide.Gui 10 | import MonoDevelop.Ide.TypeSystem 11 | import MonoDevelop.Ide.Gui.Content 12 | import MonoDevelop.Components 13 | 14 | import ICSharpCode.NRefactory 15 | import ICSharpCode.NRefactory.CSharp 16 | import ICSharpCode.NRefactory.TypeSystem 17 | 18 | 19 | class DataProvider(DropDownBoxListWindow.IListDataProvider): 20 | public IconCount as int: 21 | get: 22 | return _memberList.Count 23 | 24 | private _tag as object 25 | private _ambience as Ambience 26 | private _memberList as List of AstNode 27 | private _document as Document 28 | 29 | def constructor(document as Document, tag as object, ambience as Ambience): 30 | _memberList = List of AstNode() 31 | _document = document 32 | _tag = tag 33 | _ambience = ambience 34 | Reset() 35 | 36 | def Reset(): 37 | _memberList.Clear() 38 | if(_tag isa SyntaxTree): 39 | foundTypes = (_tag as SyntaxTree).GetTypes (false) as IEnumerable of EntityDeclaration 40 | types = Stack of EntityDeclaration((_tag as SyntaxTree).GetTypes (false)) 41 | while(types.Count > 0): 42 | type = types.Pop() 43 | _memberList.Add(type) 44 | for innerType in type.Children.Where({child | child isa TypeDeclaration}): 45 | types.Push(innerType) 46 | elif(_tag isa TypeDeclaration): 47 | _memberList.AddRange((_tag as TypeDeclaration).GetChildrenByRole (SyntaxTree.MemberRole)) 48 | else: 49 | MonoDevelop.Core.LoggingService.LogError ("No fallback for {0}", _tag.GetType ().FullName) 50 | _memberList.Sort({x,y|string.Compare(GetString(_ambience,x), GetString(_ambience,y), StringComparison.OrdinalIgnoreCase)}) 51 | 52 | def GetString(ambience as Ambience, member as AstNode): 53 | return GetName (member) 54 | 55 | static def GetName (node as AstNode): 56 | if node isa TypeDeclaration: 57 | sb = StringBuilder ((node as TypeDeclaration).Name) 58 | while node.Parent isa TypeDeclaration: 59 | node = node.Parent 60 | sb.Insert (0, (node as TypeDeclaration).Name + ".") 61 | return sb.ToString () 62 | if node isa FieldDeclaration: 63 | return (node as FieldDeclaration).Variables.First ().Name 64 | if node isa EventDeclaration: 65 | return (node as EventDeclaration).Variables.First ().Name 66 | if (node isa EntityDeclaration): 67 | return (node as EntityDeclaration).Name 68 | if (node isa VariableInitializer): 69 | return (node as VariableInitializer).Name 70 | MonoDevelop.Core.LoggingService.LogError ("Can't get name for {0}", node.GetType ().FullName) 71 | return string.Empty 72 | 73 | def GetText(index as int) as string: 74 | return GetName (_memberList[index]) 75 | 76 | def GetMarkup(index as int) as string: 77 | return GetText (index) 78 | 79 | static def GetIconStringForNode (node as AstNode): 80 | icon = MonoDevelop.Ide.Gui.Stock.Literal 81 | if (node isa TypeDeclaration): 82 | icon = MonoDevelop.Ide.Gui.Stock.Class 83 | elif (node isa NamespaceDeclaration): 84 | icon = MonoDevelop.Ide.Gui.Stock.NameSpace 85 | elif (node isa FieldDeclaration): 86 | icon = MonoDevelop.Ide.Gui.Stock.Field 87 | elif (node isa PropertyDeclaration): 88 | icon = MonoDevelop.Ide.Gui.Stock.Property 89 | elif (node isa MethodDeclaration): 90 | icon = MonoDevelop.Ide.Gui.Stock.Method 91 | elif (node isa EventDeclaration): 92 | icon = MonoDevelop.Ide.Gui.Stock.Event 93 | elif (node isa DelegateDeclaration): 94 | icon = MonoDevelop.Ide.Gui.Stock.Delegate 95 | 96 | return icon 97 | 98 | static def GetIconForNode (node as AstNode): 99 | return ImageService.GetPixbuf(GetIconStringForNode (node), Gtk.IconSize.Menu) 100 | 101 | def GetIcon(index as int) as Gdk.Pixbuf: 102 | return GetIconForNode (_memberList[index]) 103 | 104 | def GetTag(index as int) as object: 105 | return _memberList[index] 106 | 107 | def ActivateItem(index as int): 108 | annotation = _memberList[index].Annotation (TextLocation) 109 | if null == annotation: 110 | location = (_memberList[index].Annotation (DomRegion) cast DomRegion).Begin 111 | else: 112 | location = annotation cast TextLocation 113 | extEditor = _document.GetContent of IExtensibleTextEditor() 114 | if(extEditor != null): 115 | position = extEditor.GetPositionFromLineColumn (location.Line, location.Column) 116 | if (position >= 0 and position < extEditor.Length): 117 | extEditor.SetCaretTo(Math.Max(1, location.Line), location.Column) 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/Boo.Ide/ProjectIndex.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import Boo.Lang.Environments 4 | import Boo.Lang.Compiler 5 | import Boo.Lang.Compiler.Ast 6 | import Boo.Lang.Compiler.TypeSystem 7 | 8 | import Boo.Adt 9 | 10 | let SendErrorsToTheConsole = true 11 | 12 | class ProjectIndex: 13 | 14 | _compiler as BooCompiler 15 | _parser as BooCompiler 16 | _implicitNamespaces as List 17 | 18 | def constructor(): 19 | _compiler = BooCompiler() 20 | _compiler.Parameters.Pipeline = Pipelines.ResolveExpressions(BreakOnErrors: false) 21 | 22 | _parser = BooCompiler() 23 | _parser.Parameters.Pipeline = Pipelines.Parse() { Steps.IntroduceModuleClasses() } 24 | _implicitNamespaces = ["Boo.Lang", "Boo.Lang.Builtins"] 25 | 26 | def constructor(compiler as BooCompiler, parser as BooCompiler, implicitNamespaces as List): 27 | _compiler = compiler 28 | _parser = parser 29 | _implicitNamespaces = implicitNamespaces 30 | 31 | [lock] 32 | virtual def Parse(fileName as string, code as string): 33 | return ParseModule(fileName, code) 34 | 35 | [lock] 36 | virtual def ProposalsFor(fileName as string, code as string): 37 | result = {} 38 | 39 | WithModule(fileName, code) do (module): 40 | expression = CursorLocationFinder().FindIn(module) 41 | if not expression is null: 42 | for proposal in CompletionProposer.ForExpression(expression): 43 | result[proposal.Name] = proposal 44 | 45 | return array(CompletionProposal, result.Values) 46 | 47 | [lock] 48 | virtual def MethodsFor(fileName as string, code as string, methodName as string, methodLine as int): 49 | methods = List of MethodDescriptor() 50 | 51 | WithModule(fileName, code) do (module): 52 | expression = MethodInvocationFinder(methodName, fileName, methodLine).FindIn(module) 53 | if expression is null: 54 | print "No method found for ${methodName}: (${fileName}:${methodLine})" 55 | return 56 | if expression.Target.Entity isa Ambiguous: 57 | # Multiple overloads 58 | for i in (expression.Target.Entity as Ambiguous).Entities: 59 | methods.Add (MethodDescriptor(i)) 60 | elif expression.Target.Entity isa IMethod: 61 | # May have failed resolution - try one more time 62 | entity = Services.NameResolutionService().ResolveMethod((expression.Target.Entity as IMethod).DeclaringType, methodName) 63 | if entity isa Ambiguous: 64 | # Multiple overloads 65 | for i in (expression.Target.Entity as Ambiguous).Entities: 66 | methods.Add (MethodDescriptor(i)) 67 | else: 68 | # No overloads 69 | methods.Add(MethodDescriptor(entity)) 70 | return methods 71 | 72 | [lock] 73 | virtual def LocalsAt(fileName as string, code as string, line as int): 74 | locals = List of string() 75 | WithModule(fileName, code) do (module): 76 | locals.Extend(LocalAccumulator(fileName, line).FindIn(module)) 77 | return locals 78 | 79 | [lock] 80 | virtual def ImportsFor(fileName as string, code as string): 81 | module = ParseModule(fileName, code) 82 | imports = List of string(i.Namespace for i in module.Imports) 83 | imports.Extend(_implicitNamespaces) 84 | return imports 85 | 86 | [lock] 87 | virtual def AddReference(assembly as System.Reflection.Assembly): 88 | _compiler.Parameters.References.Add(assembly) 89 | 90 | [lock] 91 | virtual def AddReference(reference as string): 92 | asm = _compiler.Parameters.LoadAssembly(reference, true) 93 | _compiler.Parameters.References.Add(asm) 94 | 95 | [lock] 96 | virtual def TargetOf (fileName as string, code as string, line as int, column as int) as TokenLocation: 97 | result = null as TokenLocation 98 | 99 | WithModule(fileName, code) do (module): 100 | result = TargetLookup (fileName, line, column).FindIn (module) 101 | return result 102 | 103 | private def WithModule(fname as string, contents as string, action as System.Action[of Module]): 104 | input = _compiler.Parameters.Input 105 | input.Add(IO.StringInput(fname, contents)) 106 | try: 107 | context = _compiler.Run() 108 | ActiveEnvironment.With(context.Environment) do: 109 | action(GetModuleForFileFromContext(context, fname)) 110 | ensure: 111 | input.Clear() 112 | 113 | private def GetModuleForFileFromContext(context as CompilerContext, fileName as string): 114 | for m in context.CompileUnit.Modules: 115 | if m.LexicalInfo.FileName == fileName: 116 | return m 117 | return null 118 | 119 | private def ParseModule(fileName as string, contents as string): 120 | try: 121 | _parser.Parameters.Input.Add(IO.StringInput(fileName, contents)) 122 | result = _parser.Run() 123 | DumpErrors result.Errors 124 | return result.CompileUnit.Modules[-1] 125 | except x: 126 | print x 127 | return Module(LexicalInfo(fileName, 1, 1)) 128 | ensure: 129 | _parser.Parameters.Input.Clear() 130 | 131 | def DumpErrors(errors as CompilerErrorCollection): 132 | if SendErrorsToTheConsole: 133 | for error in errors: 134 | System.Console.Error.WriteLine(error.ToString(true)) 135 | 136 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38} 9 | Library 10 | UnityScript.MonoDevelop 11 | false 12 | UnityScript.MonoDevelop 13 | v4.0 14 | 15 | 16 | true 17 | full 18 | bin\Debug 19 | prompt 20 | false 21 | 22 | false 23 | false 24 | 25 | 26 | none 27 | bin\Release 28 | prompt 29 | false 30 | 31 | false 32 | false 33 | 34 | 35 | 36 | 37 | monodevelop 38 | False 39 | 40 | 41 | monodevelop 42 | False 43 | 44 | 45 | monodevelop-core-addins 46 | 47 | 48 | monodevelop-core-addins 49 | 50 | 51 | monodevelop-core-addins 52 | 53 | 54 | monodevelop 55 | 56 | 57 | 58 | monodevelop 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1} 81 | Boo.MonoDevelop.Util 82 | 83 | 84 | {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB} 85 | UnityScript 86 | 87 | 88 | {2784E7F4-5206-4BF9-99CD-96B1D94D0E19} 89 | UnityScript.Lang 90 | 91 | 92 | {53D5E189-64E0-49A6-A8F3-505599E84639} 93 | UnityScript.Ide 94 | 95 | 96 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 97 | Boo.Ide 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Boo.MonoDevelop.addin.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 107 | 108 | 109 | 110 | 111 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/UnityScriptCompiler.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Core 4 | import MonoDevelop.Projects 5 | 6 | import System.IO 7 | import System.Linq.Enumerable 8 | 9 | import Boo.Lang.PatternMatching 10 | 11 | class UnityScriptCompiler: 12 | 13 | _config as DotNetProjectConfiguration 14 | _selector as ConfigurationSelector 15 | _projectItems as ProjectItemCollection 16 | _compilationParameters as UnityScriptCompilationParameters 17 | _projectParameters as UnityScriptProjectParameters 18 | _monitor as IProgressMonitor 19 | 20 | def constructor( 21 | config as DotNetProjectConfiguration, 22 | selector as ConfigurationSelector, 23 | projectItems as ProjectItemCollection, 24 | progressMonitor as IProgressMonitor): 25 | 26 | _config = config 27 | _selector = selector 28 | _projectItems = projectItems 29 | _compilationParameters = config.CompilationParameters or UnityScriptCompilationParameters() 30 | _projectParameters = config.ProjectParameters or UnityScriptProjectParameters() 31 | _monitor = progressMonitor 32 | 33 | def Run() as BuildResult: 34 | responseFileName = Path.GetTempFileName() 35 | try: 36 | WriteOptionsToResponseFile(responseFileName) 37 | compiler = MapPath("bin/us.exe") 38 | compilerOutput = ExecuteProcess(compiler, "\"@${responseFileName}\"") 39 | return ParseBuildResult(compilerOutput) 40 | ensure: 41 | FileService.DeleteFile(responseFileName) 42 | 43 | private def WriteOptionsToResponseFile(responseFileName as string): 44 | commandLine = StringWriter() 45 | 46 | referencedFiles = GetReferencedFileNames() 47 | if ContainsReference(referencedFiles, "UnityEngine.dll"): 48 | commandLine.WriteLine("-base:UnityEngine.MonoBehaviour") 49 | commandLine.WriteLine("-method:Main") 50 | commandLine.WriteLine("-i:System.Collections") 51 | commandLine.WriteLine("-i:UnityEngine") 52 | commandLine.WriteLine("-i:UnityEditor") if ContainsReference(referencedFiles, "UnityEditor.dll") 53 | commandLine.WriteLine("-t:library") 54 | commandLine.WriteLine("-x-type-inference-rule-attribute:UnityEngineInternal.TypeInferenceRuleAttribute") 55 | 56 | else: 57 | commandLine.WriteLine("-base:System.Object") 58 | commandLine.WriteLine("-method:Awake") 59 | commandLine.WriteLine("-t:exe") 60 | 61 | commandLine.WriteLine("-debug+") 62 | commandLine.WriteLine("-out:${_config.CompiledOutputName}") 63 | 64 | for define in _compilationParameters.DefineSymbols: 65 | commandLine.WriteLine ("-define:${define}") 66 | 67 | for r in referencedFiles: 68 | commandLine.WriteLine("-reference:'$r'") 69 | 70 | projectFiles = item as ProjectFile for item in _projectItems if item isa ProjectFile 71 | for file in projectFiles: 72 | continue if file.Subtype == Subtype.Directory 73 | 74 | match file.BuildAction: 75 | case "Compile": 76 | commandLine.WriteLine("\"${file.Name}\"") 77 | otherwise: 78 | print "Unrecognized build action:", file.BuildAction 79 | 80 | commandLineString = commandLine.ToString() 81 | if (_monitor): 82 | _monitor.Log.WriteLine (commandLineString) 83 | print commandLineString 84 | File.WriteAllText(responseFileName, commandLineString) 85 | 86 | private def GetReferencedFileNames(): 87 | return _projectItems.OfType[of ProjectReference]().SelectMany({ r | r.GetReferencedFileNames(_selector) }).ToArray() 88 | 89 | private def ContainsReference(files as (string), fileName as string): 90 | return System.Array.Exists(files, { f | Path.GetFileName(f) == fileName }) 91 | 92 | private def MapPath(path as string): 93 | return Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), path) 94 | 95 | private def ExecuteProcess(executable as string, commandLine as string): 96 | startInfo = System.Diagnostics.ProcessStartInfo(executable, commandLine, 97 | UseShellExecute: false, 98 | RedirectStandardOutput: true, 99 | RedirectStandardError: true, 100 | CreateNoWindow: true) 101 | 102 | using process = Runtime.SystemAssemblyService.CurrentRuntime.ExecuteAssembly(startInfo, _config.TargetFramework): 103 | return process.StandardOutput.ReadToEnd() + System.Environment.NewLine + process.StandardError.ReadToEnd() 104 | 105 | private static def IsWarningCode (code as string): 106 | return (not string.IsNullOrEmpty (code)) and code.StartsWith ("BCW") 107 | 108 | private def ParseBuildResult(stdout as string): 109 | 110 | result = BuildResult() 111 | 112 | for line in StringReader(stdout): 113 | match line: 114 | case /(?.+)\((?\d+),(?\d+)\):\s+(?.+?):\s+(?.+)/: 115 | result.Append(BuildError( 116 | FileName: fileName[0].Value, 117 | Line: int.Parse(lineNumber[0].Value), 118 | Column: int.Parse(column[0].Value), 119 | IsWarning: IsWarningCode (code[0].Value), 120 | ErrorNumber: code[0].Value, 121 | ErrorText: message[0].Value)) 122 | 123 | case /(?.+):\s+(?.+)/: 124 | result.Append( 125 | BuildError( 126 | ErrorNumber: code[0].Value, 127 | ErrorText: message[0].Value, 128 | IsWarning: IsWarningCode (code[0].Value))) 129 | 130 | otherwise: 131 | unrecognized = len(line) > 0 \ 132 | and not line.StartsWith("Successfully compiled '") 133 | 134 | if unrecognized: print "Unrecognized compiler output:", line 135 | 136 | return result 137 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/UnityScript.MonoDevelop.addin.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 104 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Completion/BooEditorCompletion.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.Completion 2 | 3 | import System 4 | import Boo.Lang.PatternMatching 5 | 6 | import MonoDevelop.Ide.Gui 7 | import MonoDevelop.Ide.CodeCompletion 8 | 9 | import Boo.Ide 10 | import Boo.MonoDevelop.Util.Completion 11 | 12 | class BooEditorCompletion(BooCompletionTextEditorExtension): 13 | 14 | # Match "blah as [...]" pattern 15 | static AS_PATTERN = /\bas\s+(?[\w\d]+(\.[\w\d]+)*)?\.?/ 16 | 17 | # Match "Blah[of ...]" pattern 18 | static OF_PATTERN = /\bof\s+(?[\w\d]+(\.[\w\d]+)*)?\.?/ 19 | 20 | # Patterns that result in us doing a type completion 21 | static TYPE_PATTERNS = (OF_PATTERN, AS_PATTERN) 22 | 23 | # Patterns that result in us doing a namespace completion 24 | static NAMESPACE_PATTERNS = (IMPORTS_PATTERN,) 25 | 26 | # Delimiters that indicate a literal 27 | static LITERAL_DELIMITERS = ['"', '/'] 28 | 29 | # Scraped from boo.g 30 | private static KEYWORDS = ( 31 | "abstract", 32 | "and", 33 | "as", 34 | "break", 35 | "continue", 36 | "callable", 37 | "cast", 38 | "char", 39 | "class", 40 | "constructor", 41 | "def", 42 | "destructor", 43 | "do", 44 | "elif", 45 | "else", 46 | "ensure", 47 | "enum", 48 | "event", 49 | "except", 50 | "failure", 51 | "final", 52 | "from", 53 | "for", 54 | "false", 55 | "get", 56 | "goto", 57 | "import", 58 | "interface", 59 | "internal", 60 | "is", 61 | "isa", 62 | "if", 63 | "in", 64 | "namespace", 65 | "new", 66 | "not", 67 | "null", 68 | "of", 69 | "or", 70 | "override", 71 | "pass", 72 | "partial", 73 | "public", 74 | "protected", 75 | "private", 76 | "raise", 77 | "ref", 78 | "return", 79 | "set", 80 | "self", 81 | "super", 82 | "static", 83 | "struct", 84 | "then", 85 | "try", 86 | "transient", 87 | "true", 88 | "typeof", 89 | "unless", 90 | "virtual", 91 | "while", 92 | "yield", 93 | 94 | // BUILTINS 95 | "len", 96 | "print" 97 | ) 98 | 99 | # Scraped from Types.cs 100 | private static PRIMITIVES = ( 101 | "byte", 102 | "sbyte", 103 | "short", 104 | "ushort", 105 | "int", 106 | "uint", 107 | "long", 108 | "ulong", 109 | "single", 110 | "double", 111 | "decimal", 112 | "void", 113 | "string", 114 | "object" 115 | ) 116 | 117 | override Keywords: 118 | get: return KEYWORDS 119 | 120 | override Primitives: 121 | get: return PRIMITIVES 122 | 123 | # override def HandleCodeCompletion(context as CodeCompletionContext, completionChar as char): 124 | # triggerWordLength = 0 125 | # return HandleCodeCompletion(context, completionChar, triggerWordLength) 126 | 127 | override def HandleCodeCompletion(context as CodeCompletionContext, completionChar as char, ref triggerWordLength as int): 128 | # print "HandleCodeCompletion(${context.ToString()}, ${completionChar.ToString()})" 129 | triggerWordLength = 0 130 | line = GetLineText(context.TriggerLine) 131 | tokenLineOffset = context.TriggerLineOffset-1 132 | 133 | if(IsInsideComment(line, tokenLineOffset) or \ 134 | IsInsideLiteral(line, tokenLineOffset)): 135 | return null 136 | 137 | match completionChar.ToString(): 138 | case " ": 139 | if (null != (completions = CompleteNamespacePatterns(context))): 140 | return completions 141 | return CompleteTypePatterns(context) 142 | case ".": 143 | if (null != (completions = CompleteNamespacePatterns(context))): 144 | return completions 145 | if (null != (completions = CompleteTypePatterns(context))): 146 | return completions 147 | return CompleteMembers(context) 148 | otherwise: 149 | if(CanStartIdentifier(completionChar)): 150 | if(StartsIdentifier(line, tokenLineOffset)): 151 | completions = CompleteVisible(context) 152 | # Necessary for completion window to take first identifier character into account 153 | --context.TriggerOffset 154 | triggerWordLength = 1 155 | else: 156 | dotLineOffset = tokenLineOffset-1 157 | if(0 <= dotLineOffset and line.Length > dotLineOffset and "."[0] == line[dotLineOffset]): 158 | --context.TriggerOffset 159 | triggerWordLength = 1 160 | return CompleteMembers(context) 161 | 162 | return completions 163 | return null 164 | 165 | def CompleteNamespacePatterns(context as CodeCompletionContext): 166 | for pattern in NAMESPACE_PATTERNS: 167 | completions = CompleteNamespacesForPattern(context, pattern, "namespace") 168 | return completions if completions is not null 169 | 170 | return null 171 | 172 | def CompleteTypePatterns(context as CodeCompletionContext): 173 | for pattern in TYPE_PATTERNS: 174 | completions = CompleteNamespacesForPattern(context, pattern, "namespace") 175 | if completions is not null: 176 | completions.AddRange(CompletionData(p, Stock.Literal) for p in Primitives) 177 | return completions 178 | return null 179 | 180 | override def ShouldEnableCompletionFor(fileName as string): 181 | return Boo.MonoDevelop.ProjectModel.BooLanguageBinding.IsBooFile(fileName) 182 | 183 | def IsInsideLiteral(line as string, offset as int): 184 | fragment = line[0:offset+1] 185 | for delimiter in LITERAL_DELIMITERS: 186 | list = List[of string]() 187 | list.Add(delimiter) 188 | if 0 == fragment.Split(list.ToArray(), StringSplitOptions.None).Length % 2: 189 | return true 190 | return false 191 | 192 | override SelfReference: 193 | get: return "self" 194 | 195 | override EndStatement: 196 | get: return string.Empty 197 | 198 | override def GetParameterDataProviderFor(methods as List of MethodDescriptor): 199 | return BooParameterDataProvider(Document, methods) 200 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/BooCompiler.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | import MonoDevelop.Core 4 | import MonoDevelop.Projects 5 | 6 | import System.IO 7 | 8 | import Boo.Lang.PatternMatching 9 | 10 | class BooCompiler: 11 | 12 | _config as DotNetProjectConfiguration 13 | _selector as ConfigurationSelector 14 | _projectItems as ProjectItemCollection 15 | _compilationParameters as BooCompilationParameters 16 | _projectParameters as BooProjectParameters 17 | _monitor as IProgressMonitor 18 | 19 | def constructor( 20 | config as DotNetProjectConfiguration, 21 | selector as ConfigurationSelector, 22 | projectItems as ProjectItemCollection, 23 | progressMonitor as IProgressMonitor): 24 | 25 | _config = config 26 | _selector = selector 27 | _projectItems = projectItems 28 | _compilationParameters = config.CompilationParameters or BooCompilationParameters() 29 | _projectParameters = config.ProjectParameters or BooProjectParameters() 30 | _monitor = progressMonitor 31 | 32 | def Run() as BuildResult: 33 | responseFileName = Path.GetTempFileName() 34 | try: 35 | WriteOptionsToResponseFile(responseFileName) 36 | compilerOutput = ExecuteProcess(BoocPath(), "\"@${responseFileName}\"") 37 | buildResult = ParseBuildResult(compilerOutput) 38 | unless buildResult.Failed: 39 | CopyRequiredReferences() 40 | return buildResult 41 | ensure: 42 | FileService.DeleteFile(responseFileName) 43 | 44 | private def CopyRequiredReferences(): 45 | outputDir = Path.GetDirectoryName(_config.CompiledOutputName) 46 | for reference in ProjectReferences(): 47 | #continue unless IsBooPackageReference(reference) 48 | for file in reference.GetReferencedFileNames(_selector): 49 | CopyReferencedFileTo(file, outputDir) 50 | 51 | def IsBooPackageReference(reference as ProjectReference): 52 | return reference.ReferenceType == ReferenceType.Gac and reference.Package.Name == "boo" 53 | 54 | def CopyReferencedFileTo(file as string, outputDir as string): 55 | if CopyNewerFileToDirectory(file, outputDir): 56 | print("Copied '${file}' to '${outputDir}'.") 57 | 58 | private def BoocPath(): 59 | return BooAssemblyPath("booc.exe") 60 | 61 | private def BooAssemblyPath(fileName as string): 62 | return PathCombine(AssemblyPath(), "boo", fileName) 63 | 64 | private def AssemblyPath(): 65 | return Path.GetDirectoryName(GetType().Assembly.ManifestModule.FullyQualifiedName) 66 | 67 | private def WriteOptionsToResponseFile(responseFileName as string): 68 | options = StringWriter() 69 | 70 | options.WriteLine("-t:${OutputType()}") 71 | options.WriteLine("-out:${_config.CompiledOutputName}") 72 | 73 | options.WriteLine("-debug" + ("+" if _config.DebugMode else "-")) 74 | 75 | if _compilationParameters.Ducky: options.WriteLine("-ducky") 76 | if _compilationParameters.NoStdLib: options.WriteLine("-nostdlib") 77 | for define in _compilationParameters.DefineSymbols: 78 | options.WriteLine ("-define:${define}") 79 | 80 | projectFiles = item as ProjectFile for item in _projectItems if item isa ProjectFile 81 | for file in projectFiles: 82 | continue if file.Subtype == Subtype.Directory 83 | 84 | match file.BuildAction: 85 | case BuildAction.Compile: 86 | options.WriteLine("\"${file.Name}\"") 87 | case BuildAction.EmbeddedResource: 88 | options.WriteLine("-embedres:${file.FilePath},${file.ResourceId}") 89 | otherwise: 90 | print "Unrecognized build action for file", file, "-", file.BuildAction 91 | 92 | for reference in ProjectReferences(): 93 | for fileName in reference.GetReferencedFileNames(_selector): 94 | options.WriteLine("-reference:${fileName}") 95 | 96 | optionsString = options.ToString() 97 | if (_monitor): 98 | _monitor.Log.WriteLine (optionsString) 99 | print optionsString 100 | File.WriteAllText(responseFileName, optionsString) 101 | 102 | private def ProjectReferences(): 103 | for item in _projectItems: 104 | reference = item as ProjectReference 105 | yield reference unless reference is null 106 | 107 | private def OutputType(): 108 | return _config.CompileTarget.ToString().ToLower() 109 | 110 | private def ExecuteProcess(executable as string, commandLine as string): 111 | startInfo = System.Diagnostics.ProcessStartInfo(executable, commandLine, 112 | UseShellExecute: false, 113 | RedirectStandardOutput: true, 114 | RedirectStandardError: true, 115 | CreateNoWindow: true) 116 | 117 | using process = Runtime.SystemAssemblyService.CurrentRuntime.ExecuteAssembly(startInfo, _config.TargetFramework): 118 | return process.StandardError.ReadToEnd() 119 | 120 | private static def IsWarningCode (code as string): 121 | return (not string.IsNullOrEmpty (code)) and code.StartsWith ("BCW") 122 | 123 | private def ParseBuildResult(stdout as string): 124 | 125 | result = BuildResult() 126 | for line in StringReader(stdout): 127 | match line: 128 | case @/^(?.+)\((?\d+),(?\d+)\):\s+(?.+?):\s+(?.+)$/: 129 | result.Append(BuildError( 130 | FileName: fileName[0].Value, 131 | Line: int.Parse(lineNumber[0].Value), 132 | Column: int.Parse(column[0].Value), 133 | IsWarning: IsWarningCode (code[0].Value), 134 | ErrorNumber: code[0].Value, 135 | ErrorText: message[0].Value)) 136 | 137 | case @/^(?.+):\s+(?.+)$/: 138 | result.Append( 139 | BuildError( 140 | ErrorNumber: code[0].Value, 141 | ErrorText: message[0].Value, 142 | IsWarning: IsWarningCode (code[0].Value))) 143 | 144 | otherwise: 145 | if len(line) > 0: print "Unrecognized compiler output:", line 146 | 147 | return result 148 | -------------------------------------------------------------------------------- /src/Boo.Ide/TargetLookup.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.Ide 2 | 3 | import System 4 | import System.Linq 5 | import System.Reflection 6 | import System.Collections.Generic 7 | import Boo.Lang.Compiler.Ast 8 | import Boo.Lang.PatternMatching 9 | import Boo.Lang.Compiler.TypeSystem 10 | 11 | class TokenLocation: 12 | public Name as string 13 | public Parent as string 14 | public File as string 15 | public Line as int 16 | public Column as int 17 | public MemberInfo as MemberInfo 18 | public TypeName as string 19 | 20 | def constructor (node as Node): 21 | initialized = false 22 | if node isa MethodInvocationExpression: 23 | initialized = Init (node as MethodInvocationExpression) 24 | elif node isa TypeReference: 25 | initialized = Init (node as TypeReference) 26 | elif node isa MemberReferenceExpression: 27 | initialized = Init (node as MemberReferenceExpression) 28 | 29 | if not initialized: 30 | raise ArgumentException (string.Format ("Unable to create TargetLocation from {0}", node.GetType ())) 31 | 32 | private def Init (reference as TypeReference) as bool: 33 | return false if reference is null 34 | 35 | if (reference.Entity isa IType): 36 | TypeName = reference.Entity.FullName 37 | # Console.WriteLine ("Initializing with reference {0}", reference.Entity.FullName) 38 | # Console.WriteLine ("Initializing with reference {0}", reference.Entity.GetType ()) 39 | return true 40 | 41 | private def Init (invocation as MethodInvocationExpression) as bool: 42 | return false if (invocation is null or invocation.Target is null or invocation.Target.Entity is null) 43 | ReadEntity (invocation.Target.Entity) 44 | return true 45 | 46 | private def Init (reference as MemberReferenceExpression): 47 | return false if (reference is null or reference.Entity is null) 48 | # Console.WriteLine (reference.Entity) 49 | ReadEntity (reference.Entity) 50 | return true 51 | 52 | private def ReadEntity(entity as IEntity): 53 | info = GetLexicalInfo (entity) 54 | if (info is null): 55 | # ExternalEntity, populate MemberInfo 56 | if not (entity isa IExternalEntity): 57 | raise ArgumentException ("Unable to lookup entity", "entity") 58 | MemberInfo = (entity as IExternalEntity).MemberInfo 59 | Name = MemberInfo.Name 60 | Parent = MemberInfo.DeclaringType.FullName 61 | else: 62 | # Normal member with lexical info 63 | Name = entity.Name 64 | Parent = FullNameToParent (entity.Name, entity.FullName) 65 | File = info.FullPath 66 | Line = info.Line 67 | Column = info.Column 68 | 69 | override def ToString () as string: 70 | return string.Format ("{0}:{1},{2} ({3} | {4})", File, Line, Column, MemberInfo, TypeName) 71 | 72 | 73 | class TargetLookup(DepthFirstVisitor): 74 | _filename as string 75 | _line as int 76 | _column as int 77 | _nodes as List[of Node] 78 | 79 | def constructor (filename as string, line as int, column as int): 80 | _filename = filename 81 | _line = line 82 | _column = column 83 | _nodes = List[of Node]() 84 | 85 | [lock] 86 | def FindIn(root as Node) as TokenLocation: 87 | Visit(root) 88 | 89 | match _nodes.Count: 90 | case 0: 91 | return null 92 | case 1: 93 | return TokenLocation (_nodes[0]) 94 | otherwise: 95 | _nodes.Sort ({ a as Node,z as Node | a.LexicalInfo.Column.CompareTo (z.LexicalInfo.Column) }) 96 | # for node in _nodes: 97 | # Console.WriteLine ("Checking {0}({1}) against {2}", node, node.LexicalInfo, _column) 98 | node = _nodes.LastOrDefault ({ n | n.LexicalInfo.Column <= _column }) 99 | 100 | return null if (node is null) 101 | # Console.WriteLine ("Using {0} ({1})", node.Entity, node.GetType()) 102 | return TokenLocation (node) 103 | 104 | 105 | override def LeaveMethodInvocationExpression (node as MethodInvocationExpression): 106 | # Console.WriteLine ("Checking {0}", node) 107 | return if not LocationMatches (node) 108 | _nodes.Add (node) 109 | 110 | override def OnSimpleTypeReference (node as SimpleTypeReference): 111 | return if not LocationMatches (node) 112 | _nodes.Add (node) 113 | # Console.WriteLine ("Adding type reference {0}", node.Name) 114 | 115 | override def LeaveMemberReferenceExpression (node as MemberReferenceExpression): 116 | return if not LocationMatches (node) 117 | _nodes.Add (node) 118 | # Console.WriteLine ("MemberReference: {0} ({1} {2})", node, node.GetType (), node.Entity.GetType ()) 119 | 120 | private def LocationMatches (node as Node): 121 | if node.LexicalInfo is null: 122 | # Console.WriteLine ("No lexical info!") 123 | return false 124 | if not node.LexicalInfo.FullPath.Equals(_filename, StringComparison.OrdinalIgnoreCase): 125 | # Console.WriteLine ("{0} doesn't match {1}", node.LexicalInfo.FullPath, _filename) 126 | return false 127 | if _line != node.LexicalInfo.Line: 128 | # Console.WriteLine ("{0} doesn't match {1}", node.LexicalInfo.Line, _line) 129 | return false 130 | return true 131 | 132 | static def GetLexicalInfo (node as IEntity): 133 | if (node is null): 134 | # Console.WriteLine ("null entity!") 135 | return null 136 | if (node isa IInternalEntity): 137 | internalEntity = node as IInternalEntity 138 | return null if internalEntity.Node is null 139 | return internalEntity.Node.LexicalInfo 140 | if (node isa IExternalEntity): 141 | # Console.WriteLine ("Dropping external method {0}", node.Name) 142 | return null 143 | if (node isa Method): 144 | return (node as Method).LexicalInfo 145 | else: 146 | raise ArgumentException (string.Format ("Invalid node type: {0}", node.GetType ()), "node"); 147 | 148 | static def FullNameToParent (name as string, fullname as string): 149 | if (string.IsNullOrEmpty (name)): raise ArgumentException ("Name cannot be empty") 150 | if (fullname is null or fullname.Length <= name.Length or not fullname.Contains (name)): return name 151 | 152 | return fullname.Substring (fullname.LastIndexOf (name)) 153 | 154 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/Completion/UnityScriptEditorCompletion.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.Completion 2 | 3 | import System 4 | import Mono.TextEditor.Highlighting 5 | import MonoDevelop.Core 6 | import MonoDevelop.Ide.Gui 7 | import MonoDevelop.Ide.CodeCompletion 8 | 9 | import Boo.Lang.PatternMatching 10 | 11 | import Boo.Ide 12 | import Boo.MonoDevelop.Util.Completion 13 | 14 | class UnityScriptEditorCompletion(BooCompletionTextEditorExtension): 15 | 16 | # Match "blah = new [...]" pattern 17 | static NEW_PATTERN = /\bnew\s+(?[\w\d]+(\.[\w\d]+)*)?\.?/ 18 | 19 | # Match "var blah: [...]" pattern 20 | static COLON_PATTERN = /\w\s*:\s*(?[\w\d]+(\.[\w\d]+)*)?\.?/ 21 | 22 | # Patterns that result in us doing a type completion 23 | static TYPE_PATTERNS = (NEW_PATTERN, COLON_PATTERN) 24 | 25 | # Patterns that result in us doing a namespace completion 26 | static NAMESPACE_PATTERNS = (IMPORTS_PATTERN,) 27 | 28 | # Delimiters that indicate a literal 29 | static LITERAL_DELIMITERS = ['"'] 30 | 31 | # Scraped from UnityScript.g 32 | private static KEYWORDS = ( 33 | "as", 34 | "break", 35 | "catch", 36 | "class", 37 | "continue", 38 | "else", 39 | "enum", 40 | "extends", 41 | "false", 42 | "final", 43 | "finally", 44 | "for", 45 | "function", 46 | "get", 47 | "if", 48 | "import", 49 | "implements", 50 | "in", 51 | "interface", 52 | "instanceof", 53 | "new", 54 | "null", 55 | "return", 56 | "public", 57 | "protected", 58 | "internal", 59 | "override", 60 | "partial", 61 | "pragma", 62 | "private", 63 | "set", 64 | "static", 65 | "super", 66 | "this", 67 | "throw", 68 | "true", 69 | "try", 70 | "typeof", 71 | "var", 72 | "virtual", 73 | "while", 74 | "yield", 75 | "switch", 76 | "case", 77 | "default" 78 | ) 79 | 80 | # Scraped from Types.cs 81 | private static PRIMITIVES = ( 82 | "byte", 83 | "sbyte", 84 | "short", 85 | "ushort", 86 | "int", 87 | "uint", 88 | "long", 89 | "ulong", 90 | "float", 91 | "double", 92 | "decimal", 93 | "void", 94 | "string", 95 | "object" 96 | ) 97 | 98 | override Keywords: 99 | get: return KEYWORDS 100 | 101 | override Primitives: 102 | get: return PRIMITIVES 103 | 104 | override def Initialize(): 105 | InstallUnityScriptSyntaxModeIfNeeded() 106 | super() 107 | 108 | def InstallUnityScriptSyntaxModeIfNeeded(): 109 | doc = Document.Editor.Document 110 | mimeType = UnityScript.MonoDevelop.ProjectModel.UnityScriptParser.MimeType 111 | syntaxMode = doc.SyntaxMode as SyntaxMode 112 | return if syntaxMode != null and syntaxMode.MimeType == mimeType 113 | 114 | mode = Mono.TextEditor.Highlighting.SyntaxModeService.GetSyntaxMode (doc, mimeType) 115 | if mode is not null: 116 | doc.SyntaxMode = mode 117 | else: 118 | LoggingService.LogWarning(GetType() + " could not get SyntaxMode for mimetype '" + mimeType + "'.") 119 | 120 | # override def HandleCodeCompletion(context as CodeCompletionContext, completionChar as char): 121 | # triggerWordLength = 0 122 | # HandleCodeCompletion(context, completionChar, triggerWordLength) 123 | 124 | override def HandleCodeCompletion(context as CodeCompletionContext, completionChar as char, ref triggerWordLength as int): 125 | # print "HandleCodeCompletion(${context.ToString()}, '${completionChar.ToString()}')" 126 | line = GetLineText(context.TriggerLine) 127 | tokenLineOffset = context.TriggerLineOffset-1 128 | 129 | if (IsInsideComment(line, tokenLineOffset) or \ 130 | IsInsideLiteral(line, tokenLineOffset)): 131 | return null 132 | 133 | match completionChar.ToString(): 134 | case " ": 135 | if (null != (completions = CompleteNamespacePatterns(context))): 136 | return completions 137 | return CompleteTypePatterns(context) 138 | case ":": 139 | return CompleteTypePatterns(context) 140 | case ".": 141 | if (null != (completions = CompleteNamespacePatterns(context))): 142 | return completions 143 | elif (null != (completions = CompleteTypePatterns(context))): 144 | return completions 145 | return CompleteMembers(context) 146 | otherwise: 147 | if(CanStartIdentifier(completionChar)): 148 | if(StartsIdentifier(line, tokenLineOffset)): 149 | # Necessary for completion window to take first identifier character into account 150 | --context.TriggerOffset 151 | triggerWordLength = 1 152 | return CompleteVisible(context) 153 | else: 154 | dotLineOffset = tokenLineOffset-1 155 | if(0 <= dotLineOffset and line.Length > dotLineOffset and "."[0] == line[dotLineOffset]): 156 | --context.TriggerOffset 157 | triggerWordLength = 1 158 | return CompleteMembers(context) 159 | return null 160 | 161 | def CompleteNamespacePatterns(context as CodeCompletionContext): 162 | completions as CompletionDataList = null 163 | 164 | for pattern in NAMESPACE_PATTERNS: 165 | return completions if (null != (completions = CompleteNamespacesForPattern(context, pattern, "namespace"))) 166 | return null 167 | 168 | def CompleteTypePatterns(context as CodeCompletionContext): 169 | completions as CompletionDataList 170 | for pattern in TYPE_PATTERNS: 171 | if (null != (completions = CompleteNamespacesForPattern(context, pattern, "namespace"))): 172 | completions.AddRange(CompletionData(p, Stock.Literal) for p in Primitives) 173 | return completions 174 | return null 175 | 176 | override def ShouldEnableCompletionFor(fileName as string): 177 | return UnityScript.MonoDevelop.IsUnityScriptFile(fileName) 178 | 179 | def IsInsideLiteral(line as string, offset as int): 180 | fragment = line[0:offset+1] 181 | for delimiter in LITERAL_DELIMITERS: 182 | list = List[of string]() 183 | list.Add(delimiter) 184 | if(0 == fragment.Split(list.ToArray(), StringSplitOptions.None).Length%2): 185 | return true 186 | return false 187 | 188 | override SelfReference: 189 | get: return "this" 190 | 191 | override EndStatement: 192 | get: return ";" 193 | 194 | override def GetParameterDataProviderFor(methods as List of MethodDescriptor): 195 | return UnityScriptParameterDataProvider(Document, methods) 196 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Boo.MonoDevelop.booproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {A154F6EB-6808-4816-B9C1-C5412663E0F1} 9 | Library 10 | Boo.MonoDevelop 11 | False 12 | Boo.MonoDevelop 13 | v4.0 14 | 15 | 16 | True 17 | full 18 | bin\Debug 19 | prompt 20 | False 21 | 22 | False 23 | False 24 | 25 | 26 | none 27 | bin\Release 28 | prompt 29 | False 30 | 31 | False 32 | False 33 | 34 | 35 | 36 | 37 | 38 | 39 | ..\..\..\monodevelop\main\build\bin\Mono.Debugging.dll 40 | 41 | 42 | ..\..\..\monodevelop\main\build\bin\MonoDevelop.Core.dll 43 | 44 | 45 | ..\..\..\monodevelop\main\build\bin\MonoDevelop.Ide.dll 46 | 47 | 48 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.Debugger\MonoDevelop.Debugger.dll 49 | 50 | 51 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll 52 | 53 | 54 | ..\..\..\monodevelop\main\build\AddIns\MonoDevelop.SourceEditor2.dll 55 | 56 | 57 | ..\..\..\monodevelop\main\build\bin\Mono.TextEditor.dll 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | Boo.MonoDevelop.addin.xml 81 | 82 | 83 | ConsoleProject.xpt.xml 84 | 85 | 86 | EmptyBooFile.xft.xml 87 | 88 | 89 | LibraryProject.xpt.xml 90 | 91 | 92 | Boo.File.EmptyFile 93 | 94 | 95 | Boo.File.Form 96 | 97 | 98 | BooBinding.Base 99 | 100 | 101 | BooFile.png 102 | 103 | 104 | BooProjectDecoration.png 105 | 106 | 107 | BooProjectStockIcon.png 108 | 109 | 110 | BooSyntaxMode.xml 111 | 112 | 113 | 114 | 115 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1} 116 | Boo.MonoDevelop.Util 117 | 118 | 119 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F} 120 | Boo.Adt 121 | 122 | 123 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9} 124 | Boo.Ide 125 | 126 | 127 | {9C3A3730-CFB9-41FA-9DFC-54918C6EE2B6} 128 | Boo.Lang.CodeDom 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/Boo.MonoDevelop.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.MonoDevelop", "Boo.MonoDevelop.booproj", "{A154F6EB-6808-4816-B9C1-C5412663E0F1}" 5 | EndProject 6 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.MonoDevelop.Tests", "..\Boo.MonoDevelop.Tests\Boo.MonoDevelop.Tests.booproj", "{DA18FECD-4F5B-4A02-B36B-876838F6B7A3}" 7 | EndProject 8 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.MonoDevelop.Util", "..\Boo.MonoDevelop.Util\Boo.MonoDevelop.Util.booproj", "{EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1}" 9 | EndProject 10 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "UnityScript.MonoDevelop", "..\UnityScript.MonoDevelop\UnityScript.MonoDevelop.booproj", "{FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38}" 11 | EndProject 12 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.Adt", "..\..\..\boo-extensions\src\Boo.Adt\Boo.Adt.booproj", "{18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F}" 13 | EndProject 14 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.Ide", "..\Boo.Ide\Boo.Ide.booproj", "{C79506C7-C4C4-424F-95AA-132B7DDF5AF9}" 15 | EndProject 16 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.Ide.Tests", "..\Boo.Ide.Tests\Boo.Ide.Tests.booproj", "{0006C2FE-E307-4180-8DBE-89392174228E}" 17 | EndProject 18 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "UnityScript.Lang", "..\..\..\unityscript\src\UnityScript.Lang\UnityScript.Lang.booproj", "{2784E7F4-5206-4BF9-99CD-96B1D94D0E19}" 19 | EndProject 20 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "UnityScript", "..\..\..\unityscript\src\UnityScript\UnityScript.booproj", "{A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}" 21 | EndProject 22 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "UnityScript.Ide", "..\UnityScript.Ide\UnityScript.Ide.booproj", "{53D5E189-64E0-49A6-A8F3-505599E84639}" 23 | EndProject 24 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "UnityScript.Ide.Tests", "..\UnityScript.Ide.Tests\UnityScript.Ide.Tests.booproj", "{A0F2C421-3C9C-45F1-9CA1-839C73D2B953}" 25 | EndProject 26 | Project("{B3672514-7503-4B01-B4B4-B44E87061EA2}") = "Boo.Lang.CodeDom", "..\..\..\boo\src\Boo.Lang.CodeDom\Boo.Lang.CodeDom.booproj", "{9C3A3730-CFB9-41FA-9DFC-54918C6EE2B6}" 27 | EndProject 28 | Global 29 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 30 | Debug|Any CPU = Debug|Any CPU 31 | Release|Any CPU = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {0006C2FE-E307-4180-8DBE-89392174228E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {0006C2FE-E307-4180-8DBE-89392174228E}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {0006C2FE-E307-4180-8DBE-89392174228E}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {0006C2FE-E307-4180-8DBE-89392174228E}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {18AF07E6-C62E-4CDC-8F58-5A0F9A872F7F}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {2784E7F4-5206-4BF9-99CD-96B1D94D0E19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {2784E7F4-5206-4BF9-99CD-96B1D94D0E19}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {2784E7F4-5206-4BF9-99CD-96B1D94D0E19}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {2784E7F4-5206-4BF9-99CD-96B1D94D0E19}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {53D5E189-64E0-49A6-A8F3-505599E84639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {53D5E189-64E0-49A6-A8F3-505599E84639}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {53D5E189-64E0-49A6-A8F3-505599E84639}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {53D5E189-64E0-49A6-A8F3-505599E84639}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {9C3A3730-CFB9-41FA-9DFC-54918C6EE2B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {9C3A3730-CFB9-41FA-9DFC-54918C6EE2B6}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {9C3A3730-CFB9-41FA-9DFC-54918C6EE2B6}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {9C3A3730-CFB9-41FA-9DFC-54918C6EE2B6}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {A0F2C421-3C9C-45F1-9CA1-839C73D2B953}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {A0F2C421-3C9C-45F1-9CA1-839C73D2B953}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {A0F2C421-3C9C-45F1-9CA1-839C73D2B953}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {A0F2C421-3C9C-45F1-9CA1-839C73D2B953}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {A154F6EB-6808-4816-B9C1-C5412663E0F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {A154F6EB-6808-4816-B9C1-C5412663E0F1}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {A154F6EB-6808-4816-B9C1-C5412663E0F1}.Release|Any CPU.ActiveCfg = Release|Any CPU 61 | {A154F6EB-6808-4816-B9C1-C5412663E0F1}.Release|Any CPU.Build.0 = Release|Any CPU 62 | {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 63 | {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}.Debug|Any CPU.Build.0 = Debug|Any CPU 64 | {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}.Release|Any CPU.ActiveCfg = Release|Any CPU 65 | {A4F2FB34-6254-473D-9EB4-FAF062AF1AEB}.Release|Any CPU.Build.0 = Release|Any CPU 66 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 67 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9}.Debug|Any CPU.Build.0 = Debug|Any CPU 68 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9}.Release|Any CPU.ActiveCfg = Release|Any CPU 69 | {C79506C7-C4C4-424F-95AA-132B7DDF5AF9}.Release|Any CPU.Build.0 = Release|Any CPU 70 | {DA18FECD-4F5B-4A02-B36B-876838F6B7A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 71 | {DA18FECD-4F5B-4A02-B36B-876838F6B7A3}.Debug|Any CPU.Build.0 = Debug|Any CPU 72 | {DA18FECD-4F5B-4A02-B36B-876838F6B7A3}.Release|Any CPU.ActiveCfg = Release|Any CPU 73 | {DA18FECD-4F5B-4A02-B36B-876838F6B7A3}.Release|Any CPU.Build.0 = Release|Any CPU 74 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 75 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1}.Debug|Any CPU.Build.0 = Debug|Any CPU 76 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1}.Release|Any CPU.ActiveCfg = Release|Any CPU 77 | {EE6B8C46-43AB-422B-B6C9-E3E29A33EDC1}.Release|Any CPU.Build.0 = Release|Any CPU 78 | {FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 79 | {FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38}.Debug|Any CPU.Build.0 = Debug|Any CPU 80 | {FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38}.Release|Any CPU.ActiveCfg = Release|Any CPU 81 | {FCFE96D7-4BDB-4EE9-BD11-E3E263E1DE38}.Release|Any CPU.Build.0 = Release|Any CPU 82 | EndGlobalSection 83 | GlobalSection(MonoDevelopProperties) = preSolution 84 | StartupItem = Boo.MonoDevelop.booproj 85 | EndGlobalSection 86 | EndGlobal 87 | -------------------------------------------------------------------------------- /src/Boo.MonoDevelop/ProjectModel/DomConversionVisitor.boo: -------------------------------------------------------------------------------- 1 | namespace Boo.MonoDevelop.ProjectModel 2 | 3 | 4 | import Boo.Lang.Compiler.Ast 5 | import Boo.Lang.PatternMatching 6 | 7 | import MonoDevelop.Core 8 | import MonoDevelop.Ide.TypeSystem 9 | 10 | import ICSharpCode.NRefactory 11 | import ICSharpCode.NRefactory.CSharp 12 | import ICSharpCode.NRefactory.TypeSystem 13 | import ICSharpCode.NRefactory.TypeSystem.Implementation 14 | 15 | class DomConversionVisitor(DepthFirstVisitor): 16 | 17 | _result as SyntaxTree 18 | _currentType as TypeDeclaration 19 | _namespace as string 20 | 21 | def constructor(result as SyntaxTree): 22 | _result = result 23 | 24 | override def OnModule(node as Module): 25 | _namespace = null 26 | try: 27 | Visit(node.Namespace) 28 | Visit(node.Members) 29 | except e: 30 | MonoDevelop.Core.LoggingService.LogError ("Error in dom conversion", e) 31 | ex = e.InnerException 32 | while null != ex: 33 | MonoDevelop.Core.LoggingService.LogError (ex.StackTrace) 34 | ex = ex.InnerException 35 | 36 | override def OnNamespaceDeclaration(node as Boo.Lang.Compiler.Ast.NamespaceDeclaration): 37 | _namespace = node.Name 38 | # domUsing = UsingStatement () 39 | # domUsing = DomUsing(IsFromNamespace: true, Region: region) 40 | astNamespace = ICSharpCode.NRefactory.CSharp.NamespaceDeclaration (Name: _namespace) 41 | astNamespace.AddAnnotation (BodyRegionOf (node)) 42 | _result.AddChild (astNamespace, SyntaxTree.MemberRole) 43 | 44 | override def OnImport(node as Import): 45 | domUsing = UsingDeclaration (node.Namespace) 46 | _result.AddChild (domUsing, SyntaxTree.MemberRole) 47 | 48 | override def OnClassDefinition(node as ClassDefinition): 49 | OnTypeDefinition(node, ClassType.Class) 50 | 51 | override def OnInterfaceDefinition(node as InterfaceDefinition): 52 | OnTypeDefinition(node, ClassType.Interface) 53 | 54 | override def OnStructDefinition(node as StructDefinition): 55 | OnTypeDefinition(node, ClassType.Struct) 56 | 57 | override def OnEnumDefinition(node as EnumDefinition): 58 | OnTypeDefinition(node, ClassType.Enum) 59 | 60 | def OnTypeDefinition(node as TypeDefinition, classType as ClassType): 61 | # LoggingService.LogError ("Found type {0}", node.FullName) 62 | converted = TypeDeclaration ( 63 | Name: node.Name, 64 | ClassType: classType, 65 | # DeclaringType: _currentType, 66 | Modifiers: ModifiersFrom(node) 67 | ) 68 | converted.AddAnnotation (LocationOf (node)) 69 | converted.AddAnnotation (BodyRegionOf (node)) 70 | 71 | WithCurrentType converted: 72 | Visit(node.Members) 73 | 74 | AddType(converted) 75 | 76 | override def OnCallableDefinition(node as CallableDefinition): 77 | if _currentType is null: return 78 | # parameters = System.Collections.Generic.List[of IParameter]() 79 | # for p in node.Parameters: parameters.Add(ParameterFrom(null, p)) 80 | 81 | converted = DelegateDeclaration ( 82 | Name: node.Name, 83 | ReturnType: ReturnTypeFrom (node.ReturnType) 84 | ) 85 | # _result, node.Name, LocationOf(node), ReturnTypeFrom(node.ReturnType), parameters) 86 | converted.Modifiers = ModifiersFrom(node) 87 | # converted.DeclaringType = _currentType 88 | # converted.BodyRegion = BodyRegionOf(node) 89 | converted.AddAnnotation (LocationOf (node)) 90 | converted.AddAnnotation (BodyRegionOf (node)) 91 | 92 | # for p in parameters: p.DeclaringMember = converted 93 | for parameter in node.Parameters: 94 | converted.Parameters.Add(ParameterFrom(parameter)) 95 | 96 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 97 | 98 | override def OnField(node as Field): 99 | if _currentType is null: return 100 | 101 | field = FieldDeclaration( 102 | # Name: node.Name, 103 | ReturnType: ParameterTypeFrom(node.Type), 104 | # DeclaringType: _currentType, 105 | Modifiers: ModifiersFrom(node)) 106 | field.AddChild (VariableInitializer (node.Name, null), Roles.Variable) 107 | field.AddAnnotation (LocationOf (node)) 108 | field.AddAnnotation (BodyRegionOf (node)) 109 | _currentType.AddChild (field, SyntaxTree.MemberRole) 110 | 111 | override def OnProperty(node as Property): 112 | if _currentType is null: return 113 | 114 | try: 115 | converted = PropertyDeclaration( 116 | Name: node.Name, 117 | ReturnType: ParameterTypeFrom(node.Type)) 118 | # Location: LocationOf(node), 119 | # BodyRegion: BodyRegionOf(node), 120 | # DeclaringType: _currentType) 121 | # if node.Getter is not null: 122 | # converted.PropertyModifier |= PropertyModifier.HasGet 123 | # converted.GetterModifier = ModifiersFrom(node.Getter) 124 | # converted.GetRegion = BodyRegionOf(node.Getter) 125 | # if node.Setter is not null: 126 | # converted.PropertyModifier |= PropertyModifier.HasSet 127 | # converted.SetterModifier = ModifiersFrom(node.Setter) 128 | # converted.SetRegion = BodyRegionOf(node.Setter) 129 | converted.AddAnnotation (LocationOf (node)) 130 | converted.AddAnnotation (BodyRegionOf (node)) 131 | 132 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 133 | except x: 134 | print x, x.InnerException 135 | 136 | override def OnEvent(node as Event): 137 | if _currentType is null: return 138 | 139 | converted = EventDeclaration ( 140 | # Name: node.Name, 141 | ReturnType: ParameterTypeFrom(node.Type)) 142 | # Location: LocationOf(node), 143 | # BodyRegion: BodyRegionOf(node), 144 | # DeclaringType: _currentType) 145 | converted.AddChild (VariableInitializer (node.Name, null), Roles.Variable) 146 | converted.AddAnnotation (LocationOf (node)) 147 | converted.AddAnnotation (BodyRegionOf (node)) 148 | 149 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 150 | 151 | override def OnEnumMember(node as EnumMember): 152 | if _currentType is null: return 153 | 154 | field = FieldDeclaration( 155 | # Name: node.Name, 156 | # DeclaringType: _currentType, 157 | Modifiers: ModifiersFrom(node)) 158 | field.AddChild (VariableInitializer (node.Name, null), Roles.Variable) 159 | field.AddAnnotation (LocationOf (node)) 160 | field.AddAnnotation (BodyRegionOf (node)) 161 | _currentType.AddChild (field, SyntaxTree.MemberRole) 162 | 163 | override def OnConstructor(node as Constructor): 164 | OnMethodImpl(node) 165 | 166 | override def OnDestructor(node as Destructor): 167 | OnMethodImpl(node) 168 | 169 | override def OnMethod(node as Method): 170 | OnMethodImpl(node) 171 | 172 | def OnMethodImpl(node as Method): 173 | if _currentType is null or node.ParentNode isa Property: 174 | return 175 | 176 | converted = MethodDeclaration ( 177 | Name: node.Name, 178 | # DeclaringType: _currentType, 179 | ReturnType: (MethodReturnTypeFrom(node) if IsRegularMethod(node.NodeType) else null), 180 | Modifiers: ModifiersFrom(node)) 181 | 182 | converted.AddAnnotation (LocationOf (node)) 183 | converted.AddAnnotation (BodyRegionOf (node)) 184 | 185 | for parameter in node.Parameters: 186 | converted.Parameters.Add(ParameterFrom(parameter)) 187 | 188 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 189 | 190 | def IsRegularMethod(modifier as Boo.Lang.Compiler.Ast.NodeType): 191 | return true 192 | match modifier: 193 | case Boo.Lang.Compiler.Ast.NodeType.Constructor | Boo.Lang.Compiler.Ast.NodeType.Destructor: 194 | return false 195 | otherwise: 196 | return true 197 | 198 | def ModifiersFrom(node as TypeMember): 199 | modifiers = Modifiers.None 200 | modifiers |= Modifiers.Public if node.IsPublic 201 | modifiers |= Modifiers.Private if node.IsPrivate 202 | modifiers |= Modifiers.Protected if node.IsProtected 203 | modifiers |= Modifiers.Internal if node.IsInternal 204 | modifiers |= Modifiers.Static if node.IsStatic 205 | modifiers |= Modifiers.Virtual if node.IsVirtual 206 | modifiers |= Modifiers.Abstract if node.IsAbstract 207 | modifiers |= Modifiers.Override if node.IsOverride 208 | modifiers |= Modifiers.Sealed if node.IsFinal 209 | return modifiers 210 | 211 | def ParameterFrom(parameter as Boo.Lang.Compiler.Ast.ParameterDeclaration): 212 | astParameter = ICSharpCode.NRefactory.CSharp.ParameterDeclaration (Type: ParameterTypeFrom (parameter.Type), 213 | Name: parameter.Name) 214 | # DeclaringMember: declaringMember, 215 | astParameter.AddAnnotation (LocationOf (parameter)) 216 | return astParameter 217 | 218 | virtual def MethodReturnTypeFrom(method as Method): 219 | if method.ReturnType is not null: 220 | return ReturnTypeFrom(method.ReturnType) 221 | 222 | match ReturnTypeDetector().Detect(method): 223 | case ReturnTypeDetector.Result.Yields: 224 | return SimpleType ("System.Collections.IEnumerator") 225 | case ReturnTypeDetector.Result.Returns: 226 | return DefaultReturnType() 227 | otherwise: 228 | return AstType.Null 229 | 230 | class ReturnTypeDetector(DepthFirstVisitor): 231 | enum Result: 232 | Returns 233 | Yields 234 | None 235 | 236 | _result = Result.None 237 | 238 | def Detect(node as Method): 239 | VisitAllowingCancellation(node) 240 | return _result 241 | 242 | override def OnBlockExpression(node as BlockExpression): 243 | pass // skip over closures 244 | 245 | override def OnReturnStatement(node as Boo.Lang.Compiler.Ast.ReturnStatement): 246 | if node.Expression is null: return 247 | _result = Result.Returns 248 | 249 | override def OnYieldStatement(node as YieldStatement): 250 | _result = Result.Yields 251 | Cancel() 252 | 253 | virtual def ParameterTypeFrom(typeRef as TypeReference): 254 | if typeRef is null: return DefaultReturnType() 255 | return ReturnTypeFrom(typeRef) 256 | 257 | virtual def ReturnTypeFrom(typeRef as TypeReference): 258 | match typeRef: 259 | case SimpleTypeReference(Name: name): 260 | return SimpleType (name) 261 | # case ArrayTypeReference(ElementType: elementType): 262 | # type = ReturnTypeFrom(elementType) 263 | # type.ArrayDimensions = 1 264 | # type.SetDimension(0, 1) 265 | # return type 266 | otherwise: 267 | return AstType.Null 268 | 269 | def AddType(type as TypeDeclaration): 270 | if _currentType is not null: 271 | _currentType.AddChild (type, SyntaxTree.MemberRole) 272 | else: 273 | # type.Namespace = _namespace 274 | _result.AddChild (type, SyntaxTree.MemberRole) 275 | 276 | def WithCurrentType(type as TypeDeclaration, block as callable()): 277 | saved = _currentType 278 | _currentType = type 279 | try: 280 | block() 281 | ensure: 282 | _currentType = saved 283 | 284 | def BodyRegionOf(node as Node): 285 | startLocation = TextLocation (DomLocationFrom(node.LexicalInfo).Line, int.MaxValue) 286 | endLocation = TextLocation (DomLocationFrom(node.EndSourceLocation).Line, int.MaxValue) 287 | return DomRegion(startLocation, endLocation) 288 | 289 | def LocationOf(node as Node): 290 | location = node.LexicalInfo 291 | return DomLocationFrom(location) 292 | 293 | def DomLocationFrom(location as SourceLocation): 294 | return TextLocation(location.Line, location.Column) 295 | 296 | def DefaultReturnType(): 297 | return SimpleType ("object") 298 | -------------------------------------------------------------------------------- /src/UnityScript.MonoDevelop/ProjectModel/DomConversionVisitor.boo: -------------------------------------------------------------------------------- 1 | namespace UnityScript.MonoDevelop.ProjectModel 2 | 3 | 4 | import Boo.Lang.Compiler.Ast 5 | import Boo.Lang.PatternMatching 6 | 7 | import MonoDevelop.Core 8 | import MonoDevelop.Ide.TypeSystem 9 | 10 | import ICSharpCode.NRefactory 11 | import ICSharpCode.NRefactory.CSharp 12 | import ICSharpCode.NRefactory.TypeSystem 13 | import ICSharpCode.NRefactory.TypeSystem.Implementation 14 | 15 | class DomConversionVisitor(DepthFirstVisitor): 16 | 17 | _result as SyntaxTree 18 | _currentType as TypeDeclaration 19 | _namespace as string 20 | 21 | def constructor(result as SyntaxTree): 22 | _result = result 23 | 24 | override def OnModule(node as Module): 25 | _namespace = null 26 | try: 27 | Visit(node.Namespace) 28 | Visit(node.Members) 29 | except e: 30 | MonoDevelop.Core.LoggingService.LogError ("Error in dom conversion", e) 31 | ex = e.InnerException 32 | while null != ex: 33 | MonoDevelop.Core.LoggingService.LogError (ex.StackTrace) 34 | ex = ex.InnerException 35 | 36 | override def OnNamespaceDeclaration(node as Boo.Lang.Compiler.Ast.NamespaceDeclaration): 37 | _namespace = node.Name 38 | # domUsing = UsingStatement () 39 | # domUsing = DomUsing(IsFromNamespace: true, Region: region) 40 | astNamespace = ICSharpCode.NRefactory.CSharp.NamespaceDeclaration (Name: _namespace) 41 | astNamespace.AddAnnotation (BodyRegionOf (node)) 42 | _result.AddChild (astNamespace, SyntaxTree.MemberRole) 43 | 44 | override def OnImport(node as Import): 45 | domUsing = UsingDeclaration (node.Namespace) 46 | _result.AddChild (domUsing, SyntaxTree.MemberRole) 47 | 48 | override def OnClassDefinition(node as ClassDefinition): 49 | OnTypeDefinition(node, ClassType.Class) 50 | 51 | override def OnInterfaceDefinition(node as InterfaceDefinition): 52 | OnTypeDefinition(node, ClassType.Interface) 53 | 54 | override def OnStructDefinition(node as StructDefinition): 55 | OnTypeDefinition(node, ClassType.Struct) 56 | 57 | override def OnEnumDefinition(node as EnumDefinition): 58 | OnTypeDefinition(node, ClassType.Enum) 59 | 60 | def OnTypeDefinition(node as TypeDefinition, classType as ClassType): 61 | # LoggingService.LogError ("Found type {0}", node.FullName) 62 | converted = TypeDeclaration ( 63 | Name: node.Name, 64 | ClassType: classType, 65 | # DeclaringType: _currentType, 66 | Modifiers: ModifiersFrom(node) 67 | ) 68 | converted.AddAnnotation (LocationOf (node)) 69 | converted.AddAnnotation (BodyRegionOf (node)) 70 | 71 | WithCurrentType converted: 72 | Visit(node.Members) 73 | 74 | AddType(converted) 75 | 76 | override def OnCallableDefinition(node as CallableDefinition): 77 | if _currentType is null: return 78 | # parameters = System.Collections.Generic.List[of IParameter]() 79 | # for p in node.Parameters: parameters.Add(ParameterFrom(null, p)) 80 | 81 | converted = DelegateDeclaration ( 82 | Name: node.Name, 83 | ReturnType: ReturnTypeFrom (node.ReturnType) 84 | ) 85 | # _result, node.Name, LocationOf(node), ReturnTypeFrom(node.ReturnType), parameters) 86 | converted.Modifiers = ModifiersFrom(node) 87 | # converted.DeclaringType = _currentType 88 | # converted.BodyRegion = BodyRegionOf(node) 89 | converted.AddAnnotation (LocationOf (node)) 90 | converted.AddAnnotation (BodyRegionOf (node)) 91 | 92 | # for p in parameters: p.DeclaringMember = converted 93 | for parameter in node.Parameters: 94 | converted.Parameters.Add(ParameterFrom(parameter)) 95 | 96 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 97 | 98 | override def OnField(node as Field): 99 | if _currentType is null: return 100 | 101 | field = FieldDeclaration( 102 | # Name: node.Name, 103 | ReturnType: ParameterTypeFrom(node.Type), 104 | # DeclaringType: _currentType, 105 | Modifiers: ModifiersFrom(node)) 106 | field.AddChild (VariableInitializer (node.Name, null), Roles.Variable) 107 | field.AddAnnotation (LocationOf (node)) 108 | field.AddAnnotation (BodyRegionOf (node)) 109 | _currentType.AddChild (field, SyntaxTree.MemberRole) 110 | 111 | override def OnProperty(node as Property): 112 | if _currentType is null: return 113 | 114 | try: 115 | converted = PropertyDeclaration( 116 | Name: node.Name, 117 | ReturnType: ParameterTypeFrom(node.Type)) 118 | # Location: LocationOf(node), 119 | # BodyRegion: BodyRegionOf(node), 120 | # DeclaringType: _currentType) 121 | # if node.Getter is not null: 122 | # converted.PropertyModifier |= PropertyModifier.HasGet 123 | # converted.GetterModifier = ModifiersFrom(node.Getter) 124 | # converted.GetRegion = BodyRegionOf(node.Getter) 125 | # if node.Setter is not null: 126 | # converted.PropertyModifier |= PropertyModifier.HasSet 127 | # converted.SetterModifier = ModifiersFrom(node.Setter) 128 | # converted.SetRegion = BodyRegionOf(node.Setter) 129 | converted.AddAnnotation (LocationOf (node)) 130 | converted.AddAnnotation (BodyRegionOf (node)) 131 | 132 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 133 | except x: 134 | print x, x.InnerException 135 | 136 | override def OnEvent(node as Event): 137 | if _currentType is null: return 138 | 139 | converted = EventDeclaration ( 140 | # Name: node.Name, 141 | ReturnType: ParameterTypeFrom(node.Type)) 142 | # Location: LocationOf(node), 143 | # BodyRegion: BodyRegionOf(node), 144 | # DeclaringType: _currentType) 145 | converted.AddChild (VariableInitializer (node.Name, null), Roles.Variable) 146 | converted.AddAnnotation (LocationOf (node)) 147 | converted.AddAnnotation (BodyRegionOf (node)) 148 | 149 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 150 | 151 | override def OnEnumMember(node as EnumMember): 152 | if _currentType is null: return 153 | 154 | field = FieldDeclaration( 155 | # Name: node.Name, 156 | # DeclaringType: _currentType, 157 | Modifiers: ModifiersFrom(node)) 158 | field.AddChild (VariableInitializer (node.Name, null), Roles.Variable) 159 | field.AddAnnotation (LocationOf (node)) 160 | field.AddAnnotation (BodyRegionOf (node)) 161 | _currentType.AddChild (field, SyntaxTree.MemberRole) 162 | 163 | override def OnConstructor(node as Constructor): 164 | OnMethodImpl(node) 165 | 166 | override def OnDestructor(node as Destructor): 167 | OnMethodImpl(node) 168 | 169 | override def OnMethod(node as Method): 170 | OnMethodImpl(node) 171 | 172 | def OnMethodImpl(node as Method): 173 | if _currentType is null or node.ParentNode isa Property: 174 | return 175 | 176 | converted = MethodDeclaration ( 177 | Name: node.Name, 178 | # DeclaringType: _currentType, 179 | ReturnType: (MethodReturnTypeFrom(node) if IsRegularMethod(node.NodeType) else null), 180 | Modifiers: ModifiersFrom(node)) 181 | 182 | converted.AddAnnotation (LocationOf (node)) 183 | converted.AddAnnotation (BodyRegionOf (node)) 184 | 185 | for parameter in node.Parameters: 186 | converted.Parameters.Add(ParameterFrom(parameter)) 187 | 188 | _currentType.AddChild (converted, SyntaxTree.MemberRole) 189 | 190 | def IsRegularMethod(modifier as Boo.Lang.Compiler.Ast.NodeType): 191 | return true 192 | match modifier: 193 | case Boo.Lang.Compiler.Ast.NodeType.Constructor | Boo.Lang.Compiler.Ast.NodeType.Destructor: 194 | return false 195 | otherwise: 196 | return true 197 | 198 | def ModifiersFrom(node as TypeMember): 199 | modifiers = Modifiers.None 200 | modifiers |= Modifiers.Public if node.IsPublic 201 | modifiers |= Modifiers.Private if node.IsPrivate 202 | modifiers |= Modifiers.Protected if node.IsProtected 203 | modifiers |= Modifiers.Internal if node.IsInternal 204 | modifiers |= Modifiers.Static if node.IsStatic 205 | modifiers |= Modifiers.Virtual if node.IsVirtual 206 | modifiers |= Modifiers.Abstract if node.IsAbstract 207 | modifiers |= Modifiers.Override if node.IsOverride 208 | modifiers |= Modifiers.Sealed if node.IsFinal 209 | return modifiers 210 | 211 | def ParameterFrom(parameter as Boo.Lang.Compiler.Ast.ParameterDeclaration): 212 | astParameter = ICSharpCode.NRefactory.CSharp.ParameterDeclaration (Type: ParameterTypeFrom (parameter.Type), 213 | Name: parameter.Name) 214 | # DeclaringMember: declaringMember, 215 | astParameter.AddAnnotation (LocationOf (parameter)) 216 | return astParameter 217 | 218 | virtual def MethodReturnTypeFrom(method as Method): 219 | if method.ReturnType is not null: 220 | return ReturnTypeFrom(method.ReturnType) 221 | 222 | match ReturnTypeDetector().Detect(method): 223 | case ReturnTypeDetector.Result.Yields: 224 | return SimpleType ("System.Collections.IEnumerator") 225 | case ReturnTypeDetector.Result.Returns: 226 | return DefaultReturnType() 227 | otherwise: 228 | return AstType.Null 229 | 230 | class ReturnTypeDetector(DepthFirstVisitor): 231 | enum Result: 232 | Returns 233 | Yields 234 | None 235 | 236 | _result = Result.None 237 | 238 | def Detect(node as Method): 239 | VisitAllowingCancellation(node) 240 | return _result 241 | 242 | override def OnBlockExpression(node as BlockExpression): 243 | pass // skip over closures 244 | 245 | override def OnReturnStatement(node as Boo.Lang.Compiler.Ast.ReturnStatement): 246 | if node.Expression is null: return 247 | _result = Result.Returns 248 | 249 | override def OnYieldStatement(node as YieldStatement): 250 | _result = Result.Yields 251 | Cancel() 252 | 253 | virtual def ParameterTypeFrom(typeRef as TypeReference): 254 | if typeRef is null: return DefaultReturnType() 255 | return ReturnTypeFrom(typeRef) 256 | 257 | virtual def ReturnTypeFrom(typeRef as TypeReference): 258 | match typeRef: 259 | case SimpleTypeReference(Name: name): 260 | return SimpleType (name) 261 | # case ArrayTypeReference(ElementType: elementType): 262 | # type = ReturnTypeFrom(elementType) 263 | # type.ArrayDimensions = 1 264 | # type.SetDimension(0, 1) 265 | # return type 266 | otherwise: 267 | return AstType.Null 268 | 269 | def AddType(type as TypeDeclaration): 270 | if _currentType is not null: 271 | _currentType.AddChild (type, SyntaxTree.MemberRole) 272 | else: 273 | # type.Namespace = _namespace 274 | _result.AddChild (type, SyntaxTree.MemberRole) 275 | 276 | def WithCurrentType(type as TypeDeclaration, block as callable()): 277 | saved = _currentType 278 | _currentType = type 279 | try: 280 | block() 281 | ensure: 282 | _currentType = saved 283 | 284 | def BodyRegionOf(node as Node): 285 | startLocation = TextLocation (DomLocationFrom(node.LexicalInfo).Line, int.MaxValue) 286 | endLocation = TextLocation (DomLocationFrom(node.EndSourceLocation).Line, int.MaxValue) 287 | return DomRegion(startLocation, endLocation) 288 | 289 | def LocationOf(node as Node): 290 | location = node.LexicalInfo 291 | return DomLocationFrom(location) 292 | 293 | def DomLocationFrom(location as SourceLocation): 294 | return TextLocation(location.Line, location.Column) 295 | 296 | def DefaultReturnType(): 297 | return SimpleType ("object") 298 | -------------------------------------------------------------------------------- /default.build: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | ${md.bin.dir} 199 | 200 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | --------------------------------------------------------------------------------