[svn] r6577: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
Nemerle.Compi...
VladD2
svnadmin at nemerle.org
Fri Aug 25 22:08:29 CEST 2006
Log:
1. Temporarily turn down caching of parsing results in completion engine.
2. Add support of some compiler flags in VS project.
2. Comment out some debugging output.
Author: VladD2
Date: Fri Aug 25 22:08:17 2006
New Revision: 6577
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n
vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n Fri Aug 25 22:08:17 2006
@@ -133,7 +133,7 @@
col : int)
: (Location * object)
{
- Trace.WriteLine($"\nStart looking at: $line:$col.");
+ //Trace.WriteLine($"\nStart looking at: $line:$col.");
def Print[T](ex : T) : void
{
@@ -158,12 +158,13 @@
for (mutable i = 0; i < counter; i++)
s += " ";
- Trace.WriteLine(s + $"$(ex.GetType().FullName) $(ex.loc.Line):"
- "$(ex.loc.Column):$(ex.loc.EndLine):$(ex.loc.EndColumn) cur:"
- "$(curLocation.Line):$(curLocation.Column):$(curLocation.EndLine):"
- "$(curLocation.EndColumn).");
- Trace.WriteLine(s + ex.ToString().Replace("\n", "\n" + s));
- Trace.WriteLine("");
+ //Trace.WriteLine(s + $"$(ex.GetType().FullName) $(ex.loc.Line):"
+ // "$(ex.loc.Column):$(ex.loc.EndLine):$(ex.loc.EndColumn) cur:"
+ // "$(curLocation.Line):$(curLocation.Column):$(curLocation.EndLine):"
+ // "$(curLocation.EndColumn).");
+ //Trace.WriteLine(s + ex.ToString().Replace("\n", "\n" + s));
+ //Trace.WriteLine("");
+ ignore(ex);
}
def Go(expression : PExpr)
@@ -323,7 +324,7 @@
locationToFind : Location)
: (Location * object)
{
- Trace.WriteLine($"\nStart looking at: $line:$col, $locationToFind.");
+ //Trace.WriteLine($"\nStart looking at: $line:$col, $locationToFind.");
def Print[T](ex : T) : void
{
@@ -348,9 +349,10 @@
for (mutable i = 0; i < counter; i++)
s += " ";
- Trace.WriteLine(s + $"$(ex.GetType().FullName) $(ex.loc.Line):$(ex.loc.Column):$(ex.loc.EndLine):$(ex.loc.EndColumn) cur:$(curLocation.Line):$(curLocation.Column):$(curLocation.EndLine):$(curLocation.EndColumn).");
- Trace.WriteLine(s + ex.ToString().Replace("\n", "\n" + s));
- Trace.WriteLine("");
+ //Trace.WriteLine(s + $"$(ex.GetType().FullName) $(ex.loc.Line):$(ex.loc.Column):$(ex.loc.EndLine):$(ex.loc.EndColumn) cur:$(curLocation.Line):$(curLocation.Column):$(curLocation.EndLine):$(curLocation.EndColumn).");
+ //Trace.WriteLine(s + ex.ToString().Replace("\n", "\n" + s));
+ //Trace.WriteLine("");
+ ignore(ex);
}
def Go(expression : TExpr)
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n Fri Aug 25 22:08:17 2006
@@ -37,18 +37,23 @@
{
match (fileInfo)
{
- | NotParsed as np =>
+ | Parsed(_, code)
+ | NotParsed(code) =>
_fileIndex = Location.GetFileIndex(filePath);
BeginParseFile(_fileIndex);
try
{
- def lexer = LexerString (this, np.code, Location(_fileIndex, 1, 1));
+ def lexer = LexerString (this, code, Location(_fileIndex, 1, 1));
def decls = ParsingPipeline (lexer);
- Sources._sources[filePath] = ParsedFile.Parsed (decls, np.code);
+ Sources._sources[filePath] = ParsedFile.Parsed (decls, code);
trees ::= decls;
}
finally { EndParseFile(_fileIndex); }
- | Parsed as p => trees ::= p.decls;
+ //| Parsed as p =>
+ // foreach (decl is TopDeclaration.Delegate in p.decls)
+ // decl.Attributes &= ~NemerleAttributes.Sealed;
+
+ // trees ::= p.decls;
}
}
}
@@ -57,10 +62,16 @@
// create N.C.TypeBuilders for all parsed types and add them to namespace hierarchy
try
{
+ //Trace.WriteLine("!!! Begin >>>>");
foreach (group in trees)
foreach (topDecl in group)
+ {
+ //Output.WriteLine($"------- $topDecl: $(topDecl.Name)");
+ //Output.WriteLine(topDecl.Location);
ScanningPipeline(topDecl);
}
+ //Trace.WriteLine("!!! End <<<<");
+ }
catch { | _e => Trace.WriteLine(_e); }
// xz. Âđîäĺ ęŕę çŕíčěŕĺňń˙ ďîńňđîĺíčĺě ĺäčíîăî äĺđĺâŕ ňčďîâ č đŕçđĺřĺíč˙ ńńűëîę.
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n Fri Aug 25 22:08:17 2006
@@ -44,7 +44,6 @@
Instance = this;
InitCompiler ();
- Init ();
}
public Init () : void
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n Fri Aug 25 22:08:17 2006
@@ -62,8 +62,6 @@
{
_decls ::= Decl.Using(location, name, nameLocations,
alias, aliasLocation, beforeEnv, afterEnv);
-
- Output.WriteLine(_decls.Head);
}
private BeforeNamespaceParse() : void
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1.n Fri Aug 25 22:08:17 2006
@@ -2,6 +2,8 @@
//using System;
using SYZ = System.Collections.Generic;
+public delegate TestDel () : bool;
+
namespace Ns1
{
namespace Ns2
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs Fri Aug 25 22:08:17 2006
@@ -3,13 +3,18 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
+using System.Windows.Forms;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.Shell.Interop;
using Nemerle.Compiler;
using Nemerle.Completion2;
+using Nemerle.VsIntegration.Project;
+
+using MSBuild = Microsoft.Build.BuildEngine;
using NCC = Nemerle.Compiler;
using Nemerle.Compiler.Utils;
-using System.Windows.Forms;
+using Utils = Nemerle.VsIntegration.Project.Utils;
+using Microsoft.VisualStudio;
namespace Microsoft.Samples.VisualStudio.NemerleLanguageService
{
@@ -20,12 +25,17 @@
private static ProjectInfoCollection _projectsInfos = new ProjectInfoCollection();
private string _projectLocation;
- public ProjectInfo(IVsHierarchy hierarchy, string fileName, string location)
+ public ProjectInfo(MSBuild.Project buildProject, IVsHierarchy hierarchy, string fileName, string location)
{
ErrorHelper.ThrowIsNull(hierarchy, "hierarchy");
+ _buildProject = buildProject;
+ CompilationOptions options = new CompilationOptions();
+
+ options.DoNotLoadStdlib = NoStdLib;
+ options.DoNotLoadMacros = NoStdMacros;
_hierarchy = hierarchy;
- _engine = new Engine(new TraceWriter()); // ÷ňîáű ďŕđńĺđ đŕáîňŕë.
+ _engine = new Engine(options, new TraceWriter()); // ÷ňîáű ďŕđńĺđ đŕáîňŕë.
if (location != null)
_projectLocation = location;
@@ -36,6 +46,17 @@
_projectLocation += "\\";
}
+ public void Init()
+ {
+ _engine.Init();
+ }
+
+ MSBuild.Project _buildProject;
+ public MSBuild.Project MSBuildProject { get { return _buildProject; } }
+
+ public bool NoStdLib { get { return Utils.IsTrue(MSBuildProject, "NoStdLib"); } }
+ public bool NoStdMacros { get { return Utils.IsTrue(MSBuildProject, "NoStdMacros"); } }
+
IVsHierarchy _hierarchy;
public void InitListener()
@@ -138,10 +159,31 @@
return text;
}
+ private static NemerleFileNodeProperties GetNodeProperties(IVsHierarchy hierarchy, uint itemID)
+ {
+ object propertyValue;
+ int hr = hierarchy.GetProperty(itemID,
+ (int)__VSHPROPID.VSHPROPID_BrowseObject,
+ out propertyValue);
+
+ if (hr != VSConstants.S_OK)
+ throw new ArgumentException(
+ "Can't obtain VSHPROPID_BrowseObject for item with ID " + itemID,
+ "itemID");
+
+ return (NemerleFileNodeProperties)propertyValue;
+ }
+
private void FileAdded(object sender, HierarchyEventArgs ergs)
{
Debug.Assert(ergs.TextBuffer == null);
+ NemerleFileNodeProperties nodeProps
+ = GetNodeProperties((IVsHierarchy)sender, ergs.ItemID);
+
+ if (nodeProps.BuildAction != BuildAction.Compile)
+ return;
+
string path = ergs.FileName;
_filesMap.Add(path, 1);
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs Fri Aug 25 22:08:17 2006
@@ -13,6 +13,8 @@
using System.Reflection;
using System.Windows.Forms;
using Microsoft.VisualStudio.Shell;
+using Microsoft.Build.BuildEngine;
+using PkgUtils = Microsoft.VisualStudio.Package.Utilities;
namespace Nemerle.VsIntegration.Project
{
@@ -51,7 +53,7 @@
Trace.Assert(imageStream != null);
- return Utilities.GetImageList(imageStream);
+ return PkgUtils.GetImageList(imageStream);
}
/// <summary>
@@ -145,7 +147,7 @@
{
get
{
- IntPtr unknownPtr = Utilities.QueryInterfaceIUnknown(this);
+ IntPtr unknownPtr = PkgUtils.QueryInterfaceIUnknown(this);
if (unknownPtr == IntPtr.Zero)
return null;
@@ -223,10 +225,14 @@
public override void Load(string filename, string location, string name,
uint flags, ref Guid iidProject, out int canceled)
{
+ Trace.Assert(BuildEngine != null);
+ Trace.Assert(BuildProject != null);
+ Trace.Assert(BuildProject.FullFileName == Path.GetFullPath(filename));
+
// IT: ProjectInfo needs to be created before loading
// as we will catch assembly reference adding.
//
- _projectInfo = new ProjectInfo(InteropSafeHierarchy, filename, location);
+ _projectInfo = new ProjectInfo(BuildProject, InteropSafeHierarchy, filename, location);
ProjectInfo.ProjectsInfos.Add(_projectInfo);
@@ -248,6 +254,8 @@
if (libraryManager != null)
libraryManager.RegisterHierarchy(InteropSafeHierarchy);
+
+ _projectInfo.Init();
}
/// <summary>
@@ -346,7 +354,7 @@
newNode.OleServiceProvider.AddService(
typeof(VSLangProj.VSProject), this.VSProject, false);
- if (IsCodeFile(include))
+ if (IsCodeFile(include) && item.ItemName == "Compile")
newNode.OleServiceProvider.AddService(
typeof(SVSMDCodeDomProvider), this.CodeDomProvider, false);
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs Fri Aug 25 22:08:17 2006
@@ -5,6 +5,7 @@
using Nemerle.Compiler;
using System.Reflection;
+using Msbuild = Microsoft.Build.BuildEngine;
namespace Nemerle
{
@@ -13,6 +14,17 @@
{
static class Utils
{
+ public static bool IsTrue(Msbuild.Project project, string valueName)
+ {
+ return Eq(project.GetEvaluatedProperty(valueName), "true");
+ }
+
+ public static bool Eq(string str1, string str2)
+ {
+ return string.Compare(str1, str2,
+ StringComparison.InvariantCultureIgnoreCase) == 0;
+ }
+
public static string GetModuleName(Type type)
{
string fileName = Path.GetFileNameWithoutExtension(type.Module.Name);
More information about the svn
mailing list