logic: visual studio solution parsing
Can now parse visual studio solutions. VS Plugin can send a command, parsing is implemented in Coati. Some minor changes: added project file icon, added language check to vs plugin
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,32 +35,55 @@
|
||||
<Group guid="guidCoatiPluginCmdSet" id="MyMenuGroup" priority="0x0600">
|
||||
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
|
||||
</Group>
|
||||
|
||||
|
||||
<Group guid="guidCoatiPluginCmdSet" id="TopLevelMenu" priority="0x0600">
|
||||
<Parent guid="guidSHLMainMenu" id="IDM_VS_TOOL_MAINMENU"/>
|
||||
</Group>
|
||||
|
||||
<Group guid="guidCoatiPluginCmdSet" id="SubMenu" priority="0x0600">
|
||||
<Parent guid="guidCoatiPluginCmdSet" id="TopLevelMenu"/>
|
||||
</Group>
|
||||
|
||||
</Groups>
|
||||
|
||||
<!--Buttons section. -->
|
||||
<!--This section defines the elements the user can interact with, like a menu command or a button
|
||||
or combo box in a toolbar. -->
|
||||
<Buttons>
|
||||
<!--To define a menu group you have to specify its ID, the parent menu and its display priority.
|
||||
The command is visible and enabled by default. If you need to change the visibility, status, etc, you can use
|
||||
the CommandFlag node.
|
||||
You can add more than one CommandFlag node e.g.:
|
||||
<CommandFlag>DefaultInvisible</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
If you do not want an image next to your command, remove the Icon node /> -->
|
||||
|
||||
|
||||
<Button guid="guidCoatiPluginCmdSet" id="cmdidCoatiSetActiveToken" priority="0x0100" type="Button">
|
||||
<Parent guid="guidCoatiPluginCmdSet" id="MyMenuGroup" />
|
||||
<Icon guid="icon" id="icon0" />
|
||||
<Strings>
|
||||
<ButtonText>Set active Token</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
|
||||
<Parent guid="guidCoatiPluginCmdSet" id="MyMenuGroup" />
|
||||
<Icon guid="icon" id="icon0" />
|
||||
<Strings>
|
||||
<ButtonText>Set active Token</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
|
||||
<Button guid="guidCoatiPluginCmdSet" id="cmdidCoatiCreateProject" priority="0x0100" type="Button">
|
||||
<Parent guid="guidCoatiPluginCmdSet" id="MyMenuGroup" />
|
||||
<Icon guid="icon" id="icon0" />
|
||||
<Strings>
|
||||
<ButtonText>Create Coati Project</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
|
||||
<Button guid="guidCoatiPluginCmdSet" id="cmdidCoatiCreateProject" priority="0x0100" type="Button">
|
||||
<Parent guid="guidCoatiPluginCmdSet" id="SubMenu" />
|
||||
<Icon guid="icon" id="icon0" />
|
||||
<Strings>
|
||||
<ButtonText>Create Coati Project</ButtonText>
|
||||
</Strings>
|
||||
</Button>
|
||||
|
||||
</Buttons>
|
||||
|
||||
<Menus>
|
||||
<Menu guid="guidCoatiPluginCmdSet" id="TopLevelMenu" priority="0x700" type="Menu">
|
||||
<Parent guid="guidSHLMainMenu"
|
||||
id="IDG_VS_MM_TOOLSADDINS"/>
|
||||
<Strings>
|
||||
<ButtonText>Coati</ButtonText>
|
||||
<CommandName>Coati</CommandName>
|
||||
</Strings>
|
||||
</Menu>
|
||||
</Menus>
|
||||
|
||||
</Commands>
|
||||
|
||||
@@ -81,6 +104,9 @@
|
||||
<IDSymbol name="cmdidCoatiGetActiveFileName" value="0x0102"/>
|
||||
<IDSymbol name="cmdidCoatiGetActiveLineNumber" value="0x0103"/>
|
||||
<IDSymbol name="cmdidCoatiSetActiveToken" value="0x0104"/>
|
||||
<IDSymbol name="cmdidCoatiCreateProject" value="0x0105"/>
|
||||
<IDSymbol name="TopLevelMenu" value="0x1021"/>
|
||||
<IDSymbol name="SubMenu" value="0x1022"/>
|
||||
</GuidSymbol>
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ using System.Collections.Generic;
|
||||
|
||||
using EnvDTE;
|
||||
using EnvDTE80;
|
||||
using System.Windows.Forms;
|
||||
// using System.Windows.Forms.
|
||||
|
||||
namespace CoatiSoftware.CoatiPlugin
|
||||
{
|
||||
@@ -76,6 +78,11 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
|
||||
public sealed class CoatiPluginPackage : Package
|
||||
{
|
||||
private MenuCommand _menuItemSetActiveToken = null;
|
||||
private MenuCommand _menuItemCreateProject = null;
|
||||
|
||||
private SolutionEvents _solutionEvents = null;
|
||||
|
||||
public uint ServerPort
|
||||
{
|
||||
get
|
||||
@@ -114,9 +121,52 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
if ( null != mcs )
|
||||
{
|
||||
CommandID setActiveTokenCommandID = new CommandID(GuidList.guidCoatiPluginCmdSet, (int)PkgCmdIDList.cmdidCoatiSetActiveToken);
|
||||
MenuCommand menuItemSetActiveToken = new MenuCommand(MenuItemCallback, setActiveTokenCommandID);
|
||||
mcs.AddCommand(menuItemSetActiveToken);
|
||||
CommandID createProjectID = new CommandID(GuidList.guidCoatiPluginCmdSet, (int)PkgCmdIDList.cmdidCoatiCreateProject); // cmdidCoatiCreateProject
|
||||
|
||||
_menuItemSetActiveToken = new MenuCommand(MenuItemCallback, setActiveTokenCommandID);
|
||||
_menuItemCreateProject = new MenuCommand(MenuItemCallback, createProjectID);
|
||||
|
||||
_menuItemCreateProject.Enabled = false;
|
||||
_menuItemSetActiveToken.Enabled = false;
|
||||
|
||||
mcs.AddCommand(_menuItemSetActiveToken);
|
||||
mcs.AddCommand(_menuItemCreateProject);
|
||||
}
|
||||
|
||||
DTE dte = (DTE)GetService(typeof(DTE));
|
||||
|
||||
_solutionEvents = dte.Events.SolutionEvents;
|
||||
|
||||
_solutionEvents.Opened += OnSolutionOpened;
|
||||
_solutionEvents.AfterClosing += OnSolutionClosed;
|
||||
}
|
||||
|
||||
void OnSolutionOpened()
|
||||
{
|
||||
DTE dte = (DTE)GetService(typeof(DTE));
|
||||
List<String> languages = SolutionUtility.GetSolutionLanguages(dte);
|
||||
|
||||
bool enable = true;
|
||||
foreach (String language in languages)
|
||||
{
|
||||
if(language != CodeModelLanguageConstants.vsCMLanguageVC
|
||||
&& language != CodeModelLanguageConstants.vsCMLanguageMC)
|
||||
{
|
||||
enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(enable)
|
||||
{
|
||||
_menuItemSetActiveToken.Enabled = true;
|
||||
_menuItemCreateProject.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSolutionClosed()
|
||||
{
|
||||
_menuItemSetActiveToken.Enabled = false;
|
||||
_menuItemCreateProject.Enabled = false;
|
||||
}
|
||||
|
||||
private void InitNetwork()
|
||||
@@ -132,6 +182,8 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
AsynchronousClient._onErrorCallback = new AsynchronousSocketListener.OnReadCallback(OnNetworkErrorCallback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void MenuItemCallback(object sender, EventArgs e)
|
||||
{
|
||||
MenuCommand menuCommand = sender as MenuCommand;
|
||||
@@ -148,8 +200,16 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
int lineNumber = FileUtility.GetActiveLineNumber(dte);
|
||||
int columnNumber = FileUtility.GetActiveColumnNumber(dte);
|
||||
|
||||
string message = NetworkProtocolUtility.createOutMessage(filePath + fileName, lineNumber, columnNumber);
|
||||
string message = NetworkProtocolUtility.createActivateTokenMessage(filePath + fileName, lineNumber, columnNumber);
|
||||
|
||||
AsynchronousClient.Send(message);
|
||||
}
|
||||
else if(menuCommand.CommandID.ID == (int)PkgCmdIDList.cmdidCoatiCreateProject)
|
||||
{
|
||||
string solutionName = SolutionUtility.GetSolutionPath(dte);
|
||||
|
||||
string message = NetworkProtocolUtility.createCreateProjectMessage(solutionName);
|
||||
|
||||
AsynchronousClient.Send(message);
|
||||
}
|
||||
}
|
||||
@@ -157,7 +217,7 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
|
||||
private void OnNetworkReadCallback(string message)
|
||||
{
|
||||
NetworkProtocolUtility.CursorPosition cursorPosition = NetworkProtocolUtility.parseInMessage(message);
|
||||
NetworkProtocolUtility.CursorPosition cursorPosition = NetworkProtocolUtility.parseSetCursorMessage(message);
|
||||
if (cursorPosition.Valid)
|
||||
{
|
||||
cursorPosition.ColumnNumber += 1; // VS counts columns starting at 1, coati starts at 0
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
private static string s_moveCursorPrefix = "moveCursor";
|
||||
private static string s_endOfMessageToken = "<EOM>";
|
||||
|
||||
private static string s_createProjectPrefix = "createProject";
|
||||
private static string s_ideId = "vs";
|
||||
|
||||
public class CursorPosition
|
||||
{
|
||||
private string _filePath = "";
|
||||
@@ -45,7 +48,7 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public static string createOutMessage(string filePath, int lineNumber, int columnNumber)
|
||||
public static string createActivateTokenMessage(string filePath, int lineNumber, int columnNumber)
|
||||
{
|
||||
string message = s_setActiveTokenPrefix;
|
||||
|
||||
@@ -66,10 +69,24 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: debug
|
||||
*/
|
||||
public static CursorPosition parseInMessage(string message)
|
||||
public static string createCreateProjectMessage(string solutionPath)
|
||||
{
|
||||
string message = s_createProjectPrefix;
|
||||
|
||||
message += s_divider;
|
||||
|
||||
message += solutionPath;
|
||||
|
||||
message += s_divider;
|
||||
|
||||
message += s_ideId;
|
||||
|
||||
message += s_endOfMessageToken;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static CursorPosition parseSetCursorMessage(string message)
|
||||
{
|
||||
CursorPosition result = new CursorPosition();
|
||||
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
static class PkgCmdIDList
|
||||
{
|
||||
public const uint cmdidCoatiSetActiveToken = 0x104;
|
||||
public const uint cmdidCoatiCreateProject = 0x105;
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,13 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
{
|
||||
class SolutionUtility
|
||||
{
|
||||
public static String GetSolutionPath(DTE dte)
|
||||
{
|
||||
EnvDTE.Solution solution = dte.Solution;
|
||||
|
||||
return solution.FullName;
|
||||
}
|
||||
|
||||
public static List<String> GetSolutionProjects(DTE dte)
|
||||
{
|
||||
List<String> projectNames = new List<String>();
|
||||
@@ -50,5 +57,23 @@ namespace CoatiSoftware.CoatiPlugin
|
||||
|
||||
return projectItems;
|
||||
}
|
||||
|
||||
public static List<String> GetSolutionLanguages(DTE dte)
|
||||
{
|
||||
List<String> languages = new List<String>();
|
||||
|
||||
EnvDTE.Solution solution = dte.Solution;
|
||||
EnvDTE.Projects projects = solution.Projects;
|
||||
|
||||
foreach (EnvDTE.Project project in projects)
|
||||
{
|
||||
string language = project.CodeModel.Language;
|
||||
languages.Add(language);
|
||||
}
|
||||
|
||||
languages = languages.Distinct().ToList();
|
||||
|
||||
return languages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
|
||||
<Metadata>
|
||||
<Identity Id="acf15780-03b5-440e-a41e-db79b7043fc2" Version="0.1.3" Language="en-US" Publisher="Coati Software" />
|
||||
<Identity Id="acf15780-03b5-440e-a41e-db79b7043fc2" Version="0.4.1" Language="en-US" Publisher="Coati Software" />
|
||||
<DisplayName>CoatiPlugin</DisplayName>
|
||||
<Description xml:space="preserve">This package allows Coati to communicate with Visual Studio and vice versa.</Description>
|
||||
<Icon>coati.ico</Icon>
|
||||
|
||||
Reference in New Issue
Block a user