Skip to content

Commit 1e4cea0

Browse files
committed
Several updates to Aphid VS support, added isolated shell.
1 parent db9bd20 commit 1e4cea0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3950
-23
lines changed

.gitattributes

+47-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Components.Aphid.Tests.Integration/StringTests.cs -text
4646
Components.Aphid.VSPackage/AphidAuthoringScope.cs -text
4747
Components.Aphid.VSPackage/AphidLanguageService.cs -text
4848
Components.Aphid.VSPackage/AphidPackage.cs -text
49-
Components.Aphid.VSPackage/AphidPackagePackage.cs -text
5049
Components.Aphid.VSPackage/AphidScanner.cs -text
5150
Components.Aphid.VSPackage/Components.Aphid.VSPackage.csproj -text
5251
Components.Aphid.VSPackage/Components.Aphid.VSPackage.csproj.user -text
@@ -60,6 +59,7 @@ Components.Aphid.VSPackage/Resources/Package.ico -text svneol=unset#unset
6059
Components.Aphid.VSPackage/TokenHelper.cs -text
6160
Components.Aphid.VSPackage/VSPackage.resx -text
6261
Components.Aphid.VSPackage/source.extension.vsixmanifest -text
62+
Components.Aphid.VSPackage/todo.txt -text
6363
Components.Aphid/App.config -text
6464
Components.Aphid/Components.Aphid.csproj -text
6565
Components.Aphid/Components.Aphid.csproj.vspscc -text
@@ -576,4 +576,50 @@ ReleasePackager/Release.cs -text
576576
ReleasePackager/ReleasePackager.csproj -text
577577
ReleasePackager/ReleasePackager.csproj.vspscc -text
578578
ReleasePackager/ReleaseProject.cs -text
579+
VSShellStub1/VSShellStub1.AboutBoxPackage/AboutBox.xaml -text
580+
VSShellStub1/VSShellStub1.AboutBoxPackage/AboutBox.xaml.cs -text
581+
VSShellStub1/VSShellStub1.AboutBoxPackage/Guids.cs -text
582+
VSShellStub1/VSShellStub1.AboutBoxPackage/Key.snk -text svneol=unset#unset
583+
VSShellStub1/VSShellStub1.AboutBoxPackage/PkgCmdID.cs -text
584+
VSShellStub1/VSShellStub1.AboutBoxPackage/Properties/AssemblyInfo.cs -text
585+
VSShellStub1/VSShellStub1.AboutBoxPackage/VSPackage.resx -text
586+
VSShellStub1/VSShellStub1.AboutBoxPackage/VSShellStub1.AboutBoxPackage.cs -text
587+
VSShellStub1/VSShellStub1.AboutBoxPackage/VSShellStub1.AboutBoxPackage.csproj -text
588+
VSShellStub1/VSShellStub1.AboutBoxPackage/VSShellStub1.AboutBoxPackage.csproj.vspscc -text
589+
VSShellStub1/VSShellStub1.AboutBoxPackage/VSShellStub1.AboutBoxPackage.vsct -text
590+
VSShellStub1/VSShellStub1.AboutBoxPackage/source.extension.vsixmanifest -text
591+
VSShellStub1/VSShellStub1/ApplicationIcon.ico -text svneol=unset#unset
592+
VSShellStub1/VSShellStub1/DebuggerProxy.dll -text svneol=unset#unset
593+
VSShellStub1/VSShellStub1/DebuggerProxy.dll.manifest -text
594+
VSShellStub1/VSShellStub1/Documentation/Images/AppEnv.jpg -text svneol=unset#unset
595+
VSShellStub1/VSShellStub1/Documentation/ReadMe.htm -text
596+
VSShellStub1/VSShellStub1/General.vssettings -text
597+
VSShellStub1/VSShellStub1/Resource.h -text svneol=unset#unset
598+
VSShellStub1/VSShellStub1/ShellSection.cpp -text
599+
VSShellStub1/VSShellStub1/ShellSection.h -text
600+
VSShellStub1/VSShellStub1/Splash.bmp -text svneol=unset#unset
601+
VSShellStub1/VSShellStub1/VSShellStub1.Application.pkgdef -text svneol=unset#unset
602+
VSShellStub1/VSShellStub1/VSShellStub1.cpp -text svneol=unset#unset
603+
VSShellStub1/VSShellStub1/VSShellStub1.exe.config -text
604+
VSShellStub1/VSShellStub1/VSShellStub1.exe.manifest -text
605+
VSShellStub1/VSShellStub1/VSShellStub1.h -text svneol=unset#unset
606+
VSShellStub1/VSShellStub1/VSShellStub1.pkgdef -text
607+
VSShellStub1/VSShellStub1/VSShellStub1.pkgundef -text
608+
VSShellStub1/VSShellStub1/VSShellStub1.rc -text
609+
VSShellStub1/VSShellStub1/VSShellStub1.reg -text svneol=unset#unset
610+
VSShellStub1/VSShellStub1/VSShellStub1.vcxproj -text
611+
VSShellStub1/VSShellStub1/VSShellStub1.vcxproj.filters -text
612+
VSShellStub1/VSShellStub1/VSShellStub1.vcxproj.vspscc -text
613+
VSShellStub1/VSShellStub1/VSShellStub1.winprf -text
614+
VSShellStub1/VSShellStub1/VsSDK.props -text
615+
VSShellStub1/VSShellStub1/small.ico -text svneol=unset#unset
616+
VSShellStub1/VSShellStub1/stdafx.cpp -text svneol=unset#unset
617+
VSShellStub1/VSShellStub1/stdafx.h -text svneol=unset#unset
618+
VSShellStub1/VSShellStub1UI/ApplicationCommands.vsct -text
619+
VSShellStub1/VSShellStub1UI/VSShellStub1UI.cpp -text svneol=unset#unset
620+
VSShellStub1/VSShellStub1UI/VSShellStub1UI.rc -text
621+
VSShellStub1/VSShellStub1UI/VSShellStub1UI.vcxproj -text
622+
VSShellStub1/VSShellStub1UI/VSShellStub1UI.vcxproj.filters -text
623+
VSShellStub1/VSShellStub1UI/VSShellStub1UI.vcxproj.vspscc -text
624+
VSShellStub1/VSShellStub1UI/resource.h -text svneol=unset#unset
579625
/build.cmd -text

Components.Aphid.VSPackage/AphidAuthoringScope.cs

+50-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,55 @@
77

88
namespace Components.Aphid.VSPackage
99
{
10+
public class AphidDeclaration
11+
{
12+
public string Name { get; set; }
13+
14+
public string Description { get; set; }
15+
16+
public string DisplayText { get; set; }
17+
18+
public AphidDeclaration(string name, string description, string displayText)
19+
{
20+
Name = name;
21+
Description = description;
22+
DisplayText = displayText;
23+
}
24+
}
25+
26+
public class AphidDeclarations : Declarations
27+
{
28+
private List<AphidDeclaration> _declarations = new List<AphidDeclaration>()
29+
{
30+
new AphidDeclaration("test", "a test", "testDisplay")
31+
};
32+
33+
public override int GetCount()
34+
{
35+
return _declarations.Count;
36+
}
37+
38+
public override string GetDescription(int index)
39+
{
40+
return _declarations[index].Description;
41+
}
42+
43+
public override string GetDisplayText(int index)
44+
{
45+
return _declarations[index].DisplayText;
46+
}
47+
48+
public override int GetGlyph(int index)
49+
{
50+
return 0;
51+
}
52+
53+
public override string GetName(int index)
54+
{
55+
return _declarations[index].Name;
56+
}
57+
}
58+
1059
public class AphidAuthoringScope : AuthoringScope
1160
{
1261
public override string GetDataTipText(int line, int col, out Microsoft.VisualStudio.TextManager.Interop.TextSpan span)
@@ -17,7 +66,7 @@ public override string GetDataTipText(int line, int col, out Microsoft.VisualStu
1766

1867
public override Declarations GetDeclarations(Microsoft.VisualStudio.TextManager.Interop.IVsTextView view, int line, int col, TokenInfo info, ParseReason reason)
1968
{
20-
return null;
69+
return new AphidDeclarations();
2170
}
2271

2372
public override Methods GetMethods(int line, int col, string name)

Components.Aphid.VSPackage/AphidLanguageService.cs

+69-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ public override LanguagePreferences GetLanguagePreferences()
2424
{
2525
return new LanguagePreferences()
2626
{
27+
EnableMatchBracesAtCaret = true,
2728
EnableCodeSense = true,
2829
CodeSenseDelay = 500,
2930
AutoListMembers = true,
3031
EnableFormatSelection = true,
3132
EnableMatchBraces = true,
3233
LineNumbers = true,
3334
EnableCommenting = true,
34-
EnableShowMatchingBrace = true,
35+
EnableShowMatchingBrace = true,
3536
IndentStyle = IndentingStyle.Smart,
3637
EnableQuickInfo = true,
3738
MaxErrorMessages = 100,
39+
HighlightMatchingBraceFlags = _HighlightMatchingBraceFlags.HMB_USERECTANGLEBRACES,
40+
3841

3942
};
4043
}
@@ -46,7 +49,7 @@ public override IScanner GetScanner(Microsoft.VisualStudio.TextManager.Interop.I
4649

4750
public override string Name
4851
{
49-
get { return "Aphid Language Service"; }
52+
get { return "Aphid"; }
5053
}
5154

5255
private void CheckParseRequest(ParseRequest req)
@@ -74,14 +77,77 @@ private void CheckParseRequest(ParseRequest req)
7477
}
7578
}
7679

80+
static TextSpan CreateSpan(int line, int col)
81+
{
82+
return new TextSpan()
83+
{
84+
iStartLine = line,
85+
iStartIndex = col,
86+
iEndLine = line,
87+
iEndIndex = col + 1,
88+
};
89+
}
90+
7791
public override AuthoringScope ParseSource(ParseRequest req)
7892
{
7993
switch (req.Reason)
8094
{
81-
case ParseReason.MatchBraces:
95+
case ParseReason.QuickInfo:
96+
break;
97+
98+
case ParseReason.DisplayMemberList:
99+
break;
100+
101+
case ParseReason.CompleteWord:
82102
break;
83103

104+
case ParseReason.MatchBraces:
105+
case ParseReason.MemberSelectAndHighlightBraces:
84106
case ParseReason.HighlightBraces:
107+
var braces = TokenHelper.GetBraces(
108+
req.Text,
109+
req.Line,
110+
req.Col - 1);
111+
112+
if (braces != null)
113+
{
114+
115+
req.Sink.MatchPair(CreateSpan(braces[0][0], braces[0][1]), CreateSpan(braces[1][0], braces[1][1]), 1);
116+
}
117+
118+
var index = TokenHelper.GetIndex(req.Text, req.Line, req.Col - 1);
119+
var str = req.Text.Substring(index);
120+
var tokens = new AphidLexer(str).GetAllTokens();
121+
122+
var depth = 1;
123+
var rightBraceIndex = -1;
124+
for (int i = 1; i < tokens.Count; i++)
125+
{
126+
switch (tokens[i].TokenType)
127+
{
128+
case AphidTokenType.LeftBrace:
129+
depth++;
130+
break;
131+
132+
case AphidTokenType.RightBrace:
133+
depth--;
134+
break;
135+
}
136+
137+
if (depth == 0)
138+
{
139+
rightBraceIndex = index + tokens[i].Index;
140+
break;
141+
}
142+
}
143+
144+
if (rightBraceIndex != -1)
145+
{
146+
var rightLineCol = TokenHelper.GetLineCol(req.Text, rightBraceIndex);
147+
148+
req.Sink.MatchPair(CreateSpan(req.Line, req.Col - 1), CreateSpan(rightLineCol.Item1, rightLineCol.Item2), 1);
149+
}
150+
85151
break;
86152

87153
case ParseReason.Check:

Components.Aphid.VSPackage/AphidPackage.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ namespace TestLanguagePackage
1818
{
1919
[ProvideService(typeof(AphidLanguageService))]
2020
[ProvideLanguageExtension(typeof(AphidLanguageService), ".alx")]
21-
[ProvideLanguageService(typeof(AphidLanguageService), "Aphid Language", 0)]
21+
[ProvideLanguageService(
22+
typeof(AphidLanguageService),
23+
"Aphid Language",
24+
0)]
2225
[Guid("2e5ec861-04b2-4a6c-ad40-8e1e0ee0ceb6")]
2326
public class AphidPackage : Package, IOleComponent
2427
{

Components.Aphid.VSPackage/AphidScanner.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
101101
break;
102102

103103
case AphidTokenType.LeftBrace:
104+
case AphidTokenType.RightBrace:
105+
case AphidTokenType.LeftBracket:
106+
case AphidTokenType.RightBracket:
104107
tokenInfo.Trigger = TokenTriggers.MatchBraces;
105108
break;
106109

@@ -110,11 +113,18 @@ public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
110113
break;
111114

112115
case AphidTokenType.LeftParenthesis:
113-
tokenInfo.Trigger = TokenTriggers.ParameterStart;
116+
tokenInfo.Trigger = TokenTriggers.MatchBraces;
117+
//tokenInfo.Trigger = TokenTriggers.ParameterStart;
114118
break;
115119

116120
case AphidTokenType.RightParenthesis:
117-
tokenInfo.Trigger = TokenTriggers.ParameterEnd;
121+
tokenInfo.Trigger = TokenTriggers.MatchBraces;
122+
//tokenInfo.Trigger = TokenTriggers.ParameterEnd;
123+
break;
124+
125+
case AphidTokenType.Comment:
126+
tokenInfo.Type = TokenType.Comment;
127+
tokenInfo.Color = TokenColor.Comment;
118128
break;
119129
}
120130

@@ -126,7 +136,7 @@ public void SetSource(string source, int offset)
126136
_index = 0;
127137
try
128138
{
129-
_tokens = new AphidLexer(source).GetTokens();
139+
_tokens = new AphidLexer(source).GetAllTokens();
130140
}
131141
catch
132142
{

Components.Aphid.VSPackage/Components.Aphid.VSPackage.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
</ItemGroup>
176176
<ItemGroup>
177177
<Content Include="Resources\Package.ico" />
178+
<Resource Include="todo.txt" />
178179
</ItemGroup>
179180
<ItemGroup>
180181
<ProjectReference Include="..\Components.Aphid\Components.Aphid.csproj">

0 commit comments

Comments
 (0)