├── src ├── LanguageModel.Tests │ ├── CorrectSampleLuaFiles │ │ ├── concat.lua │ │ ├── tabs.lua │ │ ├── assignment.lua │ │ ├── SemiColonStatement.lua │ │ ├── longcomment.lua │ │ ├── AssignmentForIORead.lua │ │ ├── BreakIfStatement.lua │ │ ├── FunctionCallStatement.lua │ │ ├── test.lua │ │ ├── trivia1.lua │ │ ├── EquivalentAssignmentWithNewLine2.lua │ │ ├── MultipleTypeAssignment.lua │ │ ├── NestedFunctionCallStatement.lua │ │ ├── TripleNestedFunctionCall.lua │ │ ├── newlines.lua │ │ ├── smallif.lua │ │ ├── EquivalentAssignmentWithNewLine1.lua │ │ ├── FunctionDefError.lua │ │ ├── IfStatement.lua │ │ ├── GenericForStatement.lua │ │ ├── StringConcat.lua │ │ ├── AssignmentWithFunctionCall.lua │ │ ├── FunctionCallChainingStatement.lua │ │ ├── ReturnStatementInFunction.lua │ │ ├── FunctionCallWithStringLiteral.lua │ │ ├── Assignments.lua │ │ ├── ForInStatement.lua │ │ ├── FunctionCallWithTableConstructor.lua │ │ ├── RepeatStatement.lua │ │ ├── MultipleReturnIf.lua │ │ ├── WhileStatement.lua │ │ ├── IfElse.lua │ │ ├── IfElseIf.lua │ │ ├── FunctionAssignment.lua │ │ ├── ComplexTableConstructor.lua │ │ ├── LocalAssignments.lua │ │ ├── TailCall.lua │ │ ├── ForStatements.lua │ │ ├── NestedTableConstructor.lua │ │ ├── leveled_blocks.lua │ │ ├── VarArgFunction.lua │ │ ├── ForStatementWithVariables.lua │ │ ├── NestedFunctionDef.lua │ │ ├── ComplexFunctionCall.lua │ │ ├── InvalidProgramsMemoryException.lua │ │ ├── TableStatements.lua │ │ ├── nestedif.lua │ │ ├── if.lua │ │ ├── longs.lua │ │ └── InvalidProgramsAsStrings.lua │ ├── TestGeneration │ │ ├── ValidatedGeneratedTests │ │ │ ├── EmptyProgram_Generated.cs │ │ │ ├── GrabKeyFromTable_Generated.cs │ │ │ ├── SimpleTableError_Generated.cs │ │ │ ├── BracketError_Generator.cs │ │ │ ├── PrefixExpFirst_Generated.cs │ │ │ ├── NestedTable_Generated.cs │ │ │ ├── FunctionDefError_Generated.cs │ │ │ ├── SmallIf_Generated.cs │ │ │ └── MultipleTypeAssignment_Generated.cs │ │ ├── UnvalidatedGeneratedTests │ │ │ ├── 27_Generated.cs │ │ │ ├── 13_Generated.cs │ │ │ ├── 12_Generated.cs │ │ │ ├── 29_Generated.cs │ │ │ ├── 26_Generated.cs │ │ │ ├── 3_Generated.cs │ │ │ ├── 14_Generated.cs │ │ │ ├── 0_Generated.cs │ │ │ ├── 21_Generated.cs │ │ │ ├── 6_Generated.cs │ │ │ ├── 7_Generated.cs │ │ │ └── 22_Generated.cs │ │ └── Tester.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── LuaVSHost │ ├── ClassDiagram1.cd │ ├── Key.snk │ ├── Resources │ │ └── Lua.Host.ico │ ├── LuaLanguageServicePackage.pkgdef │ ├── Errors │ │ ├── ErrorListItem.cs │ │ ├── TaskExtensions.cs │ │ └── ErrorTaggerProvider.cs │ ├── Formatting │ │ ├── OptionPages │ │ │ ├── BaseDialogPage.cs │ │ │ ├── UserControls │ │ │ │ ├── GeneralUserControl.xaml.cs │ │ │ │ ├── SpacingUserControl.xaml.cs │ │ │ │ ├── WrappingAndNewLineUserControl.xaml.cs │ │ │ │ └── GeneralUserControl.xaml │ │ │ ├── GeneralPage.cs │ │ │ ├── SpacingPage.cs │ │ │ └── WrappingAndNewLinePage.cs │ │ ├── SmartIndentation │ │ │ ├── SmartIndentProvider.cs │ │ │ └── SmartIndent.cs │ │ └── IFormatter.cs │ ├── Shared │ │ ├── ICore.cs │ │ ├── ContentTypes.cs │ │ ├── ISingletons.cs │ │ ├── Guids.cs │ │ ├── EditorUtilities.cs │ │ ├── Core.cs │ │ ├── Constants.cs │ │ ├── BufferExtensions.cs │ │ ├── IMiniCommandFilter.cs │ │ └── CommandFilter.cs │ ├── Navigation │ │ └── IDocumentOperations.cs │ ├── LuaLanguageService.cs │ ├── LuaContentTypes.cs │ ├── Intellisense │ │ ├── CompletionSourceProvider.cs │ │ └── CompletionHandlerProvider.cs │ ├── Text │ │ └── SourceTextCache.cs │ ├── Classifications │ │ ├── LuaClassificationTypeDefinition.cs │ │ └── TaggerProvider.cs │ ├── source.extension.vsixmanifest │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── LuaLanguageServicePackage.cs │ └── LuaLanguageServiceThemes.pkgdef ├── LanguageModel │ ├── Key.snk │ ├── LanguageModel │ │ ├── ParseContexts.cs │ │ ├── ParseError.cs │ │ ├── Trivia.cs │ │ ├── SyntaxTree.cs │ │ ├── SyntaxNode.cs │ │ └── Token.cs │ ├── Classification │ │ ├── TagInfo.cs │ │ └── Classification.cs │ ├── Formatting │ │ ├── Ruling │ │ │ ├── RuleOperation.cs │ │ │ ├── Rule.cs │ │ │ ├── RuleAction.cs │ │ │ ├── RuleBucket.cs │ │ │ ├── RuleOperationContext.cs │ │ │ ├── RuleDescriptor.cs │ │ │ ├── DeleteSpaceBeforeEofToken.cs │ │ │ └── DeleteTrailingWhitespace.cs │ │ ├── Options │ │ │ ├── OptionalRuleGroup.cs │ │ │ ├── GlobalOptions.cs │ │ │ ├── FormattingOptions.cs │ │ │ └── DisableableRules.cs │ │ ├── TextEditInfo.cs │ │ └── FormattingContext.cs │ ├── Text │ │ └── SourceTextLine.cs │ ├── Diagnostics │ │ ├── DiagnosticsProvider.cs │ │ └── IDiagnosticsProvider.cs │ ├── Shared │ │ └── Range.cs │ ├── ParseTreeCache.cs │ ├── LuaFeatureContainer.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SourceText.cs ├── ProjectLauncher │ ├── Key.snk │ ├── Resources │ │ ├── Images.png │ │ └── Package.ico │ ├── LuaDetour │ │ ├── LuaDebug32.dll │ │ └── LuaDetours.dll │ ├── PkgCmdIDList.cs │ ├── GuidList.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── source.extension.vsixmanifest │ ├── LaunchForm.cs │ ├── LuaLanguageServiceThemes.pkgdef │ └── Resources.Designer.cs ├── LuaDebuggerLauncher │ ├── tools │ │ ├── Xaml2Cs.exe │ │ └── CommonProjectSystemExtension.props │ ├── [PlatformName] │ │ ├── ImportBefore │ │ │ └── Lua.props │ │ └── ImportAfter │ │ │ ├── Lua.targets │ │ │ └── LuaDebugger.xaml │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── source.extension.vsixmanifest │ └── RuleProperties.cs ├── Directory.Build.props ├── stylecop.json ├── version.json ├── Microsoft.VisualStudio.Debugger.Lua │ ├── AD7.Impl │ │ ├── EngineConstants.cs │ │ ├── AD7Expression.cs │ │ └── AD7MemoryAddress.cs │ ├── Variable.cs │ ├── Frame.cs │ ├── Commands.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── EngineRegistration.pkgdef │ ├── Engine.Impl │ │ ├── EngineUtils.cs │ │ └── BreakpointManager.cs │ ├── DLLInjector.cs │ └── AD7.Definitions │ │ └── AD7Guids.cs └── Formatting.Tests │ ├── Properties │ └── AssemblyInfo.cs │ └── FormatRulesAndIndentation │ ├── MixedTests.cs │ ├── ForLoopTests.cs │ ├── DotColonTests.cs │ └── TrailingWhitespaceTests.cs ├── images ├── colorization.png ├── intelliSense.png └── errorsquiggles.png ├── nuget.config ├── appveyor.yml ├── license.txt ├── CONTRIBUTING.md ├── README.md └── .gitattributes /src/LanguageModel.Tests/CorrectSampleLuaFiles/concat.lua: -------------------------------------------------------------------------------- 1 | .. -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/tabs.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/assignment.lua: -------------------------------------------------------------------------------- 1 | x = 0 -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/SemiColonStatement.lua: -------------------------------------------------------------------------------- 1 | ; -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/longcomment.lua: -------------------------------------------------------------------------------- 1 | x --[[comment]] -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/AssignmentForIORead.lua: -------------------------------------------------------------------------------- 1 | a = io.read("*number") -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/BreakIfStatement.lua: -------------------------------------------------------------------------------- 1 | if a[i] == v then break end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/FunctionCallStatement.lua: -------------------------------------------------------------------------------- 1 | runSampleTest(true, 5) -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/test.lua: -------------------------------------------------------------------------------- 1 | end 2 | 3 | --98098098 4 | x = 5 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/trivia1.lua: -------------------------------------------------------------------------------- 1 | x 2 | 3 | 4 | x -------------------------------------------------------------------------------- /src/LuaVSHost/ClassDiagram1.cd: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/LuaVSHost/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/LuaVSHost/Key.snk -------------------------------------------------------------------------------- /images/colorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/images/colorization.png -------------------------------------------------------------------------------- /images/intelliSense.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/images/intelliSense.png -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/EquivalentAssignmentWithNewLine2.lua: -------------------------------------------------------------------------------- 1 | a = 1 b = a*2 -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/MultipleTypeAssignment.lua: -------------------------------------------------------------------------------- 1 | x,y,var = "string", 4, {} -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/NestedFunctionCallStatement.lua: -------------------------------------------------------------------------------- 1 | print(type(10.4*3)) -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/TripleNestedFunctionCall.lua: -------------------------------------------------------------------------------- 1 | print(type(type(X))) -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/newlines.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/smallif.lua: -------------------------------------------------------------------------------- 1 | if true == "+" then 2 | run(); 3 | end -------------------------------------------------------------------------------- /images/errorsquiggles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/images/errorsquiggles.png -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/EquivalentAssignmentWithNewLine1.lua: -------------------------------------------------------------------------------- 1 | a = 1 2 | b = a*2 -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/FunctionDefError.lua: -------------------------------------------------------------------------------- 1 | foo = function 2 | return 3 | end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/IfStatement.lua: -------------------------------------------------------------------------------- 1 | if op == "+" then 2 | r = a + b 3 | end -------------------------------------------------------------------------------- /src/LanguageModel/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/LanguageModel/Key.snk -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/GenericForStatement.lua: -------------------------------------------------------------------------------- 1 | for i,v in ipairs(a) do print(v) end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/StringConcat.lua: -------------------------------------------------------------------------------- 1 | print("Hello " .. "World") --> Hello World -------------------------------------------------------------------------------- /src/ProjectLauncher/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/ProjectLauncher/Key.snk -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/AssignmentWithFunctionCall.lua: -------------------------------------------------------------------------------- 1 | b = string.gsub(a, "one", "another") -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/FunctionCallChainingStatement.lua: -------------------------------------------------------------------------------- 1 | prefixExp():runSampleTest(true, 5) -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/ReturnStatementInFunction.lua: -------------------------------------------------------------------------------- 1 | function foo () 2 | return; 3 | end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/FunctionCallWithStringLiteral.lua: -------------------------------------------------------------------------------- 1 | print [[a multi-line 2 | message]] -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/Assignments.lua: -------------------------------------------------------------------------------- 1 | a = "hello" .. "world" 2 | t.n = t.n + 1 3 | a, b = 10, 2*x -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/ForInStatement.lua: -------------------------------------------------------------------------------- 1 | for i, v in ipairs(a) do 2 | print(i, v) 3 | end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/FunctionCallWithTableConstructor.lua: -------------------------------------------------------------------------------- 1 | rename{old="temp.lua", new="temp1.lua"} -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/RepeatStatement.lua: -------------------------------------------------------------------------------- 1 | repeat 2 | line = os.read() 3 | until line ~= "" 4 | -------------------------------------------------------------------------------- /src/LuaVSHost/Resources/Lua.Host.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/LuaVSHost/Resources/Lua.Host.ico -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/MultipleReturnIf.lua: -------------------------------------------------------------------------------- 1 | if t[i] ~= nil then 2 | return t[i], unpack(t, i + 1) 3 | end -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/tools/Xaml2Cs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/LuaDebuggerLauncher/tools/Xaml2Cs.exe -------------------------------------------------------------------------------- /src/ProjectLauncher/Resources/Images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/ProjectLauncher/Resources/Images.png -------------------------------------------------------------------------------- /src/ProjectLauncher/Resources/Package.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/ProjectLauncher/Resources/Package.ico -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/WhileStatement.lua: -------------------------------------------------------------------------------- 1 | local i = 1 2 | while a[i] do 3 | print(a[i]) 4 | i = i + 1 5 | end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/IfElse.lua: -------------------------------------------------------------------------------- 1 | if op == "+" then 2 | r = a + b 3 | else 4 | error("invalid operation") 5 | end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/IfElseIf.lua: -------------------------------------------------------------------------------- 1 | if op == "+" then 2 | r = a + b 3 | elseif op == "-" then 4 | r = a - b 5 | end -------------------------------------------------------------------------------- /src/LuaVSHost/LuaLanguageServicePackage.pkgdef: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/LuaVSHost/LuaLanguageServicePackage.pkgdef -------------------------------------------------------------------------------- /src/ProjectLauncher/LuaDetour/LuaDebug32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/ProjectLauncher/LuaDetour/LuaDebug32.dll -------------------------------------------------------------------------------- /src/ProjectLauncher/LuaDetour/LuaDetours.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/VSLua/HEAD/src/ProjectLauncher/LuaDetour/LuaDetours.dll -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/FunctionAssignment.lua: -------------------------------------------------------------------------------- 1 | local fact 2 | fact = function (n) 3 | if n == 0 then return 1 4 | end end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/ComplexTableConstructor.lua: -------------------------------------------------------------------------------- 1 | y = {x=10, ["x"]=0, y=45; "one", print("hello world"), [3] = {x=10}, "two", "three"} -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/LocalAssignments.lua: -------------------------------------------------------------------------------- 1 | local a2 = 2*a 2 | local d = sqrt(b^2 - 4*a*c) 3 | local x1 = (-b + d)/a2 4 | local f = 10 -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/TailCall.lua: -------------------------------------------------------------------------------- 1 | function room3 () 2 | local move = io.read() 3 | if move == "north" then return room1() 4 | end 5 | end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/ForStatements.lua: -------------------------------------------------------------------------------- 1 | for var=exp1,exp2,exp3 do 2 | something(); 3 | end 4 | 5 | for i=1,f(x) do print(i) end 6 | 7 | for i=10,1,-1 do print(i) end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/NestedTableConstructor.lua: -------------------------------------------------------------------------------- 1 | network = { 2 | {name = "grauna", IP = "210.26.30.34"}, 3 | {name = "arraial", IP = "210.26.30.23"}, 4 | } -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/leveled_blocks.lua: -------------------------------------------------------------------------------- 1 | x = [==========[leveled string]==========] 2 | y = [[adsf 3 | asf]] 4 | z = [= unfinished 5 | y = [==========================[ onesided! 6 | ds -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/tools/CommonProjectSystemExtension.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/VarArgFunction.lua: -------------------------------------------------------------------------------- 1 | function fwrite (fmt, ...) 2 | return io.write(string.format(fmt, unpack(arg))) 3 | end 4 | 5 | function print (...) 6 | print(""); 7 | end 8 | 9 | function g (a, b, ...) end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/ForStatementWithVariables.lua: -------------------------------------------------------------------------------- 1 | for var=exp1,exp2,exp3 do 2 | something(); 3 | end 4 | 5 | for i=1,f(x) do print(i) end 6 | 7 | for i=10,1,-1 do print(i) end 8 | 9 | for i=f(true),1 do print(i) end -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/NestedFunctionDef.lua: -------------------------------------------------------------------------------- 1 | function digitButton (digit) 2 | return Button{ label = digit, 3 | action = function () 4 | add_to_display(digit) 5 | end 6 | } 7 | end -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "documentationRules": { 5 | "companyName": "Microsoft", 6 | "xmlHeader": false 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ProjectLauncher/PkgCmdIDList.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace ProjectLauncher 4 | { 5 | using System; 6 | 7 | /// 8 | /// MUST match PkgCmdID.h 9 | /// 10 | internal static class PkgCmdIDList 11 | { 12 | public const uint cmdidProjectLauncher = 0x100; 13 | } 14 | } -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/ComplexFunctionCall.lua: -------------------------------------------------------------------------------- 1 | _Window(options.title, 2 | options.x or 0, -- default value 3 | options.y or 0, -- default value 4 | options.width, options.height, 5 | options.background or "white", -- default 6 | options.border -- default is false (nil) 7 | ) -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/[PlatformName]/ImportBefore/Lua.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LuaDebugger 5 | 6 | -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/[PlatformName]/ImportAfter/Lua.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/InvalidProgramsMemoryException.lua: -------------------------------------------------------------------------------- 1 | " 2 | x, 3 | y = 1,2" 4 | 5 | 6 | "x,y = 1,2" 7 | "function foo(x,y,z)" 8 | 9 | "{ x, y,}" 10 | 11 | "x,y" 12 | 13 | " 14 | x 15 | 16 | x " 17 | 18 | " 19 | x = 10 20 | -- comment here 21 | --[[ block 22 | comment 23 | here]] 24 | x = x + 1 " 25 | 26 | "x 27 | " -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/TableStatements.lua: -------------------------------------------------------------------------------- 1 | a = {} -- create a table and store its reference in `a' 2 | k = "x" 3 | a[k] = 10 -- new entry, with key="x" and value=10 4 | a[20] = "great" -- new entry, with key=20 and value="great" 5 | print(a["x"]) --> 10 6 | k = 20 7 | print(a[k]) --> "great" 8 | a["x"] = a["x"] + 1 -- increments entry "x" 9 | print(a["x"]) --> 11 -------------------------------------------------------------------------------- /src/LuaVSHost/Errors/ErrorListItem.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Shell; 2 | using Microsoft.VisualStudio.Text; 3 | 4 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Errors 5 | { 6 | internal class ErrorListItem : ErrorTask 7 | { 8 | public ErrorListItem(SnapshotSpan errorSpan) 9 | { 10 | this.ErrorSpan = errorSpan; 11 | } 12 | 13 | public SnapshotSpan ErrorSpan { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/version.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", 3 | "version": "1.1", 4 | "publicReleaseRefSpec": [ 5 | "^refs/heads/master$", // we release out of master 6 | "^refs/heads/v\\d+(?:\\.\\d+)?$" // we also release out of vNN branches 7 | ], 8 | "cloudBuild": { 9 | "buildNumber": { 10 | "enabled": true 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/nestedif.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | if true == "+" then 4 | test; 5 | if false .. "+" then 6 | if(yolo) or hello then 7 | run(); 8 | end 9 | elseif 345 then 10 | lol = true; 11 | end 12 | end 13 | end 14 | 15 | if plusString | "+" then --testcomment 16 | if (test) and {[hello] = world ;[test] = 5, me = "Kevin"} then 17 | main(); 18 | else 19 | 20 | end 21 | return true; 22 | end -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/AD7.Impl/EngineConstants.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.VisualStudio.Debugger.Lua 2 | { 3 | public static class EngineConstants 4 | { 5 | /// 6 | /// This is the engine GUID of the sample engine. It needs to be changed here and in EngineRegistration.pkgdef 7 | /// when turning the sample into a real engine. 8 | /// 9 | public const string EngineId = "{FE72992A-F091-45CA-B9C6-B653D374AA61}"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/LanguageModel/LanguageModel/ParseContexts.cs: -------------------------------------------------------------------------------- 1 | namespace LanguageService 2 | { 3 | public enum ParsingContext 4 | { 5 | IfBlock, 6 | ChunkNodeBlock, 7 | ElseBlock, 8 | ElseIfBlock, 9 | DoStatementBlock, 10 | WhileBlock, 11 | RepeatStatementBlock, 12 | ForStatementBlock, 13 | FuncBodyBlock, 14 | ExpList, 15 | NameList, 16 | VarList, 17 | FieldList, 18 | FuncNameDotSeperatedNameList, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/if.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | if op == "+" then 4 | r = a + b 5 | elseif op == "-" then 6 | r = a - b 7 | originRoom:removeWall(WEST); 8 | Generator.maze:GetValue(coordinates.x - 1, coordinates.y):removeWall(EAST) 9 | elseif op == "*" then 10 | r = a*b 11 | elseif op == "/" then 12 | 13 | Generator.maze:GetValue(coordinates.x - 1, coordinates.y):removeWall(EAST) 14 | 15 | r = a/b 16 | else 17 | error("invalid operation") 18 | end 19 | 20 | --98098098 21 | x = 0 -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/BaseDialogPage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using Microsoft.VisualStudio.Shell; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages 6 | { 7 | internal abstract class BaseDialogPage : UIElementDialogPage 8 | { 9 | public override object AutomationObject 10 | { 11 | get 12 | { 13 | return UserSettings.MainInstance; 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/ICore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using LanguageService; 3 | using Microsoft.VisualStudio.Editor; 4 | 5 | namespace Microsoft.VisualStudio.LuaLanguageService.Shared 6 | { 7 | internal interface ICore 8 | { 9 | GlobalEditorOptions GlobalEditorOptions { get; } 10 | IServiceProvider ServiceProvider { get; } 11 | IVsEditorAdaptersFactoryService EditorAdaptersFactory { get; } 12 | SourceTextCache SourceTextCache { get; } 13 | LuaFeatureContainer FeatureContainer { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/longs.lua: -------------------------------------------------------------------------------- 1 | ThisIsAVeryLongIdentifierNameItsSoLongThatItsSoLongICantThinkNowIAmTryingToMakeThisEqualToTenOrSomethingBecauseThatWillBeAwesome 2 | 12398193048193480123840918340918309481903480138409183094810934809138409183094810934810983409183049810923480193840918340918230948 3 | [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] 4 | "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pulvinar ex in posuere malesuada. Vestibulum ante ipsum primis." -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/UserControls/GeneralUserControl.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Windows.Controls; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages.UserControls 6 | { 7 | /// 8 | /// Interaction logic for GeneralUserControl.xaml 9 | /// 10 | public partial class GeneralUserControl : UserControl 11 | { 12 | public GeneralUserControl() 13 | { 14 | this.InitializeComponent(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/UserControls/SpacingUserControl.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Windows.Controls; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages.UserControls 6 | { 7 | /// 8 | /// Interaction logic for SpacingUserControl.xaml 9 | /// 10 | public partial class SpacingUserControl : UserControl 11 | { 12 | public SpacingUserControl() 13 | { 14 | this.InitializeComponent(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/LanguageModel/Classification/TagInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageService.Classification 4 | { 5 | public class TagInfo 6 | { 7 | internal TagInfo(int start, int length, Classification classification) 8 | { 9 | this.Start = start; 10 | this.Length = length; 11 | this.Classification = classification; 12 | } 13 | 14 | public int Start { get; } 15 | 16 | public int Length { get; } 17 | 18 | public Classification Classification { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ProjectLauncher/GuidList.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace ProjectLauncher 4 | { 5 | using System; 6 | 7 | /// 8 | /// MUST match guids.h 9 | /// 10 | internal static class GuidList 11 | { 12 | public const string guidProjectLauncherPkgString = "933a507d-7abd-4a75-b906-895d8cc0616e"; 13 | public const string guidProjectLauncherCmdSetString = "3ebc3be9-5f46-4b77-a2a3-73cfeb1a8791"; 14 | 15 | public static readonly Guid guidProjectLauncherCmdSet = new Guid(guidProjectLauncherCmdSetString); 16 | } 17 | } -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/UserControls/WrappingAndNewLineUserControl.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Windows.Controls; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages.UserControls 6 | { 7 | /// 8 | /// Interaction logic for WrappingAndNewLineUserControl.xaml 9 | /// 10 | public partial class WrappingAndNewLineUserControl : UserControl 11 | { 12 | public WrappingAndNewLineUserControl() 13 | { 14 | this.InitializeComponent(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/LuaVSHost/Navigation/IDocumentOperations.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Shell.Interop; 2 | using Microsoft.VisualStudio.Text; 3 | using Microsoft.VisualStudio.Text.Editor; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 6 | { 7 | internal interface IDocumentOperations 8 | { 9 | bool OpenDocument(string path, out bool isAlreadyOpen, out IWpfTextView textView); 10 | void NavigateTo(IWpfTextView textView, Span span, bool selectSpan, bool deferNavigationWithOutlining); 11 | bool GetAlreadyOpenedDocument(string path, out IVsWindowFrame windowFrame); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/RuleOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using Validation; 4 | 5 | namespace LanguageService.Formatting.Ruling 6 | { 7 | internal class RuleOperation 8 | { 9 | internal RuleOperationContext Context { get; } 10 | 11 | internal RuleAction Action { get; } 12 | 13 | internal RuleOperation(RuleOperationContext context, RuleAction action) 14 | { 15 | Requires.NotNull(context, nameof(context)); 16 | 17 | this.Action = action; 18 | this.Context = context; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/EmptyProgram_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class EmptyProgram_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | t.N(SyntaxKind.EndOfFile); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | branches: 3 | only: 4 | - master 5 | - /^v\d+(?:\.\d+)?$/ 6 | - /[\b_]validate\b/ 7 | skip_tags: true 8 | nuget: 9 | disable_publish_on_pr: true 10 | image: Visual Studio 2017 11 | environment: 12 | VisualStudioVersion: 15.0 13 | DeployExtension: false 14 | configuration: Release 15 | before_build: 16 | - ps: nuget restore src -Verbosity quiet 17 | build: 18 | verbosity: minimal 19 | test: off 20 | artifacts: 21 | - path: bin\Release\Microsoft.VisualStudio.LanguageServices.Lua.vsix 22 | name: Lua Language service 23 | - path: bin\%configuration%\LuaDebuggerLauncher.vsix 24 | name: Lua Debugger launcher 25 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/Rule.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace LanguageService.Formatting.Ruling 6 | { 7 | internal abstract class Rule 8 | { 9 | internal abstract RuleDescriptor RuleDescriptor { get; } 10 | 11 | internal abstract RuleOperation RuleOperationContext { get; } 12 | 13 | internal abstract bool AppliesTo(FormattingContext formattingContext); 14 | 15 | internal abstract IEnumerable Apply(FormattingContext formattingContext); 16 | 17 | internal abstract Rule Inverse { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/LanguageModel/LanguageModel/ParseError.cs: -------------------------------------------------------------------------------- 1 | using Validation; 2 | 3 | namespace LanguageService 4 | { 5 | public class ParseError 6 | { 7 | public ParseError(string message, int start, int end) 8 | { 9 | Requires.NotNull(message, nameof(message)); 10 | 11 | this.Message = message; 12 | this.Start = start; 13 | this.End = end; 14 | } 15 | 16 | public string Message { get; } 17 | public int Start { get; } 18 | public int End { get; } 19 | 20 | public int Length 21 | { 22 | get { return this.End - this.Start; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/ContentTypes.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using Microsoft.VisualStudio.Utilities; 3 | 4 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 5 | { 6 | internal static class ContentTypes 7 | { 8 | [Export] 9 | [Name(Constants.Language.Name)] 10 | [BaseDefinition("code")] 11 | internal static ContentTypeDefinition ContentType { get; set; } 12 | 13 | [Export] 14 | [FileExtension(Constants.Language.FileExtension)] 15 | [ContentType(Constants.Language.Name)] 16 | internal static FileExtensionToContentTypeDefinition LuaContentTypeExtensionDefinition { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/LuaVSHost/LuaLanguageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Microsoft.VisualStudio.LuaLanguageService.Shared; 4 | 5 | namespace Microsoft.VisualStudio.LuaLanguageService 6 | { 7 | [Guid(Guids.ServiceString)] 8 | public sealed class LuaLanguageService : IServiceProvider 9 | { 10 | private IServiceProvider serviceProvider; 11 | 12 | public object GetService(Type serviceType) 13 | { 14 | return serviceProvider != null ? serviceProvider.GetService(serviceType) : null; 15 | } 16 | 17 | public LuaLanguageService(IServiceProvider serviceProvider) 18 | { 19 | this.serviceProvider = serviceProvider; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/LuaVSHost/LuaContentTypes.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Utilities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.Composition; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using VSLua.Shared; 9 | 10 | namespace VSLua 11 | { 12 | internal static class LuaContentTypes 13 | { 14 | [Export] 15 | [Name(Constants.LuaLanguageName)] 16 | [BaseDefinition("code")] 17 | internal static ContentTypeDefinition LuaContentType; 18 | 19 | [Export] 20 | [FileExtension(Constants.LuaFileExtension)] 21 | [ContentType(Constants.LuaLanguageName)] 22 | internal static FileExtensionToContentTypeDefinition LuaContentTypeExtensionDefintion; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Options/OptionalRuleGroup.cs: -------------------------------------------------------------------------------- 1 | namespace LanguageService.Formatting.Options 2 | { 3 | public enum OptionalRuleGroup 4 | { 5 | WrappingOneLineForFors, 6 | WrappingOneLineForFunctions, 7 | WrappingOneLineForTableConstructors, 8 | WrappingMoreLinesForTableConstructors, 9 | SpaceBeforeOpenParenthesis, 10 | SpaceOnInsideOfParenthesis, 11 | SpaceOnInsideOfCurlyBraces, 12 | SpaceOnInsideOfSquareBrackets, 13 | SpaceAfterCommas, 14 | SpaceBeforeAndAfterBinaryOperations, 15 | SpaceBeforeAndAfterAssignmentForField, 16 | SpaceBeforeAndAfterAssignmentForStatement, 17 | SpaceBeforeAndAfterAssignmentInForLoopHeader, 18 | NoSpaceBeforeAndAfterIndiciesInForLoopHeader 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/LanguageModel/Text/SourceTextLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace LanguageService.Text 9 | { 10 | public class SourceTextLine 11 | { 12 | internal SourceTextLine(string text, int start, int length) 13 | { 14 | this.Text = text; 15 | this.Start = start; 16 | this.Length = length; 17 | this.End = start + length; 18 | } 19 | 20 | public string Text { get; } 21 | 22 | public int Start { get; } 23 | 24 | public int Length { get; } 25 | 26 | public int End { get; } 27 | 28 | public TextReader TextReader => new StringReader(this.Text); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/LanguageModel/Diagnostics/DiagnosticsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Validation; 3 | 4 | namespace LanguageService.Diagnostics 5 | { 6 | internal class DiagnosticsProvider : IDiagnosticsProvider 7 | { 8 | private ParseTreeCache parseTreeCache; 9 | 10 | public DiagnosticsProvider(ParseTreeCache parseTreeCache) 11 | { 12 | Requires.NotNull(parseTreeCache, nameof(parseTreeCache)); 13 | 14 | this.parseTreeCache = parseTreeCache; 15 | } 16 | 17 | public IReadOnlyList GetDiagnostics(SourceText sourceText) 18 | { 19 | Requires.NotNull(sourceText, nameof(sourceText)); 20 | 21 | SyntaxTree syntaxTree = this.parseTreeCache.Get(sourceText); 22 | 23 | return syntaxTree.ErrorList; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/Variable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.VisualStudio.Debugger.Lua 8 | { 9 | public class Variable 10 | { 11 | public Variable(string name, string value, string type) 12 | { 13 | this.Name = name; 14 | this.Value = value; 15 | this.Type = type; 16 | } 17 | 18 | public string Name { get; private set; } 19 | 20 | public string Value { get; private set; } 21 | 22 | public string Type { get; private set; } 23 | 24 | public List Children { get; private set; } 25 | 26 | public bool HasChildren() 27 | { 28 | return Children.Count > 0; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/27_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\SemiColonStatement.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_27 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.SemiColonStatementNode); 18 | { 19 | t.N(SyntaxKind.Semicolon); 20 | } 21 | } 22 | t.N(SyntaxKind.EndOfFile); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/LanguageModel/Shared/Range.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageService.Shared 4 | { 5 | /// 6 | /// Species a number range 7 | /// 8 | public struct Range 9 | { 10 | /// 11 | /// Specifies a number range 12 | /// 13 | /// The start index 14 | /// The end index, must be equal or 15 | /// greater than 16 | public Range(int start, int length) 17 | { 18 | this.Start = start; 19 | this.Length = length; 20 | this.End = start + length; 21 | } 22 | 23 | public int Start { get; } 24 | 25 | public int End { get; } 26 | 27 | public int Length { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/Frame.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.VisualStudio.Debugger.Lua 8 | { 9 | internal class Frame 10 | { 11 | private string m_func; 12 | private string m_src; 13 | private string m_line; 14 | 15 | public Frame(string funcName, string src, string line) 16 | { 17 | m_func = funcName; 18 | m_src = src; 19 | m_line = line; 20 | } 21 | 22 | public string GetFunc() 23 | { 24 | return m_func; 25 | } 26 | 27 | public string GetSource() 28 | { 29 | return m_src; 30 | } 31 | 32 | public string GetLine() 33 | { 34 | return m_line; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/RuleAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageService.Formatting.Ruling 4 | { 5 | /// 6 | /// The set of enumerables that describes all the possible Rule actions 7 | /// 8 | internal enum RuleAction 9 | { 10 | /// 11 | /// Action that enforces one space between tokens 12 | /// 13 | Space, 14 | 15 | /// 16 | /// Action that removes spaces between tokens 17 | /// 18 | Delete, 19 | 20 | /// 21 | /// Action that inserts a newline between tokens 22 | /// 23 | Newline, 24 | 25 | /// 26 | /// Action that enforces nothing is done 27 | /// 28 | Ignore // <- Might not be needed 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/LanguageModel/ParseTreeCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Runtime.CompilerServices; 4 | using Validation; 5 | 6 | namespace LanguageService 7 | { 8 | public class ParseTreeCache 9 | { 10 | private readonly ConditionalWeakTable sources = 11 | new ConditionalWeakTable(); 12 | 13 | public SyntaxTree Get(SourceText sourceText) 14 | { 15 | Requires.NotNull(sourceText, nameof(sourceText)); 16 | 17 | SyntaxTree syntaxTree; 18 | if (this.sources.TryGetValue(sourceText, out syntaxTree)) 19 | { 20 | return syntaxTree; 21 | } 22 | 23 | syntaxTree = Parser.Parse(sourceText.TextReader); 24 | this.sources.Add(sourceText, syntaxTree); 25 | 26 | return syntaxTree; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/LuaVSHost/Intellisense/CompletionSourceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using Microsoft.VisualStudio.Language.Intellisense; 4 | using Microsoft.VisualStudio.Shell; 5 | using Microsoft.VisualStudio.Text; 6 | using Microsoft.VisualStudio.Text.Operations; 7 | using Microsoft.VisualStudio.Utilities; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Intellisense 10 | { 11 | [Export(typeof(ICompletionSourceProvider))] 12 | [ContentType("lua")] 13 | [Name("token completion")] 14 | internal class CompletionSourceProvider : ICompletionSourceProvider 15 | { 16 | [Import] 17 | internal ITextStructureNavigatorSelectorService NavigatorService { get; set; } 18 | public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer) 19 | { 20 | return new CompletionSource(this, textBuffer); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ProjectLauncher/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Resources; 6 | using System.Runtime.CompilerServices; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("ProjectLauncher")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("Microsoft")] 16 | [assembly: AssemblyProduct("ProjectLauncher")] 17 | [assembly: AssemblyCopyright("Copyright © Microsoft")] 18 | [assembly: AssemblyTrademark("Copyright © Microsoft")] 19 | [assembly: AssemblyCulture("")] 20 | [assembly: ComVisible(false)] 21 | [assembly: CLSCompliant(false)] 22 | [assembly: NeutralResourcesLanguage("en-US")] 23 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/ISingletons.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using LanguageService; 3 | using Microsoft.VisualStudio.Editor; 4 | using Microsoft.VisualStudio.LanguageServices.Lua.Classifications; 5 | using Microsoft.VisualStudio.LanguageServices.Lua.Formatting; 6 | using Microsoft.VisualStudio.LanguageServices.Lua.Text; 7 | using Microsoft.VisualStudio.Text.Operations; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 10 | { 11 | internal interface ISingletons 12 | { 13 | IDocumentOperations DocumentOperations { get; } 14 | 15 | IEditorOperationsFactoryService EditorOperationsFactory { get; } 16 | 17 | IVsEditorAdaptersFactoryService EditorAdaptersFactory { get; } 18 | 19 | LuaFeatureContainer FeatureContainer { get; } 20 | 21 | UserSettings FormattingUserSettings { get; } 22 | 23 | IServiceProvider ServiceProvider { get; } 24 | 25 | SourceTextCache SourceTextCache { get; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/RuleBucket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace LanguageService.Formatting.Ruling 6 | { 7 | internal class RuleBucket 8 | { 9 | private List rules; 10 | 11 | // This methods is here for when I need to add precedence to the rules 12 | internal void Add(Rule rule) 13 | { 14 | if (this.rules == null) 15 | { 16 | this.rules = new List(); 17 | } 18 | 19 | this.rules.Add(rule); 20 | } 21 | 22 | internal Rule Get(FormattingContext formattingContext) 23 | { 24 | foreach (Rule rule in this.rules) 25 | { 26 | if (rule.AppliesTo(formattingContext)) 27 | { 28 | return rule; 29 | } 30 | } 31 | 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/SmartIndentation/SmartIndentProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 7 | using Microsoft.VisualStudio.Text.Editor; 8 | using Microsoft.VisualStudio.Utilities; 9 | 10 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.SmartIndentation 11 | { 12 | [Export(typeof(ISmartIndentProvider))] 13 | [ContentType(Constants.Language.Name)] 14 | [Name("LuaSmartIndentation")] 15 | internal class SmartIndentProvider : ISmartIndentProvider 16 | { 17 | #pragma warning disable 0169, 0649 18 | [Import] 19 | private ISingletons singletons; 20 | #pragma warning restore 0169, 0649 21 | 22 | public ISmartIndent CreateSmartIndent(ITextView textView) 23 | { 24 | return new SmartIndent(textView, this.singletons); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("LuaDebuggerLauncher")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("LuaDebuggerLauncher")] 15 | [assembly: AssemblyCopyright("")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Options/GlobalOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | using Validation; 3 | 4 | namespace LanguageService.Formatting.Options 5 | { 6 | 7 | internal class GlobalOptions 8 | { 9 | internal GlobalOptions(NewOptions options) 10 | { 11 | Requires.NotNull(options, nameof(options)); 12 | this.IndentSize = options.IndentSize; 13 | this.TabSize = options.TabSize; 14 | this.UsingTabs = options.UsingTabs; 15 | this.OptionalRuleMap = new OptionalRuleMap(options.RuleGroupsToDisable); 16 | } 17 | 18 | internal GlobalOptions() 19 | { 20 | IndentSize = 4; 21 | OptionalRuleMap = new OptionalRuleMap(ImmutableArray.Create()); 22 | } 23 | 24 | internal uint IndentSize { get; } 25 | internal uint TabSize { get; } 26 | internal bool UsingTabs { get; } 27 | internal OptionalRuleMap OptionalRuleMap { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/LuaVSHost/Errors/TaskExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Errors 5 | { 6 | internal static class TaskExtensions 7 | { 8 | internal static Task WithoutCancellation(this Task task) 9 | { 10 | Requires.NotNull(task, nameof(task)); 11 | 12 | var tcs = new TaskCompletionSource(); 13 | task.ContinueWith( 14 | t => 15 | { 16 | if (t.IsFaulted) 17 | { 18 | tcs.SetException(t.Exception); 19 | } 20 | else 21 | { 22 | tcs.SetResult(null); 23 | } 24 | }, 25 | CancellationToken.None, 26 | TaskContinuationOptions.ExecuteSynchronously, 27 | TaskScheduler.Default); 28 | 29 | return tcs.Task; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/RuleOperationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace LanguageService.Formatting.Ruling 7 | { 8 | internal class RuleOperationContext 9 | { 10 | private List> contextFilters; 11 | 12 | internal RuleOperationContext(List> contextFilters) 13 | { 14 | Validation.Requires.NotNull(contextFilters, nameof(contextFilters)); 15 | 16 | this.contextFilters = contextFilters; 17 | } 18 | 19 | internal bool InContext(FormattingContext formattingContext) 20 | { 21 | foreach (Func contextFilter in this.contextFilters) 22 | { 23 | if (!contextFilter(formattingContext)) 24 | { 25 | return false; 26 | } 27 | } 28 | 29 | return true; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/Commands.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.VisualStudio.Debugger.Lua 8 | { 9 | internal enum CommandKind 10 | { 11 | Breakpoint, 12 | Step, 13 | Continue, 14 | Detach, 15 | DebuggerEnvironmentReady 16 | } 17 | 18 | internal class Command 19 | { 20 | public CommandKind Kind { get; private set; } 21 | 22 | public Command(CommandKind command) 23 | { 24 | this.Kind = command; 25 | } 26 | } 27 | 28 | internal class BreakpointCommand : Command 29 | { 30 | public string File { get; private set; } 31 | public int LineNumber { get; private set; } 32 | 33 | public BreakpointCommand(string file, int lineNumber): base(CommandKind.Breakpoint) 34 | { 35 | this.File = file; 36 | this.LineNumber = lineNumber; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/GeneralPage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | using Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages.UserControls; 7 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages 10 | { 11 | [Guid(Guids.GeneralPageString)] 12 | internal class GeneralPage : BaseDialogPage 13 | { 14 | private GeneralUserControl generalUserControl; 15 | 16 | protected override UIElement Child 17 | { 18 | get 19 | { 20 | if (this.generalUserControl == null) 21 | { 22 | this.generalUserControl = new GeneralUserControl(); 23 | this.generalUserControl.DataContext = UserSettings.MainInstance; 24 | } 25 | 26 | return this.generalUserControl; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/SpacingPage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | using Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages.UserControls; 7 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages 10 | { 11 | [Guid(Guids.SpacingPageString)] 12 | internal class SpacingPage : BaseDialogPage 13 | { 14 | private SpacingUserControl spacingUserControl; 15 | 16 | protected override UIElement Child 17 | { 18 | get 19 | { 20 | if (this.spacingUserControl == null) 21 | { 22 | this.spacingUserControl = new SpacingUserControl(); 23 | this.spacingUserControl.DataContext = UserSettings.MainInstance; 24 | } 25 | 26 | return this.spacingUserControl; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/Tester.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.TestGeneration 4 | { 5 | using System.Collections.Generic; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class Tester 10 | { 11 | private IEnumerator treeEnumerator; 12 | 13 | public Tester(SyntaxTree actualTree) 14 | { 15 | this.treeEnumerator = actualTree.Root.Descendants().GetEnumerator(); 16 | } 17 | 18 | public void N(SyntaxKind kind) 19 | { 20 | this.treeEnumerator.MoveNext(); 21 | //TODO remove is-check once Immutable graph object bug is fixed. 22 | if (this.treeEnumerator.Current is SyntaxNode) 23 | { 24 | Assert.Equal(kind, ((SyntaxNode)this.treeEnumerator.Current).Kind); 25 | } 26 | else 27 | { 28 | Assert.Equal(kind, ((Token)this.treeEnumerator.Current).Kind); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/LanguageModel/Diagnostics/IDiagnosticsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace LanguageService.Diagnostics 4 | { 5 | /// 6 | /// The diagnostics interface that provides access to any diagnostics messages 7 | /// gathered by the language model or associated analyzers. 8 | /// 9 | public interface IDiagnosticsProvider 10 | { 11 | /// 12 | /// Gets the diagnostics for a given . These messages 13 | /// may be generated from different sources, but are aggregated through this method. 14 | /// At the moment, this list contains only parse errors (and the return type is constrained 15 | /// to parse errors, though it would be made a generic 'Message' in the future). 16 | /// 17 | /// The source text to analyze and return messages for 18 | /// The diagnostics for a given 19 | IReadOnlyList GetDiagnostics(SourceText sourceText); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/Guids.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 5 | { 6 | internal sealed class Guids 7 | { 8 | internal const string PackageString = "40c3d121-7e37-4d03-a9f8-f10bca9805f3"; 9 | 10 | [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")] 11 | internal static readonly Guid Package = new Guid(PackageString); 12 | 13 | internal const string ServiceString = "88A1F488-9D00-4896-A255-6F8251208B90"; 14 | 15 | [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")] 16 | internal static readonly Guid Service = new Guid(ServiceString); 17 | 18 | internal const string GeneralPageString = "9CA639C0-CFC8-4583-95CE-D35E97940788"; 19 | internal const string SpacingPageString = "59E82B53-EC56-4EE0-A682-EF331109BA09"; 20 | internal const string WrappingAndNewLinePageString = "45482116-B8FB-46E7-A51D-518FCE83B626"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Visual Studio Extension for Lua 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | All rights reserved. 6 | 7 | MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | -------------------------------------------------------------------------------- /src/LuaVSHost/Text/SourceTextCache.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using LanguageService; 3 | using Microsoft.VisualStudio.Text; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Text 6 | { 7 | /// 8 | /// This class will be changed to non-static once I merge this branch with the branch that has the Core class that 9 | /// holds everything. 10 | /// 11 | internal class SourceTextCache 12 | { 13 | internal SourceText Get(ITextSnapshot textSnapshot) 14 | { 15 | Requires.NotNull(textSnapshot, nameof(textSnapshot)); 16 | 17 | SourceText sourceText = null; 18 | if (this.sources.TryGetValue(textSnapshot, out sourceText)) 19 | { 20 | return sourceText; 21 | } 22 | 23 | sourceText = new SourceText(textSnapshot.GetText()); 24 | this.sources.Add(textSnapshot, sourceText); 25 | 26 | return sourceText; 27 | } 28 | 29 | private ConditionalWeakTable sources = 30 | new ConditionalWeakTable(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Formatting.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("Formatting.Tests")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Formatting.Tests")] 15 | [assembly: AssemblyCopyright("Copyright © 2015")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("7f9f1c86-159a-4189-a23c-6994a1a5d50d")] 26 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/13_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\FunctionCallWithStringLiteral.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_13 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.FunctionCallStatementNode); 18 | { 19 | t.N(SyntaxKind.NameVar); 20 | { 21 | t.N(SyntaxKind.Identifier); 22 | } 23 | t.N(SyntaxKind.StringArg); 24 | { 25 | t.N(SyntaxKind.String); 26 | } 27 | } 28 | } 29 | t.N(SyntaxKind.EndOfFile); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/WrappingAndNewLinePage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | using Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages.UserControls; 7 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages 10 | { 11 | [Guid(Guids.WrappingAndNewLinePageString)] 12 | internal class WrappingAndNewLinePage : BaseDialogPage 13 | { 14 | private WrappingAndNewLineUserControl wrappingAndNewLineUserControl; 15 | 16 | protected override UIElement Child 17 | { 18 | get 19 | { 20 | if (this.wrappingAndNewLineUserControl == null) 21 | { 22 | this.wrappingAndNewLineUserControl = new WrappingAndNewLineUserControl(); 23 | this.wrappingAndNewLineUserControl.DataContext = UserSettings.MainInstance; 24 | } 25 | 26 | return this.wrappingAndNewLineUserControl; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("LanguageModel.Tests")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("LanguageModel.Tests")] 15 | [assembly: AssemblyCopyright("Copyright © 2015")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("fd20d189-b281-4793-8940-ea9be9428d32")] 26 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/RuleDescriptor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Collections.Immutable; 4 | 5 | namespace LanguageService.Formatting.Ruling 6 | { 7 | internal class RuleDescriptor 8 | { 9 | internal RuleDescriptor(ImmutableArray tokenLeft, ImmutableArray tokenRight) 10 | { 11 | this.TokenRangeLeft = tokenLeft; 12 | this.TokenRangeRight = tokenRight; 13 | } 14 | 15 | internal RuleDescriptor(ImmutableArray tokenLeft, SyntaxKind tokenRight) : this(tokenLeft, ImmutableArray.Create(tokenRight)) 16 | { 17 | } 18 | 19 | internal RuleDescriptor(SyntaxKind tokenLeft, ImmutableArray tokenRight) : this(ImmutableArray.Create(tokenLeft), tokenRight) 20 | { 21 | } 22 | 23 | internal RuleDescriptor(SyntaxKind tokenLeft, SyntaxKind tokenRight) : this(ImmutableArray.Create(tokenLeft), ImmutableArray.Create(tokenRight)) 24 | { 25 | } 26 | 27 | internal ImmutableArray TokenRangeLeft { get; } 28 | 29 | internal ImmutableArray TokenRangeRight { get; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft Visual Studio Tools for Lua 5 | Microsoft 6 | 1.0 7 | Microsoft Visual Studio Tools for Lua 8 | 1033 9 | 10 | 11 | Community 12 | Enterprise 13 | 14 | 15 | 16 | 17 | 18 | 19 | |%CurrentProject%| 20 | |LuaLanguageServicePackage| 21 | |LanguageService| 22 | LuaLanguageServiceThemes.pkgdef 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Microsoft.VisualStudio.Debugger.SampleEngine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Microsoft.VisualStudio.Debugger.SampleEngine")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft")] 14 | [assembly: AssemblyTrademark("Copyright © Microsoft")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("42127a66-b150-42db-8ca0-a4f059e60e6e")] 24 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/IFormatter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting 4 | { 5 | internal interface IFormatter 6 | { 7 | /// 8 | /// Formats the entire document. 9 | /// 10 | void FormatDocument(); 11 | 12 | /// 13 | /// Formats the line based on the caret position. 14 | /// 15 | void FormatOnEnter(); 16 | 17 | /// 18 | /// Formats the selection made by the user. 19 | /// 20 | void FormatSelection(); 21 | 22 | #pragma warning disable SA1512, SA1515 // Single-line comments must not be followed/preceeded by blank line 23 | /// 24 | /// Formats the statenent made by the user. A statement as defined in the Formatting Functional Spec. 25 | /// 26 | 27 | // void FormatStatement(); 28 | 29 | /// 30 | /// Formats the pasted content. 31 | /// 32 | void FormatOnPaste(); 33 | #pragma warning restore SA1512, SA1515 // Single-line comments must not be followed/preceeded by blank line 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Formatting.Tests/FormatRulesAndIndentation/MixedTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Formatting.Tests 4 | { 5 | using Xunit; 6 | 7 | // Assumes all Rules are turned on, all with regular indentation... 8 | public class MixedTests 9 | { 10 | private delegate void TestFunction(string original, string expected1, string expected2); 11 | private TestFunction GeneralTest = Tester.FormattingTest; 12 | 13 | [Fact(Skip = "Not passing")] 14 | public void Basic() 15 | { 16 | string original = @" 17 | x= 1 18 | --this is an add function 19 | add = function(x, y) 20 | return x+y;--adding 21 | end 22 | 23 | 24 | get_zero = function() return 0 end"; 25 | string expected1 = @" 26 | x = 1 27 | -- this is an add function 28 | add = function( x, y ) 29 | return x + y 30 | ;-- adding 31 | end 32 | 33 | 34 | get_zero = function() 35 | return 0 36 | end"; 37 | string expected2 = @" 38 | x = 1 39 | -- this is an add function 40 | add = function ( x, y ) 41 | return x + y 42 | ; -- adding 43 | end 44 | 45 | 46 | get_zero = function() 47 | return 0 48 | end"; 49 | this.GeneralTest(original, expected1, expected2); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/LanguageModel/LuaFeatureContainer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using LanguageService.Classification; 4 | using LanguageService.Diagnostics; 5 | using LanguageService.Formatting; 6 | 7 | namespace LanguageService 8 | { 9 | /// 10 | /// Contains all the Lua language service features 11 | /// 12 | public sealed class LuaFeatureContainer 13 | { 14 | private ParseTreeCache parseTreeCache; 15 | 16 | public LuaFeatureContainer() 17 | { 18 | this.parseTreeCache = new ParseTreeCache(); 19 | this.Formatter = new Formatter(this.parseTreeCache); 20 | this.Colourizer = new Colourizer(this.parseTreeCache); 21 | this.DiagnosticsProvider = new DiagnosticsProvider(this.parseTreeCache); 22 | } 23 | 24 | public IDiagnosticsProvider DiagnosticsProvider { get; } 25 | 26 | /// 27 | /// Gets the Formatter object 28 | /// 29 | /// The Formatter 30 | public Formatter Formatter { get; } 31 | 32 | /// 33 | /// Gets the Colourizer object 34 | /// 35 | /// The Colourizer 36 | public Colourizer Colourizer { get; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/LuaVSHost/Classifications/LuaClassificationTypeDefinition.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 4 | using Microsoft.VisualStudio.Text.Classification; 5 | using Microsoft.VisualStudio.Utilities; 6 | 7 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Classifications 8 | { 9 | [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate")] 10 | internal class LuaClassificationTypeDefinition 11 | { 12 | [Export(typeof(ClassificationTypeDefinition))] 13 | [Name(Constants.Colourization.GlobalName), Export] 14 | internal ClassificationTypeDefinition Globals { get; set; } 15 | 16 | [Export(typeof(ClassificationTypeDefinition))] 17 | [Name(Constants.Colourization.LocalName), Export] 18 | internal ClassificationTypeDefinition Locals { get; set; } 19 | 20 | [Export(typeof(ClassificationTypeDefinition))] 21 | [Name(Constants.Colourization.ParamName), Export] 22 | internal ClassificationTypeDefinition LuaParams { get; set; } 23 | 24 | [Export(typeof(ClassificationTypeDefinition))] 25 | [Name(Constants.Colourization.FieldName), Export] 26 | internal ClassificationTypeDefinition Fields { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/TextEditInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using LanguageService.Shared; 4 | using Validation; 5 | 6 | namespace LanguageService.Formatting 7 | { 8 | public class TextEditInfo 9 | { 10 | internal TextEditInfo(Range range, string replaceWith) 11 | { 12 | Requires.NotNull(replaceWith, nameof(replaceWith)); 13 | 14 | this.Start = range.Start; 15 | this.Length = range.Length; 16 | this.ReplacingWith = replaceWith; 17 | } 18 | 19 | /// 20 | /// Gets the Start index of the text that is to be replaced. 21 | /// 22 | /// The start of the text for the replacing string 23 | public int Start { get; } 24 | 25 | /// 26 | /// Gets the length of the text from the start that is to be replaced. 27 | /// Length can be 0. 28 | /// 29 | /// The length of the text that is to be replaced 30 | public int Length { get; } 31 | 32 | /// 33 | /// Gets the string that will replace the text in question. 34 | /// 35 | /// The string that spaces the text in question 36 | public string ReplacingWith { get; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/LuaVSHost/Errors/ErrorTaggerProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using Microsoft.Internal.VisualStudio.Shell; 4 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 5 | using Microsoft.VisualStudio.Text; 6 | using Microsoft.VisualStudio.Text.Tagging; 7 | using Microsoft.VisualStudio.Utilities; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Errors 10 | { 11 | [Export(typeof(ITaggerProvider))] 12 | [TagType(typeof(ErrorTag))] 13 | [ContentType(Constants.Language.Name)] 14 | internal sealed class ErrorTaggerProvider : ITaggerProvider 15 | { 16 | [Import] 17 | private ISingletons singletons = null; 18 | 19 | public ITagger CreateTagger(ITextBuffer buffer) where T : ITag 20 | { 21 | Validate.IsNotNull(buffer, nameof(buffer)); 22 | 23 | Func errorTaggerCreator = () => 24 | { 25 | ErrorTagger tagger = new ErrorTagger(buffer, this.singletons); 26 | 27 | return tagger; 28 | }; 29 | 30 | // Taggers can be created for many reasons. In this case, it's fine to have a sinlge 31 | // tagger for a given buffer, so cache it on the buffer as a singleton property. 32 | return buffer.Properties.GetOrCreateSingletonProperty(errorTaggerCreator) as ITagger; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/EditorUtilities.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 4 | { 5 | using System; 6 | using Microsoft.VisualStudio.Text; 7 | 8 | internal static class EditorUtilities 9 | { 10 | internal static SnapshotSpan CreateSnapshotSpan(ITextSnapshot snapshot, int position, int length) 11 | { 12 | // Assume a bogus (negative) position to be at the end. 13 | if (position < 0) 14 | { 15 | position = snapshot.Length; 16 | } 17 | 18 | position = Math.Min(position, snapshot.Length); 19 | length = Math.Max(0, Math.Min(length, snapshot.Length - position)); 20 | 21 | return new SnapshotSpan(snapshot, position, length); 22 | } 23 | 24 | internal static SnapshotSpan? GetPasteSpan(ITextSnapshot prePasteSnapshot, ITextSnapshot postPasteSnapshot) 25 | { 26 | INormalizedTextChangeCollection changes = prePasteSnapshot.Version.Changes; 27 | if (changes != null && changes.Count > 0) 28 | { 29 | ITextChange firstChange = changes[0]; 30 | ITextChange lastChange = changes[changes.Count - 1]; 31 | 32 | SnapshotSpan newSpan = new SnapshotSpan(postPasteSnapshot, Span.FromBounds(firstChange.NewPosition, lastChange.NewEnd)); 33 | 34 | return newSpan; 35 | } 36 | 37 | return null; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/LanguageModel/LanguageModel/Trivia.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LanguageService 4 | { 5 | public class Trivia 6 | { 7 | public SyntaxKind Type { get; private set; } 8 | public string Text { get; private set; } 9 | 10 | public Trivia(SyntaxKind type, string trivia) 11 | { 12 | this.Type = type; 13 | this.Text = trivia; 14 | } 15 | 16 | public override string ToString() 17 | { 18 | return string.Format("{0},\t{1}", Enum.GetName(typeof(SyntaxKind), this.Type), this.ConvertStringToSymbols(this.Text)); 19 | } 20 | 21 | private string ConvertStringToSymbols(string s) //TODO: temp, just for testing 22 | { 23 | string new_string = ""; 24 | 25 | foreach (char c in s) 26 | { 27 | if (c == '\r') 28 | { 29 | new_string += "\\r"; 30 | } 31 | else if (c == '\n') 32 | { 33 | new_string += "\\n"; 34 | } 35 | else if (c == '\t') 36 | { 37 | new_string += "\\t"; 38 | } 39 | else if (c == ' ') 40 | { 41 | new_string += "\\s"; 42 | } 43 | else 44 | { 45 | new_string += c; 46 | } 47 | } 48 | 49 | return new_string; 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/LanguageModel/LanguageModel/SyntaxTree.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Immutable; 4 | using System.IO; 5 | 6 | namespace LanguageService 7 | { 8 | public class SyntaxTree 9 | { 10 | public SyntaxTree(ChunkNode root, List tokens, List statementNodeList, ImmutableList errorList) 11 | { 12 | this.Root = root; 13 | this.Tokens = tokens; 14 | this.ErrorList = errorList; 15 | this.StatementNodeList = statementNodeList; 16 | } 17 | 18 | public ChunkNode Root { get; } 19 | public ImmutableList ErrorList { get; } 20 | public List Tokens { get; } 21 | public List StatementNodeList { get; } 22 | 23 | public static SyntaxTree Create(TextReader luaReader) 24 | { 25 | var parser = Parser.Parse(luaReader); 26 | return parser; 27 | } 28 | 29 | // For testing 30 | public static SyntaxTree Create(string filename) 31 | { 32 | TextReader luaStream = File.OpenText(filename); 33 | return Parser.Parse(luaStream); 34 | } 35 | 36 | public static SyntaxTree CreateFromString(string program) 37 | { 38 | TextReader luaStream = new StringReader(program); 39 | return Parser.Parse(luaStream); 40 | } 41 | 42 | public SyntaxNode GetNodeAt(int position) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/FormattingContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using Validation; 4 | 5 | namespace LanguageService.Formatting 6 | { 7 | internal struct FormattingContext 8 | { 9 | internal FormattingContext(ParsedToken currentToken, ParsedToken nextToken, SourceText sourceText) 10 | { 11 | Requires.NotNull(currentToken, nameof(currentToken)); 12 | Requires.NotNull(nextToken, nameof(nextToken)); 13 | Requires.NotNull(sourceText, nameof(sourceText)); 14 | 15 | this.CurrentToken = currentToken; 16 | this.NextToken = nextToken; 17 | this.SourceText = sourceText; 18 | } 19 | 20 | internal ParsedToken CurrentToken { get; } 21 | 22 | internal ParsedToken NextToken { get; } 23 | 24 | internal SourceText SourceText { get; } 25 | 26 | internal bool TriviaBetweenTokensContains(SyntaxKind triviaType) 27 | { 28 | foreach (Trivia trivia in this.NextToken.Token.LeadingTrivia) 29 | { 30 | if (trivia.Type == triviaType) 31 | { 32 | return true; 33 | } 34 | } 35 | 36 | return false; 37 | } 38 | 39 | internal bool ContainsCommentsBetweenTokens() 40 | { 41 | return this.TriviaBetweenTokensContains(SyntaxKind.Comment); 42 | } 43 | 44 | internal bool TokensOnSameLine() 45 | { 46 | return !this.TriviaBetweenTokensContains(SyntaxKind.Newline); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Formatting.Tests/FormatRulesAndIndentation/ForLoopTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Formatting.Tests 4 | { 5 | using Xunit; 6 | 7 | public class ForLoopTests 8 | { 9 | private delegate void TestFunction(string original, string expected); 10 | private TestFunction GeneralTest = Tester.FormattingTest; 11 | 12 | [Fact] 13 | public void Basic() 14 | { 15 | string original = "for i = 1, 2 do end"; 16 | string expected = "for i = 1,2 do end"; 17 | this.GeneralTest(original, expected); 18 | } 19 | 20 | [Fact] 21 | public void NoChange() 22 | { 23 | string original = "for i = 1,2 do end"; 24 | string expected = "for i = 1,2 do end"; 25 | this.GeneralTest(original, expected); 26 | } 27 | 28 | [Fact] 29 | public void Comment() 30 | { 31 | string original = "for i = 1,--[[ comment ]]2 do end"; 32 | this.GeneralTest(original, original); 33 | } 34 | 35 | [Fact] 36 | public void ManySpaces() 37 | { 38 | string original = "for i = 1, 2 do end"; 39 | string expected = "for i = 1,2 do end"; 40 | this.GeneralTest(original, expected); 41 | } 42 | 43 | [Fact] 44 | public void SpacesAssignment() 45 | { 46 | string original = "for i = 1,2 do end"; 47 | string expected = "for i = 1,2 do end"; 48 | this.GeneralTest(original, expected); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/EngineRegistration.pkgdef: -------------------------------------------------------------------------------- 1 | ; This file registers the sample debug engine with Visual Studio. 2 | ; The 'AD7Metrics\Engine\{guid}' section declares capabiliets of the engine. 3 | ; Make sure to update the GUID in this file when changing EngineVSConstants.EngineId 4 | 5 | [$RootKey$\AD7Metrics\Engine\{FE72992A-F091-45CA-B9C6-B653D374AA61}] 6 | "CLSID"="{438738F7-C363-47ED-87DA-42B682E38096}" 7 | "ProgramProvider"="{14DB1ECC-B720-4F36-AEC6-3CFAC4E23A37}" 8 | "Attach"=dword:00000001 9 | "AddressBP"=dword:00000000 10 | "AutoSelectPriority"=dword:00000004 11 | "CallstackBP"=dword:00000001 12 | "Name"="Sample Debug Engine" 13 | "PortSupplier"="{708C1ECA-FF48-11D2-904F-00C04FA302A1}" 14 | @="Lua Debug Engine" 15 | 16 | [$RootKey$\AD7Metrics\Engine\{FE72992A-F091-45CA-B9C6-B653D374AA61}\IncompatibleList] 17 | "guidCOMPlusNativeEng"="{92EF0900-2251-11D2-B72E-0000F87572EF}" 18 | "guidCOMPlusOnlyEng"="{449EC4CC-30D2-4032-9256-EE18EB41B62B}" 19 | "guidNativeOnlyEng"="{449EC4CC-30D2-4032-9256-EE18EB41B62B}" 20 | "guidScriptEng"="{F200A7E7-DEA5-11D0-B854-00A0244A1DE2}" 21 | "gpudebugengine"="{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}" 22 | 23 | [$RootKey$\CLSID\{438738F7-C363-47ED-87DA-42B682E38096}] 24 | "Assembly"="Microsoft.VisualStudio.Debugger.Lua" 25 | "Class"="Microsoft.VisualStudio.Debugger.Lua.AD7Engine" 26 | "CodeBase"="$PackageFolder$\Microsoft.VisualStudio.Debugger.Lua.dll" 27 | 28 | [$RootKey$\CLSID\{14DB1ECC-B720-4F36-AEC6-3CFAC4E23A37}] 29 | "Assembly"="Microsoft.VisualStudio.Debugger.SampleEngine" 30 | "Class"="Microsoft.VisualStudio.Debugger.Lua.AD7ProgramProvider" 31 | "CodeBase"="$PackageFolder$\Microsoft.VisualStudio.Debugger.Lua.dll" 32 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Visual Studio Extension for Lua is currently accepting contributions in the form of bug fixes, features or design changes. 4 | 5 | Your pull request should: 6 | 7 | * Include a description of what your change intends to do 8 | * Be a child commit of a reasonably recent commit in the **master** branch 9 | * Requests need not be a single commit, but should be a linear sequence of commits (i.e. no merge commits in your PR) 10 | * It is desirable, but not necessary, for the tests to pass at each commit 11 | * Have clear commit messages 12 | * e.g. "Refactor feature", "Fix issue", "Add tests for issue" 13 | * To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration 14 | 15 | # Legal 16 | 17 | You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. 18 | 19 | Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to . Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/SmartIndentation/SmartIndent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using LanguageService; 5 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 6 | using Microsoft.VisualStudio.Text; 7 | using Microsoft.VisualStudio.Text.Editor; 8 | using Microsoft.VisualStudio.TextManager.Interop; 9 | 10 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Formatting.SmartIndentation 11 | { 12 | internal class SmartIndent : ISmartIndent 13 | { 14 | private ITextView textView; 15 | private ISingletons singletons; 16 | 17 | internal SmartIndent(ITextView textView, ISingletons singletons) 18 | { 19 | this.textView = textView; 20 | this.singletons = singletons; 21 | } 22 | 23 | public void Dispose() 24 | { 25 | // don't know if I need this... 26 | // throw new NotImplementedException(); 27 | } 28 | 29 | public int? GetDesiredIndentation(ITextSnapshotLine line) 30 | { 31 | if (this.singletons.FormattingUserSettings.IndentStyle == vsIndentStyle.vsIndentStyleSmart) 32 | { 33 | ITextSnapshot snapshot = this.textView.TextSnapshot; 34 | int position = this.textView.Caret.Position.BufferPosition.Position; 35 | SourceText sourceText = this.singletons.SourceTextCache.Get(snapshot); 36 | 37 | int indentAmount = this.singletons.FeatureContainer.Formatter.SmartIndent(sourceText, position); 38 | 39 | return indentAmount; 40 | } 41 | 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/LuaVSHost/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Microsoft Visual Studio Extension for Lua 6 | Microsoft Visual Studio Extension for Lua 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/Engine.Impl/EngineUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.VisualStudio.Debugger.Interop; 5 | using System.Diagnostics; 6 | using System.Globalization; 7 | 8 | namespace Microsoft.VisualStudio.Debugger.Lua 9 | { 10 | public static class EngineUtils 11 | { 12 | public static void CheckOk(int hr) 13 | { 14 | if (hr != 0) 15 | { 16 | throw new Exception("Com error: " + hr); 17 | } 18 | } 19 | 20 | public static void RequireOk(int hr) 21 | { 22 | if (hr != 0) 23 | { 24 | throw new InvalidOperationException(); 25 | } 26 | } 27 | 28 | public static int GetProcessId(IDebugProcess2 process) 29 | { 30 | AD_PROCESS_ID[] pid = new AD_PROCESS_ID[1]; 31 | EngineUtils.RequireOk(process.GetPhysicalProcessId(pid)); 32 | 33 | if (pid[0].ProcessIdType != (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM) 34 | { 35 | return 0; 36 | } 37 | 38 | return (int)pid[0].dwProcessId; 39 | } 40 | 41 | public static int GetProcessId(IDebugProgram2 program) 42 | { 43 | IDebugProcess2 process; 44 | RequireOk(program.GetProcess(out process)); 45 | 46 | return GetProcessId(process); 47 | } 48 | 49 | public static int UnexpectedException(Exception e) 50 | { 51 | Debug.Fail("Unexpected exception occured"); 52 | return VSConstants.RPC_E_SERVERFAULT; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/GrabKeyFromTable_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class GrabKeyFromTable_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.SquareBracketVar); 23 | { 24 | t.N(SyntaxKind.NameVar); 25 | { 26 | t.N(SyntaxKind.Identifier); 27 | } 28 | t.N(SyntaxKind.OpenBracket); 29 | t.N(SyntaxKind.SimpleExpression); 30 | { 31 | t.N(SyntaxKind.String); 32 | } 33 | t.N(SyntaxKind.CloseBracket); 34 | } 35 | } 36 | t.N(SyntaxKind.MissingToken); 37 | t.N(SyntaxKind.ExpList); 38 | } 39 | } 40 | t.N(SyntaxKind.EndOfFile); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/LuaVSHost/Intellisense/CompletionHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Runtime.InteropServices; 4 | using Microsoft.VisualStudio; 5 | using Microsoft.VisualStudio.Editor; 6 | using Microsoft.VisualStudio.Language.Intellisense; 7 | using Microsoft.VisualStudio.OLE.Interop; 8 | using Microsoft.VisualStudio.Shell; 9 | using Microsoft.VisualStudio.Text; 10 | using Microsoft.VisualStudio.Text.Editor; 11 | using Microsoft.VisualStudio.TextManager.Interop; 12 | using Microsoft.VisualStudio.Utilities; 13 | 14 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Intellisense 15 | { 16 | [Export(typeof(IVsTextViewCreationListener))] 17 | [TextViewRole(PredefinedTextViewRoles.Editable)] 18 | [ContentType("lua")] 19 | internal class CompletionHandlerProvider : IVsTextViewCreationListener 20 | { 21 | [Import] 22 | internal IVsEditorAdaptersFactoryService AdapterService = null; 23 | 24 | [Import] 25 | internal ICompletionBroker CompletionBroker { get; set; } 26 | 27 | [Import] 28 | internal SVsServiceProvider ServiceProvider { get; set; } 29 | 30 | public void VsTextViewCreated(IVsTextView textViewAdapter) 31 | { 32 | ITextView textView = this.AdapterService.GetWpfTextView(textViewAdapter); 33 | if (textView == null) 34 | { 35 | return; 36 | } 37 | 38 | Func createCommandHandler = delegate { return new CompletionCommandHandler(textViewAdapter, textView, this); }; 39 | textView.Properties.GetOrCreateSingletonProperty(createCommandHandler); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/SimpleTableError_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class SimpleTableError_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.NameVar); 23 | { 24 | t.N(SyntaxKind.Identifier); 25 | } 26 | } 27 | t.N(SyntaxKind.AssignmentOperator); 28 | t.N(SyntaxKind.ExpList); 29 | { 30 | t.N(SyntaxKind.SimpleExpression); 31 | { 32 | t.N(SyntaxKind.Number); 33 | } 34 | t.N(SyntaxKind.Comma); 35 | t.N(SyntaxKind.NameVar); 36 | { 37 | t.N(SyntaxKind.Identifier); 38 | } 39 | } 40 | } 41 | } 42 | t.N(SyntaxKind.EndOfFile); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/LanguageModel/LanguageModel/SyntaxNode.cs: -------------------------------------------------------------------------------- 1 | using ImmutableObjectGraph; 2 | using ImmutableObjectGraph.CodeGeneration; 3 | using System.Collections.Generic; 4 | using System.Collections.Immutable; 5 | using System.Linq; 6 | 7 | namespace LanguageService 8 | { 9 | 10 | [GenerateImmutable(GenerateBuilder = true)] 11 | public abstract partial class SyntaxNode : SyntaxNodeOrToken 12 | { 13 | [Required] 14 | private readonly SyntaxKind kind; 15 | [Required] 16 | readonly int startPosition; 17 | [Required] 18 | readonly int length; 19 | public override bool IsToken => false; 20 | public override bool IsLeafNode => this.Children.Count == 0; 21 | 22 | public IEnumerable Descendants() 23 | { 24 | if (this is SyntaxNode && ((SyntaxNode)this).kind == SyntaxKind.ChunkNode) 25 | { 26 | yield return this; 27 | } 28 | 29 | foreach (var node in this.Children) 30 | { 31 | yield return node; 32 | 33 | var nodeAsSyntaxNode = node as SyntaxNode; 34 | 35 | if (nodeAsSyntaxNode != null) 36 | { 37 | foreach (var nextNode in nodeAsSyntaxNode.Descendants()) 38 | { 39 | yield return nextNode; 40 | } 41 | } 42 | } 43 | } 44 | } 45 | 46 | #region Simple Statement Nodes 47 | #endregion 48 | #region If Statement 49 | #endregion 50 | #region Expression nodes 51 | #region FieldNodes 52 | #endregion 53 | #region PrefixExp Expression 54 | #endregion 55 | #endregion 56 | #region Args Nodes 57 | #endregion 58 | #region List nodes 59 | #endregion 60 | } 61 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/BracketError_Generator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class BracketsError_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.DotVar); 23 | { 24 | t.N(SyntaxKind.ParenPrefixExp); 25 | { 26 | t.N(SyntaxKind.OpenParen); 27 | t.N(SyntaxKind.MissingToken); 28 | { 29 | t.N(SyntaxKind.MissingToken); 30 | } 31 | t.N(SyntaxKind.MissingToken); 32 | } 33 | t.N(SyntaxKind.MissingToken); 34 | t.N(SyntaxKind.MissingToken); 35 | } 36 | } 37 | t.N(SyntaxKind.MissingToken); 38 | t.N(SyntaxKind.ExpList); 39 | } 40 | } 41 | t.N(SyntaxKind.EndOfFile); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Visual Studio Extension for Lua is a free, open source plugin that turns Visual Studio into a Lua development environment. It is designed, developed, and supported by Microsoft and the community. 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/sj49e0yom1n9bhmg/branch/master?svg=true)](https://ci.appveyor.com/project/AArnott/vslua-2w2wn/branch/master) 4 | [![Visual Studio Extension](https://img.shields.io/badge/VSIX-1.0.1-green.svg)](https://visualstudiogallery.msdn.microsoft.com/46e33dfd-c2bd-4903-99b3-94ab0f6847e9) 5 | 6 | The extension currently supports editing intelliSense, syntax colorization, formatting, and error squiggles. It also supports single Lua file debugging. 7 | 8 | ![](images/colorization.png?raw=true) 9 | ![](images/intelliSense.png?raw=true) 10 | ![](images/errorsquiggles.png?raw=true) 11 | 12 | The installer is available on https://visualstudiogallery.msdn.microsoft.com/46e33dfd-c2bd-4903-99b3-94ab0f6847e9 13 | 14 | Releases 15 | • Visual Studio Extension for Lua 1.0 includes editing and local debugging support for Visual Studio 2015. 16 | 17 | Contributions 18 | We would love to have you as a contributor! 19 | * [Contributing to Visual Studio Extension for Lua](https://github.com/Microsoft/VSLua/blob/master/CONTRIBUTING.md) 20 | * [Build Instructions for Visual Studio Extension for Lua](https://github.com/Microsoft/VSLua/wiki/Build-Instructions) 21 | 22 | 23 | [License](https://github.com/Microsoft/VSLua/blob/master/license.txt) 24 | 25 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 26 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/12_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\FunctionCallStatement.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_12 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.FunctionCallStatementNode); 18 | { 19 | t.N(SyntaxKind.NameVar); 20 | { 21 | t.N(SyntaxKind.Identifier); 22 | } 23 | t.N(SyntaxKind.ParenArg); 24 | { 25 | t.N(SyntaxKind.OpenParen); 26 | t.N(SyntaxKind.ExpList); 27 | { 28 | t.N(SyntaxKind.SimpleExpression); 29 | { 30 | t.N(SyntaxKind.TrueKeyValue); 31 | } 32 | t.N(SyntaxKind.Comma); 33 | t.N(SyntaxKind.SimpleExpression); 34 | { 35 | t.N(SyntaxKind.Number); 36 | } 37 | } 38 | t.N(SyntaxKind.CloseParen); 39 | } 40 | } 41 | } 42 | t.N(SyntaxKind.EndOfFile); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/LuaVSHost/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Diagnostics.CodeAnalysis; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("LuaVSHost")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("LuaVSHost")] 15 | [assembly: AssemblyCopyright("")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Reviewed.")] 20 | [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText", Justification = "Reviewed.")] 21 | [assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "Reviewed.")] 22 | [assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "Reviewed.")] 23 | [assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1404:CodeAnalysisSuppressionMustHaveJustification", Justification = "Reviewed.")] 24 | [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1124:DoNotUseRegions", Justification = "Reviewed.")] 25 | 26 | // Setting ComVisible to false makes the types in this assembly not visible 27 | // to COM components. If you need to access a type in this assembly from 28 | // COM, set the ComVisible attribute to true on that type. 29 | [assembly: ComVisible(false)] 30 | -------------------------------------------------------------------------------- /src/LanguageModel/LanguageModel/Token.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Text; 4 | 5 | namespace LanguageService 6 | { 7 | public class Token : SyntaxNodeOrToken 8 | { 9 | public int FullStart { get; private set; } 10 | public int Start { get; private set; } 11 | public string Text { get; private set; } 12 | public int Length { get; private set; } 13 | public int End => this.Start + this.Length; 14 | public SyntaxKind Kind { get; private set; } 15 | 16 | public List LeadingTrivia { get; private set; } //TODO: change to Immutable List 17 | 18 | public Token(SyntaxKind kind, string text, List trivia, int fullStart, int start) 19 | { 20 | this.Kind = kind; 21 | this.Text = text; 22 | this.Kind = kind; 23 | this.Text = text; 24 | this.LeadingTrivia = trivia == null ? new List() : trivia; 25 | this.FullStart = fullStart; 26 | this.Start = start; 27 | this.Length = this.Text.Length; 28 | } 29 | 30 | public static Token CreateMissingToken(int position) 31 | { 32 | return new Token(SyntaxKind.MissingToken, "", Enumerable.Empty().ToList(), position, position); 33 | } 34 | 35 | public override string ToString() 36 | { 37 | StringBuilder sb = new StringBuilder(); 38 | sb.Append(this.Kind.ToString()); 39 | sb.Append("\t"); 40 | sb.Append(this.Text); 41 | 42 | return sb.ToString(); 43 | } 44 | 45 | public override System.Collections.Immutable.ImmutableList Children 46 | { 47 | get 48 | { 49 | return null; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/Core.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using LanguageService; 4 | using Microsoft.VisualStudio.Editor; 5 | using Microsoft.VisualStudio.Shell; 6 | 7 | namespace Microsoft.VisualStudio.LuaLanguageService.Shared 8 | { 9 | [Export(typeof(ICore))] 10 | internal class Core : ICore 11 | { 12 | [Import] 13 | private GlobalEditorOptions globalEditorOptions; 14 | 15 | [Import(typeof(SVsServiceProvider))] 16 | private IServiceProvider serviceProvider; 17 | 18 | [Import] 19 | private IVsEditorAdaptersFactoryService editorAdaptersFactory; 20 | 21 | private SourceTextCache sourceTextCache; 22 | private LuaFeatureContainer featureContainer; 23 | 24 | public GlobalEditorOptions GlobalEditorOptions => this.globalEditorOptions; 25 | 26 | public IServiceProvider ServiceProvider 27 | { 28 | get 29 | { 30 | return this.serviceProvider; 31 | } 32 | } 33 | 34 | public IVsEditorAdaptersFactoryService EditorAdaptersFactory 35 | { 36 | get 37 | { 38 | return this.editorAdaptersFactory; 39 | } 40 | } 41 | 42 | public SourceTextCache SourceTextCache 43 | { 44 | get 45 | { 46 | return sourceTextCache != null ? sourceTextCache : (sourceTextCache = new SourceTextCache()); 47 | } 48 | } 49 | 50 | public LuaFeatureContainer FeatureContainer 51 | { 52 | get 53 | { 54 | if (featureContainer == null) 55 | { 56 | featureContainer = new LuaFeatureContainer(); 57 | } 58 | return featureContainer; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Formatting.Tests/FormatRulesAndIndentation/DotColonTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Formatting.Tests 4 | { 5 | using Xunit; 6 | 7 | public class DotColonTests 8 | { 9 | private delegate void TestFunction(string original, string expected); 10 | private TestFunction GeneralTest = Tester.FormattingTest; 11 | 12 | [Fact] 13 | public void BasicDot() 14 | { 15 | string original = "t . foo ()"; 16 | string expected = "t.foo ()"; 17 | this.GeneralTest(original, expected); 18 | } 19 | 20 | [Fact] 21 | public void BasicColon() 22 | { 23 | string original = "t : foo ()"; 24 | string expected = "t:foo ()"; 25 | this.GeneralTest(original, expected); 26 | } 27 | 28 | [Fact] 29 | public void MultipleInOneLine() 30 | { 31 | string original = "t :foo ().anothertable. bar : foobar ()"; 32 | string expected = "t:foo ().anothertable.bar:foobar ()"; 33 | this.GeneralTest(original, expected); 34 | } 35 | 36 | [Fact] 37 | public void NothingToChange() 38 | { 39 | string original = "t:foo (); t.foo ()"; 40 | this.GeneralTest(original, original); 41 | } 42 | 43 | [Fact] 44 | public void NewLineInBetweenDotOrColon() 45 | { 46 | string original = @" 47 | t : 48 | foo () 49 | t. 50 | bar ()"; 51 | string expected = @" 52 | t: 53 | foo () 54 | t. 55 | bar ()"; 56 | this.GeneralTest(original, expected); 57 | } 58 | 59 | [Fact] 60 | public void CommentInBetweenDotOrColon() 61 | { 62 | string original = "t. --[[comment]]bar; t: --[[comment]] bar"; 63 | this.GeneralTest(original, original); 64 | } 65 | 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/CorrectSampleLuaFiles/InvalidProgramsAsStrings.lua: -------------------------------------------------------------------------------- 1 | "{ x=1, y=2 }" 2 | 3 | "1+1" 4 | 5 | "-hello_world" 6 | 7 | "+-*/" 8 | 9 | "x ==--[[ comment ]]y" 10 | 11 | "x..y" 12 | 13 | "x +1 == 2 x= 3 /2+4" 14 | 15 | " 16 | x= 17 | 1" 18 | 19 | "1 + 2 = x" 20 | 21 | " 22 | 1+1+ 23 | 1" 24 | 25 | " 26 | 1+1+ 27 | 1" 28 | 29 | "1+" 30 | 31 | "t[1]" 32 | 33 | "}(" 34 | 35 | ")(" 36 | 37 | "](" 38 | 39 | "foo = function (x, y, z, w) end" 40 | 41 | "t = {1, 3, 4, 5, 6, 7,}" 42 | 43 | " 44 | t = { 45 | 1, 46 | 2, 47 | }" 48 | 49 | " 50 | foo = function ( 51 | a, b, c)" 52 | 53 | " 54 | t = [ 55 | 56 | 57 | 1 58 | 59 | 60 | ]" 61 | 62 | " 63 | t : 64 | foo () 65 | t. 66 | bar ()" 67 | 68 | " 69 | foo = function () 70 | return 71 | end" 72 | 73 | " 74 | foo = function() 75 | return 76 | end" 77 | 78 | " 79 | t1 = { 80 | 1, 81 | }" 82 | 83 | " 84 | foo = function 85 | --[[comment]] return 86 | end" 87 | 88 | " 89 | foo = function 90 | bar = function 91 | end 92 | end" 93 | 94 | " 95 | t1 = { 96 | t2 = { 97 | x, y, z 98 | } 99 | t3 = { 100 | x 101 | } 102 | }" 103 | 104 | " 105 | foo = function () 106 | return--comment 107 | end" 108 | 109 | " foo" 110 | 111 | " 112 | 113 | foo = function () 114 | return 115 | end" 116 | 117 | "{ 118 | x" 119 | 120 | ",x" 121 | 122 | "x,= 1" 123 | 124 | "{ x,,y }" 125 | 126 | ",--[[ comment ]]x" 127 | 128 | "{ x,y,z }" 129 | 130 | "{ x,y, ,,,, },y32,,,s2," 131 | 132 | "x, y" 133 | 134 | " 135 | x, 136 | y = 1,2" 137 | 138 | "x,y = 1,2" 139 | 140 | "function foo(x,y,z)" 141 | 142 | "{ x, y,}" 143 | 144 | "x,y" 145 | 146 | " 147 | x 148 | 149 | x " 150 | 151 | " 152 | x = 10 153 | -- comment here 154 | --[[ block 155 | comment 156 | here]] 157 | x = x + 1 " 158 | 159 | "x 160 | " -------------------------------------------------------------------------------- /src/ProjectLauncher/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Microsoft Visual Studio Tools for Lua 6 | Microsoft Visual Studio Tools for Lua 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/DeleteSpaceBeforeEofToken.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using LanguageService.Shared; 6 | 7 | namespace LanguageService.Formatting.Ruling 8 | { 9 | internal class DeleteSpaceBeforeEofToken : SimpleRule 10 | { 11 | internal DeleteSpaceBeforeEofToken() : base( 12 | new RuleDescriptor(TokenRange.All, SyntaxKind.EndOfFile), 13 | new List> { Rules.TokensAreOnSameLine }, 14 | RuleAction.Delete) 15 | { 16 | } 17 | 18 | // formattingContext is a struct, and therefore not nullable. 19 | internal override IEnumerable Apply(FormattingContext formattingContext) 20 | { 21 | List edits = new List(); 22 | TextEditInfo edit = this.GetLastSpaceTriviaInfo(formattingContext.NextToken.Token); 23 | 24 | if (edit != null) 25 | { 26 | edits.Add(edit); 27 | } 28 | 29 | return edits; 30 | } 31 | 32 | private TextEditInfo GetLastSpaceTriviaInfo(Token token) 33 | { 34 | Validation.Requires.NotNull(token, nameof(token)); 35 | List leadingTrivia = token.LeadingTrivia; 36 | if (leadingTrivia == null || leadingTrivia.Count == 0) 37 | { 38 | return null; 39 | } 40 | 41 | Trivia lastTrivia = leadingTrivia[token.LeadingTrivia.Count - 1]; 42 | 43 | TextEditInfo edit = null; 44 | 45 | if (lastTrivia.Type == SyntaxKind.Whitespace) 46 | { 47 | int length = lastTrivia.Text.Length; 48 | int start = token.Start - length; 49 | edit = new TextEditInfo(new Range(start, length), string.Empty); 50 | } 51 | 52 | return edit; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/Constants.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | 3 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 4 | { 5 | internal sealed class Constants 6 | { 7 | // Wait some time after last buffer change to actually update the UI 8 | // If changes come up during the way, cancel the current update task 9 | // and queue another. 10 | internal const int UIUpdateDelay = 875; 11 | internal const int MaximumErrorsPerFile = 25; 12 | 13 | internal sealed class Language 14 | { 15 | internal const string Name = "Lua"; 16 | internal const string FileExtension = ".lua"; 17 | } 18 | 19 | internal sealed class Colourization 20 | { 21 | internal const int ParserUpdateDelay = 440; 22 | 23 | internal const string GlobalName = "LuaGlobalClassificationFormat"; 24 | internal const string GlobalDisplayName = "Lua Global Identifier"; 25 | 26 | internal const string LocalName = "LuaLocalClassificationFormat"; 27 | internal const string LocalDisplayName = "Lua Local Identifier"; 28 | 29 | internal const string ParamName = "LuaParamClassificationFormat"; 30 | internal const string ParamDisplayName = "Lua Parameter Reference"; 31 | 32 | internal const string FieldName = "LuaFieldClassificationFormat"; 33 | internal const string FieldDisplayName = "Lua Field"; 34 | } 35 | 36 | internal sealed class Formatting 37 | { 38 | internal const string Category = "Formatting"; 39 | 40 | internal sealed class Pages 41 | { 42 | internal const string General = "General"; 43 | internal const string Spacing = "Spacing"; 44 | internal const string Indentation = "Indentation"; 45 | internal const string WrappingAndNewLines = "WrappingNewLines"; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/29_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\StringConcat.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_29 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.FunctionCallStatementNode); 18 | { 19 | t.N(SyntaxKind.NameVar); 20 | { 21 | t.N(SyntaxKind.Identifier); 22 | } 23 | t.N(SyntaxKind.ParenArg); 24 | { 25 | t.N(SyntaxKind.OpenParen); 26 | t.N(SyntaxKind.ExpList); 27 | { 28 | t.N(SyntaxKind.BinaryOperatorExpression); 29 | { 30 | t.N(SyntaxKind.SimpleExpression); 31 | { 32 | t.N(SyntaxKind.String); 33 | } 34 | t.N(SyntaxKind.StringConcatOperator); 35 | t.N(SyntaxKind.SimpleExpression); 36 | { 37 | t.N(SyntaxKind.String); 38 | } 39 | } 40 | } 41 | t.N(SyntaxKind.CloseParen); 42 | } 43 | } 44 | } 45 | t.N(SyntaxKind.EndOfFile); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/RuleProperties.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Microsoft.VisualStudio.Debugger.Lua.Rules 4 | { 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.ProjectSystem; 7 | using Microsoft.VisualStudio.ProjectSystem.Properties; 8 | using Microsoft.VisualStudio.ProjectSystem.Utilities; 9 | 10 | /// 11 | /// Provides rule-based property access. 12 | /// 13 | [Export] 14 | [AppliesTo(ProjectCapabilities.VisualC)] 15 | internal partial class RuleProperties : StronglyTypedPropertyAccess 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | [ImportingConstructor] 21 | public RuleProperties(ConfiguredProject configuredProject) 22 | : base(configuredProject) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | public RuleProperties(ConfiguredProject configuredProject, string file, string itemType, string itemName) 30 | : base(configuredProject, file, itemType, itemName) 31 | { 32 | } 33 | 34 | /// 35 | /// Initializes a new instance of the class. 36 | /// 37 | public RuleProperties(ConfiguredProject configuredProject, IProjectPropertiesContext projectPropertiesContext) 38 | : base(configuredProject, projectPropertiesContext) 39 | { 40 | } 41 | 42 | /// 43 | /// Initializes a new instance of the class. 44 | /// 45 | public RuleProperties(ConfiguredProject configuredProject, UnconfiguredProject unconfiguredProject) 46 | : base(configuredProject, unconfiguredProject) 47 | { 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/ProjectLauncher/LaunchForm.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace ProjectLauncher 4 | { 5 | using System; 6 | using System.Collections.Generic; 7 | using System.ComponentModel; 8 | using System.Data; 9 | using System.Drawing; 10 | using System.Text; 11 | using System.Windows.Forms; 12 | using EnvDTE; 13 | using EnvDTE80; 14 | 15 | public partial class LaunchForm : Form 16 | { 17 | private DTE2 dte; 18 | private string filePath; 19 | 20 | public LaunchForm(DTE2 dte) 21 | { 22 | this.dte = dte; 23 | this.InitializeComponent(); 24 | } 25 | 26 | public string FilePath 27 | { 28 | get { return this.filePath; } 29 | } 30 | 31 | private void btnLaunch_Click(object sender, EventArgs e) 32 | { 33 | if (this.filePath != null) 34 | { 35 | this.DialogResult = DialogResult.OK; 36 | this.Close(); 37 | } 38 | } 39 | 40 | private void LaunchForm_Load(object sender, EventArgs e) 41 | { 42 | if (this.dte.ActiveDocument != null) 43 | { 44 | string activeDocName = this.dte.ActiveDocument.Name; 45 | this.cmbProjects.Items.Add(activeDocName); 46 | } 47 | 48 | if (this.cmbProjects.Items.Count > 0) 49 | { 50 | this.cmbProjects.SelectedIndex = 0; 51 | } 52 | } 53 | 54 | private void btnBrowse_Click(object sender, EventArgs e) 55 | { 56 | OpenFileDialog openFileDialog = new OpenFileDialog(); 57 | openFileDialog.Filter = "Lua Hosts|*.exe"; 58 | 59 | if (openFileDialog.ShowDialog() == DialogResult.OK) 60 | { 61 | this.lblPath.Text = openFileDialog.FileName; 62 | this.filePath = openFileDialog.FileName; 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Options/FormattingOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Collections.Generic; 4 | using System.Collections.Immutable; 5 | using Validation; 6 | 7 | namespace LanguageService.Formatting.Options 8 | { 9 | public class FormattingOptions 10 | { 11 | 12 | /// 13 | /// Updates the general options. 14 | /// 15 | /// 16 | /// The rules that can be turned off for the formatter. 17 | /// 18 | /// 19 | /// How big in spaces the indents are when you format 20 | /// 21 | /// 22 | /// How big in spaces the indents are when you press tab, 23 | /// 24 | /// 25 | /// Whether or not Keep Tabs is on or off. 26 | /// 27 | public FormattingOptions( 28 | List disableRuleGroups, 29 | uint tabSize, uint indentSize, bool usingTabs) 30 | { 31 | Requires.NotNull(disableRuleGroups, nameof(disableRuleGroups)); 32 | 33 | this.TabSize = tabSize; 34 | this.IndentSize = indentSize; 35 | this.UsingTabs = usingTabs; 36 | this.RuleGroupsToDisable = disableRuleGroups.ToImmutableArray(); 37 | this.OptionalRuleMap = new OptionalRuleMap(this.RuleGroupsToDisable); 38 | } 39 | 40 | public FormattingOptions() 41 | { 42 | this.IndentSize = 4; 43 | this.OptionalRuleMap = new OptionalRuleMap(ImmutableArray.Create()); 44 | } 45 | 46 | public uint IndentSize { get; } 47 | 48 | public uint TabSize { get; } 49 | 50 | public bool UsingTabs { get; } 51 | 52 | public ImmutableArray RuleGroupsToDisable { get; } 53 | 54 | internal OptionalRuleMap OptionalRuleMap { get; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/DLLInjector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | namespace Microsoft.VisualStudio.Debugger.Lua 7 | { 8 | public class DLLInjector 9 | { 10 | [DllImport("kernel32.dll")] 11 | public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); 12 | 13 | [DllImport("kernel32.dll", CharSet = CharSet.Auto)] 14 | public static extern IntPtr GetModuleHandle(string lpModuleName); 15 | 16 | [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] 17 | public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); 18 | 19 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] 20 | public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, 21 | uint dwSize, uint flAllocationType, uint flProtect); 22 | 23 | [DllImport("kernel32.dll", SetLastError = true)] 24 | public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out UIntPtr lpNumberOfBytesWritten); 25 | 26 | [DllImport("kernel32.dll")] 27 | public static extern IntPtr CreateRemoteThread(IntPtr hProcess, 28 | IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId); 29 | 30 | // privileges 31 | public const int PROCESS_CREATE_THREAD = 0x0002; 32 | public const int PROCESS_QUERY_INFORMATION = 0x0400; 33 | public const int PROCESS_VM_OPERATION = 0x0008; 34 | public const int PROCESS_VM_WRITE = 0x0020; 35 | public const int PROCESS_VM_READ = 0x0010; 36 | 37 | // used for memory allocation 38 | public const uint MEM_COMMIT = 0x00001000; 39 | public const uint MEM_RESERVE = 0x00002000; 40 | public const uint PAGE_READWRITE = 4; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/BufferExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using Microsoft.VisualStudio.Text; 4 | using Microsoft.VisualStudio.Text.Projection; 5 | 6 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 7 | { 8 | internal static class BufferExtensions 9 | { 10 | internal static string GetFilePath(this ITextBuffer textBuffer) 11 | { 12 | string filePath = GetFilePathFromTextDocument(textBuffer); 13 | 14 | if (!string.IsNullOrEmpty(filePath)) 15 | { 16 | return filePath; 17 | } 18 | 19 | IProjectionBuffer projectionBuffer = textBuffer as IProjectionBuffer; 20 | 21 | if (projectionBuffer == null) 22 | { 23 | return null; 24 | } 25 | 26 | List filePaths = new List(); 27 | 28 | foreach (ITextBuffer buffer in projectionBuffer.SourceBuffers) 29 | { 30 | filePath = GetFilePathFromTextDocument(buffer); 31 | 32 | if (!string.IsNullOrEmpty(filePath)) 33 | { 34 | filePaths.Add(filePath); 35 | } 36 | } 37 | 38 | Debug.Assert(filePaths.Count <= 1, "Why is there more than one buffer with a file path?"); 39 | 40 | if (filePaths.Count > 0) 41 | { 42 | return filePaths[0]; 43 | } 44 | 45 | return null; 46 | } 47 | 48 | private static string GetFilePathFromTextDocument(ITextBuffer textBuffer) 49 | { 50 | if (textBuffer == null) 51 | { 52 | return null; 53 | } 54 | 55 | ITextDocument document; 56 | 57 | if (textBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document) && document != null && document.TextBuffer != null) 58 | { 59 | return document.FilePath; 60 | } 61 | 62 | return null; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/26_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\ReturnStatementInFunction.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_26 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.GlobalFunctionStatementNode); 18 | { 19 | t.N(SyntaxKind.FunctionKeyword); 20 | t.N(SyntaxKind.FuncNameNode); 21 | { 22 | t.N(SyntaxKind.Identifier); 23 | t.N(SyntaxKind.DotSeparatedNameList); 24 | } 25 | t.N(SyntaxKind.FuncBodyNode); 26 | { 27 | t.N(SyntaxKind.OpenParen); 28 | t.N(SyntaxKind.NameListPar); 29 | { 30 | t.N(SyntaxKind.NameList); 31 | } 32 | t.N(SyntaxKind.CloseParen); 33 | t.N(SyntaxKind.BlockNode); 34 | { 35 | t.N(SyntaxKind.ReturnStatementNode); 36 | { 37 | t.N(SyntaxKind.ReturnKeyword); 38 | t.N(SyntaxKind.ExpList); 39 | t.N(SyntaxKind.Semicolon); 40 | } 41 | } 42 | t.N(SyntaxKind.EndKeyword); 43 | } 44 | } 45 | } 46 | t.N(SyntaxKind.EndOfFile); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/LuaVSHost/Classifications/TaggerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Language.StandardClassification; 7 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 8 | using Microsoft.VisualStudio.Text; 9 | using Microsoft.VisualStudio.Text.Classification; 10 | using Microsoft.VisualStudio.Text.Tagging; 11 | using Microsoft.VisualStudio.Utilities; 12 | 13 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Classifications 14 | { 15 | [Export(typeof(ITaggerProvider))] 16 | [ContentType(Constants.Language.Name)] 17 | [TagType(typeof(ClassificationTag))] 18 | internal class TaggerProvider : ITaggerProvider 19 | { 20 | #pragma warning disable 0169, 0649 // Supress the "not" initialized warning 21 | [Import] 22 | private IStandardClassificationService standardClassifications; 23 | 24 | [Import] 25 | private IClassificationTypeRegistryService classificationTypeRegistry; 26 | 27 | [Import] 28 | private ISingletons singletons; 29 | #pragma warning restore 0169, 0649 30 | 31 | public ITagger CreateTagger(ITextBuffer buffer) where T : ITag 32 | { 33 | Requires.NotNull(buffer, nameof(buffer)); 34 | 35 | Func taggerCreator = () => 36 | { 37 | Tagger tagger = new Tagger(buffer, this.standardClassifications, this.classificationTypeRegistry, this.singletons); 38 | 39 | return tagger; 40 | }; 41 | 42 | // Taggers can be created for many reasons. In this case, it's fine to have a sinlge 43 | // tagger for a given buffer, so cache it on the buffer as a singleton property. 44 | // return buffer.Properties.GetOrCreateSingletonProperty(taggerCreator) as ITagger; 45 | return new Tagger(buffer, this.standardClassifications, this.classificationTypeRegistry, this.singletons) as ITagger; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/Engine.Impl/BreakpointManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.Debugger.Interop; 3 | using System.Collections.Generic; 4 | 5 | namespace Microsoft.VisualStudio.Debugger.Lua 6 | { 7 | // This class manages breakpoints for the engine. 8 | internal class BreakpointManager 9 | { 10 | private AD7Engine m_engine; 11 | private List m_pendingBreakpoints; 12 | private Dictionary m_boundBreakpoints; 13 | 14 | public BreakpointManager(AD7Engine engine) 15 | { 16 | m_engine = engine; 17 | m_pendingBreakpoints = new List(); 18 | m_boundBreakpoints = new Dictionary(); 19 | } 20 | 21 | // A helper method used to construct a new pending breakpoint. 22 | // Called when new breakpoint set 23 | public void CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP) 24 | { 25 | AD7PendingBreakpoint pendingBreakpoint = new AD7PendingBreakpoint(pBPRequest, m_engine, this); 26 | ppPendingBP = (IDebugPendingBreakpoint2)pendingBreakpoint; 27 | m_pendingBreakpoints.Add(pendingBreakpoint); 28 | } 29 | 30 | public void StoreBoundBreakpoint(string fileandline, AD7BoundBreakpoint bp) 31 | { 32 | // store bound breakpoint in list, need to be able to get 33 | m_boundBreakpoints.Add(fileandline, bp); 34 | } 35 | 36 | // Called from the engine's detach method to remove the debugger's breakpoint instructions. 37 | public void ClearBoundBreakpoints() 38 | { 39 | } 40 | 41 | internal AD7BoundBreakpoint GetBoundBreakpoint(string fileandline) 42 | { 43 | if(m_boundBreakpoints.ContainsKey(fileandline)) 44 | { 45 | return m_boundBreakpoints[fileandline]; 46 | } 47 | 48 | throw new InvalidOperationException(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/PrefixExpFirst_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class PrefixExpFirst_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.SquareBracketVar); 23 | { 24 | t.N(SyntaxKind.ParenPrefixExp); 25 | { 26 | t.N(SyntaxKind.OpenParen); 27 | t.N(SyntaxKind.NameVar); 28 | { 29 | t.N(SyntaxKind.Identifier); 30 | } 31 | t.N(SyntaxKind.CloseParen); 32 | } 33 | t.N(SyntaxKind.OpenBracket); 34 | t.N(SyntaxKind.NameVar); 35 | { 36 | t.N(SyntaxKind.Identifier); 37 | } 38 | t.N(SyntaxKind.CloseBracket); 39 | } 40 | } 41 | t.N(SyntaxKind.AssignmentOperator); 42 | t.N(SyntaxKind.ExpList); 43 | { 44 | t.N(SyntaxKind.NameVar); 45 | { 46 | t.N(SyntaxKind.Identifier); 47 | } 48 | } 49 | } 50 | } 51 | t.N(SyntaxKind.EndOfFile); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/LuaVSHost/Formatting/OptionPages/UserControls/GeneralUserControl.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 11 | 12 | 13 | 17 | 18 | 22 | 23 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/AD7.Definitions/AD7Guids.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Microsoft.VisualStudio.Debugger.Lua 6 | { 7 | // These are well-known guids in AD7. Most of these are used to specify filters in what the debugger UI is requesting. 8 | // For instance, guidFilterLocals can be passed to IDebugStackFrame2::EnumProperties to specify only locals are requested. 9 | internal static class AD7Guids 10 | { 11 | static private Guid _guidFilterRegisters = new Guid("223ae797-bd09-4f28-8241-2763bdc5f713"); 12 | static public Guid guidFilterRegisters 13 | { 14 | get { return _guidFilterRegisters; } 15 | } 16 | 17 | static private Guid _guidFilterLocals = new Guid("b200f725-e725-4c53-b36a-1ec27aef12ef"); 18 | static public Guid guidFilterLocals 19 | { 20 | get { return _guidFilterLocals; } 21 | } 22 | 23 | static private Guid _guidFilterAllLocals = new Guid("196db21f-5f22-45a9-b5a3-32cddb30db06"); 24 | static public Guid guidFilterAllLocals 25 | { 26 | get { return _guidFilterAllLocals; } 27 | } 28 | 29 | static private Guid _guidFilterArgs = new Guid("804bccea-0475-4ae7-8a46-1862688ab863"); 30 | static public Guid guidFilterArgs 31 | { 32 | get { return _guidFilterArgs; } 33 | } 34 | 35 | static private Guid _guidFilterLocalsPlusArgs = new Guid("e74721bb-10c0-40f5-807f-920d37f95419"); 36 | static public Guid guidFilterLocalsPlusArgs 37 | { 38 | get { return _guidFilterLocalsPlusArgs; } 39 | } 40 | 41 | static private Guid _guidFilterAllLocalsPlusArgs = new Guid("939729a8-4cb0-4647-9831-7ff465240d5f"); 42 | static public Guid guidFilterAllLocalsPlusArgs 43 | { 44 | get { return _guidFilterAllLocalsPlusArgs; } 45 | } 46 | 47 | // Language guid for C++. Used when the language for a document context or a stack frame is requested. 48 | static private Guid _guidLanguageCpp = new Guid("3a12d0b7-c26c-11d0-b442-00a0244a1dd2"); 49 | static public Guid guidLanguageCpp 50 | { 51 | get { return _guidLanguageCpp; } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/3_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\BreakIfStatement.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_3 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.IfStatementNode); 18 | { 19 | t.N(SyntaxKind.IfKeyword); 20 | t.N(SyntaxKind.BinaryOperatorExpression); 21 | { 22 | t.N(SyntaxKind.SquareBracketVar); 23 | { 24 | t.N(SyntaxKind.NameVar); 25 | { 26 | t.N(SyntaxKind.Identifier); 27 | } 28 | t.N(SyntaxKind.OpenBracket); 29 | t.N(SyntaxKind.NameVar); 30 | { 31 | t.N(SyntaxKind.Identifier); 32 | } 33 | t.N(SyntaxKind.CloseBracket); 34 | } 35 | t.N(SyntaxKind.EqualityOperator); 36 | t.N(SyntaxKind.NameVar); 37 | { 38 | t.N(SyntaxKind.Identifier); 39 | } 40 | } 41 | t.N(SyntaxKind.ThenKeyword); 42 | t.N(SyntaxKind.BlockNode); 43 | { 44 | t.N(SyntaxKind.BreakStatementNode); 45 | { 46 | t.N(SyntaxKind.BreakKeyword); 47 | } 48 | } 49 | t.N(SyntaxKind.EndKeyword); 50 | } 51 | } 52 | t.N(SyntaxKind.EndOfFile); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/LanguageModel/Classification/Classification.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageService.Classification 4 | { 5 | /// 6 | /// Defines the token classifications for the Lua language service, every token can be placed into 7 | /// one of these categories, all tokens only have one classification. 8 | /// 9 | public enum Classification 10 | { 11 | /// 12 | /// Specifies a Keyword type as defined in the Lua Language Service 13 | /// 14 | Keyword, 15 | 16 | /// 17 | /// Any name that is not a keyword and defined at the global scope as 18 | /// defined by the Lua language manual 19 | /// 20 | Global, 21 | 22 | /// 23 | /// Any name that is not a keyword and defined at the local scope as 24 | /// defined by the Lua language manual 25 | /// 26 | Local, 27 | 28 | /// 29 | /// Any name that is the field of a table 30 | /// 31 | Field, 32 | 33 | /// 34 | /// Any name that is defined as a parameter for a function and all its references 35 | /// within the function 36 | /// 37 | ParameterReference, 38 | 39 | /// 40 | /// Dots, Semi-Colons, Colons, Commas 41 | /// 42 | Punctuation, 43 | 44 | /// 45 | /// A number as defined in the Lua reference manual 46 | /// 47 | Number, 48 | 49 | /// 50 | /// A string literal as defined in the Lua reference manual 51 | /// 52 | StringLiteral, 53 | 54 | /// 55 | /// Both multiline and single-lined comments 56 | /// 57 | Comment, 58 | 59 | /// 60 | /// Operators as defined in the Lua reference manual, excludes "and" and "or" as keywords. 61 | /// 62 | Operator, 63 | 64 | /// 65 | /// true, false, nil 66 | /// 67 | KeyValue, 68 | 69 | /// 70 | /// Square brackets, curly braces, parenthesis 71 | /// 72 | Bracket 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/NestedTable_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class NestedTable_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.NameVar); 23 | { 24 | t.N(SyntaxKind.Identifier); 25 | } 26 | } 27 | t.N(SyntaxKind.AssignmentOperator); 28 | t.N(SyntaxKind.ExpList); 29 | { 30 | t.N(SyntaxKind.TableConstructorExp); 31 | { 32 | t.N(SyntaxKind.OpenCurlyBrace); 33 | t.N(SyntaxKind.FieldList); 34 | { 35 | t.N(SyntaxKind.AssignmentField); 36 | { 37 | t.N(SyntaxKind.Identifier); 38 | t.N(SyntaxKind.AssignmentOperator); 39 | t.N(SyntaxKind.TableConstructorExp); 40 | { 41 | t.N(SyntaxKind.OpenCurlyBrace); 42 | t.N(SyntaxKind.FieldList); 43 | t.N(SyntaxKind.CloseCurlyBrace); 44 | } 45 | } 46 | } 47 | t.N(SyntaxKind.CloseCurlyBrace); 48 | } 49 | } 50 | } 51 | } 52 | t.N(SyntaxKind.EndOfFile); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/LuaVSHost/LuaLanguageServicePackage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Runtime.InteropServices; 6 | using Microsoft.VisualStudio.LanguageServices.Lua.Formatting; 7 | using Microsoft.VisualStudio.LanguageServices.Lua.Formatting.OptionPages; 8 | using Microsoft.VisualStudio.LanguageServices.Lua.Shared; 9 | using Microsoft.VisualStudio.Shell; 10 | 11 | namespace Microsoft.VisualStudio.LanguageServices.Lua 12 | { 13 | 14 | using Interop = Microsoft.VisualStudio.Shell.Interop; 15 | 16 | [PackageRegistration(UseManagedResourcesOnly = true)] 17 | [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] 18 | [Guid(Guids.PackageString)] 19 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")] 20 | 21 | [ProvideOptionPage(typeof(GeneralPage), Constants.Formatting.Category, Constants.Formatting.Pages.General, 22 | 1000, 1002, true, ProfileMigrationType = ProfileMigrationType.PassThrough)] 23 | 24 | [ProvideOptionPage(typeof(SpacingPage), Constants.Formatting.Category, Constants.Formatting.Pages.Spacing, 25 | 1000, 1004, true, ProfileMigrationType = ProfileMigrationType.PassThrough)] 26 | 27 | /*[ProvideOptionPage(typeof(WrappingAndNewLinePage), Constants.Formatting.Category, Constants.Formatting.Pages.WrappingAndNewLines, 28 | 1000, 1005, true, ProfileMigrationType = ProfileMigrationType.PassThrough)]*/ 29 | 30 | public sealed class LuaLanguageServicePackage : Package 31 | { 32 | public LuaLanguageServicePackage() 33 | { 34 | // initiaization stuff before package creation 35 | } 36 | 37 | #region Package Members 38 | 39 | protected override void Initialize() 40 | { 41 | var uiShell = (Interop.IVsUIShell2)this.GetService(typeof(Interop.IVsUIShell2)); 42 | 43 | base.Initialize(); 44 | } 45 | 46 | internal UserSettings FormattingUserSettings 47 | { 48 | get 49 | { 50 | return (UserSettings)this.GetAutomationObject($"{Constants.Formatting.Category}.{Constants.Formatting.Pages.General}"); 51 | } 52 | } 53 | 54 | #endregion 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/IMiniCommandFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using OLECommandFlags = Microsoft.VisualStudio.OLE.Interop.OLECMDF; 4 | 5 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 6 | { 7 | internal interface IMiniCommandFilter 8 | { 9 | /// 10 | /// Operations that happen at the close of whatever the IMiniCommandFilter is attached to. 11 | /// 12 | void Close(); 13 | 14 | /// 15 | /// Operations that happen before the command has been processed 16 | /// 17 | /// The Guid Cmd Group for the command 18 | /// The command ID 19 | /// The variant for the command 20 | /// 21 | /// Return true if the command proceeded in affecting the editor environment, i.e. if it formatted 22 | /// the document, or a selection, otherwise returns false if the editor environment 23 | /// did not change. 24 | /// 25 | bool PreProcessCommand(Guid guidCmdGroup, uint commandId, IntPtr variantIn); 26 | 27 | /// 28 | /// Operations that happen after the command has been processed 29 | /// 30 | /// The Guid Cmd Group for the command 31 | /// The command ID 32 | /// The variant for the command 33 | /// Whether or not the pre-process command was handled 34 | void PostProcessCommand(Guid guidCmdGroup, uint commandId, IntPtr variantIn, bool wasHandled); 35 | 36 | /// 37 | /// Puts the command status in commandStatus, a wrapper for the QueryStatus in IOleCommandTarget 38 | /// 39 | /// The Guid Cmd Group for the command 40 | /// The command ID 41 | /// The command text 42 | /// The command status 43 | /// Returns true if the query succeeded otherwise false 44 | bool QueryCommandStatus(Guid guidCmdGroup, uint commandId, IntPtr commandText, out OLECommandFlags commandStatus); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/14_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\FunctionCallWithTableConstructor.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_14 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.FunctionCallStatementNode); 18 | { 19 | t.N(SyntaxKind.NameVar); 20 | { 21 | t.N(SyntaxKind.Identifier); 22 | } 23 | t.N(SyntaxKind.TableConstructorArg); 24 | { 25 | t.N(SyntaxKind.OpenCurlyBrace); 26 | t.N(SyntaxKind.FieldList); 27 | { 28 | t.N(SyntaxKind.AssignmentField); 29 | { 30 | t.N(SyntaxKind.Identifier); 31 | t.N(SyntaxKind.AssignmentOperator); 32 | t.N(SyntaxKind.SimpleExpression); 33 | { 34 | t.N(SyntaxKind.String); 35 | } 36 | } 37 | t.N(SyntaxKind.Comma); 38 | t.N(SyntaxKind.AssignmentField); 39 | { 40 | t.N(SyntaxKind.Identifier); 41 | t.N(SyntaxKind.AssignmentOperator); 42 | t.N(SyntaxKind.SimpleExpression); 43 | { 44 | t.N(SyntaxKind.String); 45 | } 46 | } 47 | } 48 | t.N(SyntaxKind.CloseCurlyBrace); 49 | } 50 | } 51 | } 52 | t.N(SyntaxKind.EndOfFile); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/FunctionDefError_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class FunctionDefError_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.NameVar); 23 | { 24 | t.N(SyntaxKind.Identifier); 25 | } 26 | } 27 | t.N(SyntaxKind.AssignmentOperator); 28 | t.N(SyntaxKind.ExpList); 29 | { 30 | t.N(SyntaxKind.FunctionDef); 31 | { 32 | t.N(SyntaxKind.FunctionKeyword); 33 | t.N(SyntaxKind.FuncBodyNode); 34 | { 35 | t.N(SyntaxKind.MissingToken); 36 | t.N(SyntaxKind.NameListPar); 37 | { 38 | t.N(SyntaxKind.NameList); 39 | } 40 | t.N(SyntaxKind.MissingToken); 41 | t.N(SyntaxKind.BlockNode); 42 | { 43 | t.N(SyntaxKind.ReturnStatementNode); 44 | { 45 | t.N(SyntaxKind.ReturnKeyword); 46 | t.N(SyntaxKind.ExpList); 47 | } 48 | } 49 | t.N(SyntaxKind.EndKeyword); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | t.N(SyntaxKind.EndOfFile); 56 | } 57 | 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/SmallIf_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class SmallIf_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.IfStatementNode); 19 | { 20 | t.N(SyntaxKind.IfKeyword); 21 | t.N(SyntaxKind.BinaryOperatorExpression); 22 | { 23 | t.N(SyntaxKind.SimpleExpression); 24 | { 25 | t.N(SyntaxKind.TrueKeyValue); 26 | } 27 | t.N(SyntaxKind.EqualityOperator); 28 | t.N(SyntaxKind.SimpleExpression); 29 | { 30 | t.N(SyntaxKind.String); 31 | } 32 | } 33 | t.N(SyntaxKind.ThenKeyword); 34 | t.N(SyntaxKind.BlockNode); 35 | { 36 | t.N(SyntaxKind.FunctionCallStatementNode); 37 | { 38 | t.N(SyntaxKind.NameVar); 39 | { 40 | t.N(SyntaxKind.Identifier); 41 | } 42 | t.N(SyntaxKind.ParenArg); 43 | { 44 | t.N(SyntaxKind.OpenParen); 45 | t.N(SyntaxKind.ExpList); 46 | t.N(SyntaxKind.CloseParen); 47 | } 48 | } 49 | t.N(SyntaxKind.SemiColonStatementNode); 50 | { 51 | t.N(SyntaxKind.Semicolon); 52 | } 53 | } 54 | t.N(SyntaxKind.EndKeyword); 55 | } 56 | } 57 | t.N(SyntaxKind.EndOfFile); 58 | } 59 | 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/0_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\AssignmentForIORead.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_0 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.AssignmentStatementNode); 18 | { 19 | t.N(SyntaxKind.VarList); 20 | { 21 | t.N(SyntaxKind.NameVar); 22 | { 23 | t.N(SyntaxKind.Identifier); 24 | } 25 | } 26 | t.N(SyntaxKind.AssignmentOperator); 27 | t.N(SyntaxKind.ExpList); 28 | { 29 | t.N(SyntaxKind.FunctionCallExp); 30 | { 31 | t.N(SyntaxKind.DotVar); 32 | { 33 | t.N(SyntaxKind.NameVar); 34 | { 35 | t.N(SyntaxKind.Identifier); 36 | } 37 | t.N(SyntaxKind.Dot); 38 | t.N(SyntaxKind.Identifier); 39 | } 40 | t.N(SyntaxKind.ParenArg); 41 | { 42 | t.N(SyntaxKind.OpenParen); 43 | t.N(SyntaxKind.ExpList); 44 | { 45 | t.N(SyntaxKind.SimpleExpression); 46 | { 47 | t.N(SyntaxKind.String); 48 | } 49 | } 50 | t.N(SyntaxKind.CloseParen); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | t.N(SyntaxKind.EndOfFile); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/LanguageModel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Diagnostics.CodeAnalysis; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyTitle("Parser.cs")] 12 | [assembly: AssemblyDescription("")] 13 | [assembly: AssemblyConfiguration("")] 14 | [assembly: AssemblyCompany("")] 15 | [assembly: AssemblyProduct("Parser.cs")] 16 | [assembly: AssemblyCopyright("Copyright © 2015")] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: AssemblyCulture("")] 19 | 20 | [assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "Reviewed.")] 21 | [assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1512:SingleLineCommentsMustNotBeFollowedByBlankLine", Justification = "Reviewed.")] 22 | [assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1515:SingleLineCommentMustBePrecededByBlankLine", Justification = "Reviewed.")] 23 | [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Reviewed.")] 24 | [assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "Reviewed.")] 25 | [assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1404:CodeAnalysisSuppressionMustHaveJustification", Justification = "Reviewed.")] 26 | [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1124:DoNotUseRegions", Justification = "Reviewed.")] 27 | [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText", Justification = "Reviewed.")] 28 | [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1118:ParameterMustNotSpanMultipleLines", Justification = "Reviewed.")] 29 | [assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.")] 30 | 31 | // Setting ComVisible to false makes the types in this assembly not visible 32 | // to COM components. If you need to access a type in this assembly from 33 | // COM, set the ComVisible attribute to true on that type. 34 | [assembly: ComVisible(false)] 35 | 36 | // The following GUID is for the ID of the typelib if this project is exposed to COM 37 | [assembly: Guid("cff6ef45-ee9f-4a9e-bd4e-8607c2bc9452")] 38 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/21_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\MultipleTypeAssignment.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_21 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.AssignmentStatementNode); 18 | { 19 | t.N(SyntaxKind.VarList); 20 | { 21 | t.N(SyntaxKind.NameVar); 22 | { 23 | t.N(SyntaxKind.Identifier); 24 | } 25 | t.N(SyntaxKind.Comma); 26 | t.N(SyntaxKind.NameVar); 27 | { 28 | t.N(SyntaxKind.Identifier); 29 | } 30 | t.N(SyntaxKind.Comma); 31 | t.N(SyntaxKind.NameVar); 32 | { 33 | t.N(SyntaxKind.Identifier); 34 | } 35 | } 36 | t.N(SyntaxKind.AssignmentOperator); 37 | t.N(SyntaxKind.ExpList); 38 | { 39 | t.N(SyntaxKind.SimpleExpression); 40 | { 41 | t.N(SyntaxKind.String); 42 | } 43 | t.N(SyntaxKind.Comma); 44 | t.N(SyntaxKind.SimpleExpression); 45 | { 46 | t.N(SyntaxKind.Number); 47 | } 48 | t.N(SyntaxKind.Comma); 49 | t.N(SyntaxKind.TableConstructorExp); 50 | { 51 | t.N(SyntaxKind.OpenCurlyBrace); 52 | t.N(SyntaxKind.FieldList); 53 | t.N(SyntaxKind.CloseCurlyBrace); 54 | } 55 | } 56 | } 57 | } 58 | t.N(SyntaxKind.EndOfFile); 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/ValidatedGeneratedTests/MultipleTypeAssignment_Generated.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageModel.Tests.GeneratedTestFiles 4 | { 5 | using LanguageModel.Tests.TestGeneration; 6 | using LanguageService; 7 | using Xunit; 8 | 9 | internal class MultipleTypeAssignment_Generated 10 | { 11 | [Fact] 12 | public void Test(Tester t) 13 | { 14 | t.N(SyntaxKind.ChunkNode); 15 | { 16 | t.N(SyntaxKind.BlockNode); 17 | { 18 | t.N(SyntaxKind.AssignmentStatementNode); 19 | { 20 | t.N(SyntaxKind.VarList); 21 | { 22 | t.N(SyntaxKind.NameVar); 23 | { 24 | t.N(SyntaxKind.Identifier); 25 | } 26 | t.N(SyntaxKind.Comma); 27 | t.N(SyntaxKind.NameVar); 28 | { 29 | t.N(SyntaxKind.Identifier); 30 | } 31 | t.N(SyntaxKind.Comma); 32 | t.N(SyntaxKind.NameVar); 33 | { 34 | t.N(SyntaxKind.Identifier); 35 | } 36 | } 37 | t.N(SyntaxKind.AssignmentOperator); 38 | t.N(SyntaxKind.ExpList); 39 | { 40 | t.N(SyntaxKind.SimpleExpression); 41 | { 42 | t.N(SyntaxKind.String); 43 | } 44 | t.N(SyntaxKind.Comma); 45 | t.N(SyntaxKind.SimpleExpression); 46 | { 47 | t.N(SyntaxKind.Number); 48 | } 49 | t.N(SyntaxKind.Comma); 50 | t.N(SyntaxKind.TableConstructorExp); 51 | { 52 | t.N(SyntaxKind.OpenCurlyBrace); 53 | t.N(SyntaxKind.FieldList); 54 | t.N(SyntaxKind.CloseCurlyBrace); 55 | } 56 | } 57 | } 58 | } 59 | t.N(SyntaxKind.EndOfFile); 60 | } 61 | 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Ruling/DeleteTrailingWhitespace.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using LanguageService.Shared; 6 | 7 | namespace LanguageService.Formatting.Ruling 8 | { 9 | internal class DeleteTrailingWhitespace : SimpleRule 10 | { 11 | internal DeleteTrailingWhitespace() : base( 12 | new RuleDescriptor(TokenRange.All, TokenRange.All), 13 | new List> { Rules.TokensAreNotOnSameLine }, 14 | RuleAction.Delete) 15 | { 16 | } 17 | 18 | internal override IEnumerable Apply(FormattingContext formattingContext) 19 | { 20 | Token nextToken = formattingContext.NextToken.Token; 21 | // flag for the end of file token where whitespace should be deleted 22 | List edits = this.GetEdits(nextToken, nextToken.Kind == SyntaxKind.EndOfFile); 23 | 24 | return edits; 25 | } 26 | 27 | private List GetEdits(Token token, bool isEndOfFile) 28 | { 29 | Validation.Requires.NotNull(token, nameof(token)); 30 | 31 | List edits = new List(); 32 | 33 | int start = token.FullStart; 34 | int length = 0; 35 | var leadingTrivia = token.LeadingTrivia; 36 | for (int i = 0; i < leadingTrivia.Count; ++i) 37 | { 38 | length = leadingTrivia[i].Text.Length; 39 | if (this.IsNewLineAfterSpace(i, leadingTrivia) || 40 | (isEndOfFile && this.IsSpaceBeforeEndOfFile(i, leadingTrivia))) 41 | { 42 | edits.Add(new TextEditInfo(new Range(start, length), string.Empty)); 43 | } 44 | 45 | start += length; 46 | } 47 | 48 | return edits; 49 | } 50 | 51 | private bool IsNewLineAfterSpace(int index, List triviaList) 52 | { 53 | if (index + 1 >= triviaList.Count) 54 | { 55 | return false; 56 | } 57 | 58 | return triviaList[index].Type == SyntaxKind.Whitespace 59 | && triviaList[index + 1].Type == SyntaxKind.Newline; 60 | } 61 | 62 | private bool IsSpaceBeforeEndOfFile(int index, List triviaList) 63 | { 64 | if (triviaList == null || index >= triviaList.Count) 65 | { 66 | return false; 67 | } 68 | 69 | return triviaList[index].Type == SyntaxKind.Whitespace; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/6_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\EquivalentAssignmentWithNewLine1.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_6 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.AssignmentStatementNode); 18 | { 19 | t.N(SyntaxKind.VarList); 20 | { 21 | t.N(SyntaxKind.NameVar); 22 | { 23 | t.N(SyntaxKind.Identifier); 24 | } 25 | } 26 | t.N(SyntaxKind.AssignmentOperator); 27 | t.N(SyntaxKind.ExpList); 28 | { 29 | t.N(SyntaxKind.SimpleExpression); 30 | { 31 | t.N(SyntaxKind.Number); 32 | } 33 | } 34 | } 35 | t.N(SyntaxKind.AssignmentStatementNode); 36 | { 37 | t.N(SyntaxKind.VarList); 38 | { 39 | t.N(SyntaxKind.NameVar); 40 | { 41 | t.N(SyntaxKind.Identifier); 42 | } 43 | } 44 | t.N(SyntaxKind.AssignmentOperator); 45 | t.N(SyntaxKind.ExpList); 46 | { 47 | t.N(SyntaxKind.BinaryOperatorExpression); 48 | { 49 | t.N(SyntaxKind.NameVar); 50 | { 51 | t.N(SyntaxKind.Identifier); 52 | } 53 | t.N(SyntaxKind.MultiplyOperator); 54 | t.N(SyntaxKind.SimpleExpression); 55 | { 56 | t.N(SyntaxKind.Number); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | t.N(SyntaxKind.EndOfFile); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/7_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\EquivalentAssignmentWithNewLine2.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_7 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.AssignmentStatementNode); 18 | { 19 | t.N(SyntaxKind.VarList); 20 | { 21 | t.N(SyntaxKind.NameVar); 22 | { 23 | t.N(SyntaxKind.Identifier); 24 | } 25 | } 26 | t.N(SyntaxKind.AssignmentOperator); 27 | t.N(SyntaxKind.ExpList); 28 | { 29 | t.N(SyntaxKind.SimpleExpression); 30 | { 31 | t.N(SyntaxKind.Number); 32 | } 33 | } 34 | } 35 | t.N(SyntaxKind.AssignmentStatementNode); 36 | { 37 | t.N(SyntaxKind.VarList); 38 | { 39 | t.N(SyntaxKind.NameVar); 40 | { 41 | t.N(SyntaxKind.Identifier); 42 | } 43 | } 44 | t.N(SyntaxKind.AssignmentOperator); 45 | t.N(SyntaxKind.ExpList); 46 | { 47 | t.N(SyntaxKind.BinaryOperatorExpression); 48 | { 49 | t.N(SyntaxKind.NameVar); 50 | { 51 | t.N(SyntaxKind.Identifier); 52 | } 53 | t.N(SyntaxKind.MultiplyOperator); 54 | t.N(SyntaxKind.SimpleExpression); 55 | { 56 | t.N(SyntaxKind.Number); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | t.N(SyntaxKind.EndOfFile); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/LanguageModel/SourceText.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | using System.Collections.Generic; 4 | using System.Collections.Immutable; 5 | using System.IO; 6 | using System.Text; 7 | using LanguageService.Text; 8 | using Validation; 9 | 10 | namespace LanguageService 11 | { 12 | public class SourceText 13 | { 14 | public SourceText(string text) 15 | { 16 | Requires.NotNull(text, nameof(text)); 17 | this.text = text; 18 | this.Lines = this.GetLines(); 19 | } 20 | 21 | private string text; 22 | 23 | public ImmutableArray Lines { get; } 24 | 25 | public TextReader TextReader => new StringReader(this.text); 26 | 27 | public int? GetLineNumberFromIndex(int index) 28 | { 29 | for (int i = 0; i < this.Lines.Length; ++i) 30 | { 31 | if (index >= this.Lines[i].Start && index < this.Lines[i].End) 32 | { 33 | return i; 34 | } 35 | } 36 | 37 | return null; 38 | } 39 | 40 | private ImmutableArray GetLines() 41 | { 42 | List lines = new List(); 43 | 44 | StringBuilder currentLine = new StringBuilder(); 45 | 46 | int start = 0; 47 | 48 | bool addLine = false; 49 | 50 | for (int i = 0; i < this.text.Length; ++i) 51 | { 52 | if (addLine) 53 | { 54 | addLine = false; 55 | lines.Add(new SourceTextLine(currentLine.ToString(), start, i - 1 - start)); 56 | currentLine.Clear(); 57 | start = i - 1; 58 | } 59 | 60 | currentLine.Append(this.text[i]); 61 | 62 | if (this.text[i] == '\r') 63 | { 64 | addLine = true; 65 | 66 | if (i < this.text.Length - 1 || this.text[i + 1] == '\n') 67 | { 68 | i++; 69 | currentLine.Append(this.text[i]); 70 | continue; 71 | } 72 | 73 | continue; 74 | } 75 | 76 | if (this.text[i] == '\n') 77 | { 78 | addLine = true; 79 | } 80 | } 81 | 82 | if (currentLine.Length > 0) 83 | { 84 | lines.Add(new SourceTextLine(currentLine.ToString(), start, this.text.Length - start)); 85 | } 86 | 87 | return lines.ToImmutableArray(); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/AD7.Impl/AD7Expression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.VisualStudio.Debugger.Interop; 5 | 6 | namespace Microsoft.VisualStudio.Debugger.Lua 7 | { 8 | // This class represents a succesfully parsed expression to the debugger. 9 | // It is returned as a result of a successful call to IDebugExpressionContext2.ParseText 10 | // It allows the debugger to obtain the values of an expression in the debuggee. 11 | // For the purposes of this sample, this means obtaining the values of locals and parameters from a stack frame. 12 | public class AD7Expression : IDebugExpression2 , IDebugExpressionEvaluator 13 | { 14 | private Variable m_var; 15 | 16 | public AD7Expression(Variable var) 17 | { 18 | m_var = var; 19 | } 20 | 21 | public int Abort() 22 | { 23 | return VSConstants.E_NOTIMPL; 24 | } 25 | 26 | public int EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback) 27 | { 28 | return VSConstants.E_NOTIMPL; 29 | } 30 | 31 | public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) 32 | { 33 | ppResult = new AD7Property(m_var); 34 | return VSConstants.S_OK; 35 | } 36 | 37 | public int GetMethodLocationProperty(string upstrFullyQualifiedMethodPlusOffset, IDebugSymbolProvider pSymbolProvider, IDebugAddress pAddress, IDebugBinder pBinder, out IDebugProperty2 ppProperty) 38 | { 39 | ppProperty = null; 40 | return VSConstants.E_NOTIMPL; 41 | } 42 | 43 | public int GetMethodProperty(IDebugSymbolProvider pSymbolProvider, IDebugAddress pAddress, IDebugBinder pBinder, int fIncludeHiddenLocals, out IDebugProperty2 ppProperty) 44 | { 45 | AD7Property method = new AD7Property(m_var); 46 | ppProperty = method; 47 | 48 | return VSConstants.S_OK; 49 | } 50 | 51 | public int Parse(string upstrExpression, enum_PARSEFLAGS dwFlags, uint nRadix, out string pbstrError, out uint pichError, out IDebugParsedExpression ppParsedExpression) 52 | { 53 | pbstrError = ""; 54 | pichError = 0; 55 | ppParsedExpression = null; 56 | return VSConstants.E_NOTIMPL; 57 | } 58 | 59 | public int SetLocale(ushort wLangID) 60 | { 61 | return VSConstants.E_NOTIMPL; 62 | } 63 | 64 | public int SetRegistryRoot(string ustrRegistryRoot) 65 | { 66 | return VSConstants.E_NOTIMPL; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/LuaVSHost/LuaLanguageServiceThemes.pkgdef: -------------------------------------------------------------------------------- 1 | [$RootKey$\Themes\{de3dbbcd-f642-433c-8353-8f1df4370aba}\LuaClassificationColors] 2 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,80,80,80,ff,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,00,00,00,ff,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff 3 | 4 | [$RootKey$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}\LuaClassificationColors] 5 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,7f,7f,7f,ff,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,ee,ee,ee,ff,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,bd,63,c5,ff,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,bd,63,c5,ff 6 | 7 | [$RootKey$\Themes\{a4d6a176-b948-4b29-8c66-53c97a1ed7d0}\LuaClassificationColors] 8 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,80,80,80,ff,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,00,00,00,ff,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff 9 | 10 | [$RootKey$\Themes\{a5c004b4-2d4b-494e-bf01-45fc492522c7}\LuaClassificationColors] 11 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00 12 | -------------------------------------------------------------------------------- /src/ProjectLauncher/LuaLanguageServiceThemes.pkgdef: -------------------------------------------------------------------------------- 1 | [$RootKey$\Themes\{de3dbbcd-f642-433c-8353-8f1df4370aba}\LuaClassificationColors] 2 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,80,80,80,ff,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,00,00,00,ff,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff 3 | 4 | [$RootKey$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}\LuaClassificationColors] 5 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,7f,7f,7f,ff,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,ee,ee,ee,ff,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,bd,63,c5,ff,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,bd,63,c5,ff 6 | 7 | [$RootKey$\Themes\{a4d6a176-b948-4b29-8c66-53c97a1ed7d0}\LuaClassificationColors] 8 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,80,80,80,ff,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,00,00,00,ff,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,01,6f,00,8a,ff 9 | 10 | [$RootKey$\Themes\{a5c004b4-2d4b-494e-bf01-45fc492522c7}\LuaClassificationColors] 11 | "Data"=hex:c9,00,00,00,0b,00,00,00,01,00,00,00,85,56,a0,75,a8,00,ed,4d,ba,e5,e7,a5,0b,fa,92,9a,04,00,00,00,1c,00,00,00,4c,75,61,50,61,72,61,6d,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00,1d,00,00,00,4c,75,61,47,6c,6f,62,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00,1c,00,00,00,4c,75,61,4c,6f,63,61,6c,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00,1c,00,00,00,4c,75,61,46,69,65,6c,64,43,6c,61,73,73,69,66,69,63,61,74,69,6f,6e,46,6f,72,6d,61,74,05,00,00,00,00,03,08,00,00,00 12 | -------------------------------------------------------------------------------- /src/LuaDebuggerLauncher/[PlatformName]/ImportAfter/LuaDebugger.xaml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 39 | 40 | 41 | 45 | 46 | -------------------------------------------------------------------------------- /src/Formatting.Tests/FormatRulesAndIndentation/TrailingWhitespaceTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace Formatting.Tests 4 | { 5 | using Xunit; 6 | 7 | public class TrailingWhitespaceTests 8 | { 9 | private delegate void TestFunction(string original, string expected); 10 | private TestFunction GeneralTest = Tester.FormattingTest; 11 | 12 | [Fact] 13 | public void Basic() 14 | { 15 | string original = "x = 10 "; 16 | string expected = "x = 10"; 17 | this.GeneralTest(original, expected); 18 | } 19 | 20 | [Fact] 21 | public void LotsOfTrailing() 22 | { 23 | string original = @" 24 | x = 10 25 | 26 | x = 10 "; 27 | string expected = @" 28 | x = 10 29 | 30 | x = 10"; 31 | this.GeneralTest(original, expected); 32 | } 33 | 34 | [Fact] 35 | public void Comments1() 36 | { 37 | string original = @"x = 10 -- hello world "; 38 | this.GeneralTest(original, original); 39 | } 40 | 41 | [Fact] 42 | public void Comments2() 43 | { 44 | string original = "x = 10 --[[comment]] "; 45 | string expected = "x = 10 --[[comment]]"; 46 | this.GeneralTest(original, expected); 47 | } 48 | 49 | [Fact] 50 | public void MultipleLines() 51 | { 52 | string original = @" 53 | x = 10 54 | -- comment here 55 | --[[ block 56 | comment 57 | here]] 58 | x = x + 1 "; 59 | string expected = @" 60 | x = 10 61 | -- comment here 62 | --[[ block 63 | comment 64 | here]] 65 | x = x + 1"; 66 | this.GeneralTest(original, expected); 67 | } 68 | 69 | [Fact] 70 | public void TrailingWhiteSpaceBeforeEof() 71 | { 72 | string original = @"x = 10 73 | "; 74 | string expected = @"x = 10 75 | "; 76 | this.GeneralTest(original, expected); 77 | } 78 | 79 | [Fact] 80 | public void FunctionTrailing() 81 | { 82 | string original = @" 83 | foo = function () 84 | 85 | end"; 86 | string expected = @" 87 | foo = function () 88 | 89 | end"; 90 | this.GeneralTest(original, expected); 91 | } 92 | 93 | [Fact] 94 | public void EmbeddedFunctionTrailing() 95 | { 96 | string original = @" 97 | foo = function () 98 | t = { 99 | 100 | } 101 | end"; 102 | string expected = @" 103 | foo = function () 104 | t = { 105 | 106 | } 107 | end"; 108 | this.GeneralTest(original, expected); 109 | } 110 | 111 | 112 | } 113 | } -------------------------------------------------------------------------------- /src/LanguageModel.Tests/TestGeneration/UnvalidatedGeneratedTests/22_Generated.cs: -------------------------------------------------------------------------------- 1 | //C:\Users\t-kevimi\\Documents\\LuaTests\Lua Files for Testing\NestedFunctionCallStatement.lua 2 | namespace LanguageModel.Tests.GeneratedTestFiles 3 | { 4 | using LanguageModel.Tests.TestGeneration; 5 | using LanguageService; 6 | using Xunit; 7 | 8 | internal class Generated_22 9 | { 10 | [Fact] 11 | public void Test(Tester t) 12 | { 13 | t.N(SyntaxKind.ChunkNode); 14 | { 15 | t.N(SyntaxKind.BlockNode); 16 | { 17 | t.N(SyntaxKind.FunctionCallStatementNode); 18 | { 19 | t.N(SyntaxKind.NameVar); 20 | { 21 | t.N(SyntaxKind.Identifier); 22 | } 23 | t.N(SyntaxKind.ParenArg); 24 | { 25 | t.N(SyntaxKind.OpenParen); 26 | t.N(SyntaxKind.ExpList); 27 | { 28 | t.N(SyntaxKind.FunctionCallExp); 29 | { 30 | t.N(SyntaxKind.NameVar); 31 | { 32 | t.N(SyntaxKind.Identifier); 33 | } 34 | t.N(SyntaxKind.ParenArg); 35 | { 36 | t.N(SyntaxKind.OpenParen); 37 | t.N(SyntaxKind.ExpList); 38 | { 39 | t.N(SyntaxKind.BinaryOperatorExpression); 40 | { 41 | t.N(SyntaxKind.SimpleExpression); 42 | { 43 | t.N(SyntaxKind.Number); 44 | } 45 | t.N(SyntaxKind.MultiplyOperator); 46 | t.N(SyntaxKind.SimpleExpression); 47 | { 48 | t.N(SyntaxKind.Number); 49 | } 50 | } 51 | } 52 | t.N(SyntaxKind.CloseParen); 53 | } 54 | } 55 | } 56 | t.N(SyntaxKind.CloseParen); 57 | } 58 | } 59 | } 60 | t.N(SyntaxKind.EndOfFile); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/LuaVSHost/Shared/CommandFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using Microsoft.VisualStudio.OLE.Interop; 5 | 6 | namespace Microsoft.VisualStudio.LanguageServices.Lua.Shared 7 | { 8 | internal class CommandFilter : IOleCommandTarget 9 | { 10 | public CommandFilter() 11 | { 12 | this.MiniFilters = new List(); 13 | } 14 | 15 | public IOleCommandTarget Next { get; set; } 16 | 17 | public IList MiniFilters { get; private set; } 18 | 19 | internal static char GetTypedChar(IntPtr pvaIn) 20 | { 21 | return (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn); 22 | } 23 | 24 | public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) 25 | { 26 | bool handled = false; 27 | int hresult = VSConstants.S_OK; 28 | 29 | // Give the commands a chance to pre-process the command 30 | foreach (IMiniCommandFilter filter in this.MiniFilters) 31 | { 32 | handled = filter.PreProcessCommand(pguidCmdGroup, nCmdID, pvaIn); 33 | 34 | if (handled) 35 | { 36 | break; 37 | } 38 | } 39 | 40 | if (!handled) 41 | { 42 | hresult = this.Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); 43 | } 44 | 45 | if (ErrorHandler.Succeeded(hresult)) 46 | { 47 | // Let the command filters post-process any successful commands 48 | foreach (IMiniCommandFilter filter in this.MiniFilters) 49 | { 50 | // Let all commands post-process for now. 51 | filter.PostProcessCommand(pguidCmdGroup, nCmdID, pvaIn, handled); 52 | } 53 | } 54 | 55 | return hresult; 56 | } 57 | 58 | public void Close() 59 | { 60 | foreach (IMiniCommandFilter filter in this.MiniFilters) 61 | { 62 | filter.Close(); 63 | } 64 | 65 | this.MiniFilters.Clear(); 66 | } 67 | 68 | public int QueryStatus(ref Guid pguidCmdGroup, uint commandsCount, OLECMD[] prgCmds, IntPtr pCmdText) 69 | { 70 | foreach (IMiniCommandFilter filter in this.MiniFilters) 71 | { 72 | OLECMDF commandStatus; 73 | if (filter.QueryCommandStatus(pguidCmdGroup, prgCmds[0].cmdID, pCmdText, out commandStatus)) 74 | { 75 | prgCmds[0].cmdf = (uint)commandStatus; 76 | return VSConstants.S_OK; 77 | } 78 | } 79 | 80 | return this.Next.QueryStatus(pguidCmdGroup, commandsCount, prgCmds, pCmdText); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.Debugger.Lua/AD7.Impl/AD7MemoryAddress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.VisualStudio.Debugger.Interop; 5 | 6 | namespace Microsoft.VisualStudio.Debugger.Lua 7 | { 8 | // And implementation of IDebugCodeContext2 and IDebugMemoryContext2. 9 | // IDebugMemoryContext2 represents a position in the address space of the machine running the program being debugged. 10 | // IDebugCodeContext2 represents the starting position of a code instruction. 11 | // For most run-time architectures today, a code context can be thought of as an address in a program's execution stream. 12 | internal class AD7MemoryAddress : IDebugCodeContext2, IDebugCodeContext100 13 | { 14 | private readonly AD7Engine m_engine; 15 | 16 | private IDebugDocumentContext2 m_documentContext; 17 | 18 | public AD7MemoryAddress(AD7Engine engine) 19 | { 20 | m_engine = engine; 21 | } 22 | 23 | public void SetDocumentContext(IDebugDocumentContext2 docContext) 24 | { 25 | m_documentContext = docContext; 26 | } 27 | 28 | #region IDebugCodeContext2 29 | 30 | public int GetName(out string pbstrName) 31 | { 32 | pbstrName = ""; 33 | return VSConstants.E_NOTIMPL; 34 | } 35 | 36 | public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo) 37 | { 38 | return VSConstants.E_NOTIMPL; 39 | } 40 | 41 | public int Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) 42 | { 43 | ppMemCxt = null; 44 | return VSConstants.E_NOTIMPL; 45 | } 46 | 47 | public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) 48 | { 49 | ppMemCxt = null; 50 | return VSConstants.E_NOTIMPL; 51 | } 52 | 53 | public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext) 54 | { 55 | pdwMemoryContext = 0; 56 | return VSConstants.E_NOTIMPL; 57 | } 58 | 59 | public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt) 60 | { 61 | ppSrcCxt = m_documentContext; 62 | return VSConstants.S_OK; 63 | } 64 | 65 | public int GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage) 66 | { 67 | pbstrLanguage = "Lua"; 68 | pguidLanguage = new Guid("88A1F488-9D00-4896-A255-6F8251208B90"); // TODO 69 | return VSConstants.S_OK; 70 | } 71 | 72 | #endregion 73 | 74 | #region IDebugCodeContext100 75 | 76 | public int GetProgram(out IDebugProgram2 ppProgram) 77 | { 78 | ppProgram = null; 79 | return VSConstants.E_NOTIMPL; 80 | } 81 | 82 | #endregion 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/ProjectLauncher/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ProjectLauncher { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectLauncher.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/LanguageModel/Formatting/Options/DisableableRules.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | 3 | namespace LanguageService.Formatting.Options 4 | { 5 | /// 6 | /// The OptionalRuleGroups represent sets of rules that can enable/disable formatting options. 7 | /// 8 | public enum DisableableRules 9 | { 10 | /// 11 | /// The set of rules that make up the wrapping in for loops (single-lined) 12 | /// 13 | WrappingOneLineForFors, 14 | 15 | /// 16 | /// The set of rules that make up the wrapping in functions (single-lined) 17 | /// 18 | WrappingOneLineForFunctions, 19 | 20 | /// 21 | /// The set of rules that make up the wrapping for table constructors (single-lined) 22 | /// 23 | WrappingOneLineForTableConstructors, 24 | 25 | /// 26 | /// The set of rules that make up the wrapping for table constructors (multi-lined) 27 | /// 28 | WrappingMoreLinesForTableConstructors, 29 | 30 | /// 31 | /// The set of individual rules that insert a space before open parenthesis' 32 | /// 33 | SpaceBeforeOpenParenthesis, 34 | 35 | /// 36 | /// The set of rules that insert spaces inside of parenthesis' 37 | /// 38 | SpaceOnInsideOfParenthesis, 39 | 40 | /// 41 | /// The set of rules that insert spaces inside of curly braces 42 | /// 43 | SpaceOnInsideOfCurlyBraces, 44 | 45 | /// 46 | /// The set of rules that insert spaces inside of square brackets 47 | /// 48 | SpaceOnInsideOfSquareBrackets, 49 | 50 | /// 51 | /// The set of rules that insert spaces after commas 52 | /// 53 | SpaceAfterCommas, 54 | 55 | /// 56 | /// The set of rules that insert spaces before and after binary operations 57 | /// 58 | SpaceBeforeAndAfterBinaryOperations, 59 | 60 | /// 61 | /// The set of rules that insert spaces before and after assignment operators in fields 62 | /// 63 | SpaceBeforeAndAfterAssignmentForField, 64 | 65 | /// 66 | /// The set of rules that insert spaces before and after asssignment operators in statements 67 | /// 68 | SpaceBeforeAndAfterAssignmentForStatement, 69 | 70 | /// 71 | /// The set of rules that insert spaces before and after assignment in for loops 72 | /// 73 | SpaceBeforeAndAfterAssignmentInForLoopHeader, 74 | 75 | /// 76 | /// The set of rules that delete spaces after indicies in the for loop header 77 | /// 78 | NoSpaceBeforeAndAfterIndiciesInForLoopHeader 79 | } 80 | } 81 | --------------------------------------------------------------------------------