[svn]
r6715: vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
Nuald
svnadmin at nemerle.org
Tue Sep 26 08:07:20 CEST 2006
Log:
Fix get node properties method.
Author: Nuald
Date: Tue Sep 26 08:07:12 2006
New Revision: 6715
Modified:
vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs Tue Sep 26 08:07:12 2006
@@ -46,9 +46,9 @@
options.DoNotLoadMacros = NoStdMacros;
_hierarchy = hierarchy;
- _engine = new Engine(options, new TraceWriter()); // ÷ňîáű ďŕđńĺđ đŕáîňŕë.
+ _engine = new Engine(options, new TraceWriter()); // it enables parser working.
- if (location != null)
+ if (!String.IsNullOrEmpty(location))
_projectLocation = location;
else
_projectLocation = Path.GetDirectoryName(fileName);
@@ -141,17 +141,25 @@
public bool IsFileInProject(string filePath)
{
+ if (String.IsNullOrEmpty(filePath))
+ {
+ return false;
+ }
return _filesMap.ContainsKey(filePath);
}
public void UpdateFile(ParseRequest request)
{
+ if (request == null)
+ {
+ return;
+ }
int oldTimestamp;
string filePath = request.FileName;
int timestamp = request.Timestamp;
if (!_filesMap.TryGetValue(filePath, out oldTimestamp))
- throw new ArgumentException("File '" + filePath + "' tot found.", "filePath");
+ throw new ArgumentException("File '" + filePath + "' not found.", "filePath");
if (timestamp != oldTimestamp)
{
@@ -162,9 +170,13 @@
string GetFileContent(ParseRequest request)
{
+ if (request == null)
+ {
+ return String.Empty;
+ }
string text = request.Text;
- if (text == null)
+ if (String.IsNullOrEmpty(text))
text = File.ReadAllText(request.FileName);
return text;
@@ -172,13 +184,22 @@
private static NemerleFileNodeProperties GetNodeProperties(IVsHierarchy hierarchy, uint itemID)
{
+ if (hierarchy == null)
+ {
+ return new NemerleFileNodeProperties(null);
+ }
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;
+ FileNodeProperties properties = propertyValue as FileNodeProperties;
+ if (properties != null)
+ {
+ return new NemerleFileNodeProperties(properties.Node);
+ }
+ return new NemerleFileNodeProperties(null);
}
private void FileAdded(object sender, HierarchyEventArgs ergs)
@@ -203,7 +224,7 @@
// Same file can be included in different projects.
// VladD2: For now we don't support it.
//
- const string format = "Error add file '{0}' to Complation Engine.\r\n{1}";
+ const string format = "Error add file '{0}' to Completion Engine.\r\n{1}";
Debug.WriteLine(string.Format(format, path, ex));
}
}
@@ -220,6 +241,10 @@
public static ProjectInfo FindProject(string fileName)
{
+ if (String.IsNullOrEmpty(fileName))
+ {
+ return null;
+ }
foreach (ProjectInfo proj in _projectsInfos)
if (proj.IsFileInProject(fileName))
return proj;
@@ -270,21 +295,21 @@
}
#if DebugLocations
- // ×čńňî îňëŕäî÷íŕ˙ őđĺíü.
- // Îáíîâëĺě ńîäĺđćčěîĺ ôŕéëŕ, ňŕę ęŕę îí čçěĺíčëń˙, ŕ Engine îá ýňîě ďîęŕ íĺçíŕĺň.
+ // Just debug staff.
+ // Update file content, because it is changed, but engine still doesn't know it.
//
string code = Utils.GetFileCode(_site, filePath);
Engine.Sources.AddOrUpdate(filePath, code);
- // Îáíóë˙ĺě ńńűëęó íŕ ďđîĺęň. Ýňî ďđčâîäčň ę ňîěó, ÷ňî ńëĺäóţůĺĺ îáđŕůĺíčĺ
- // ę ńâîéńňâó Project ńîçäŕńň íîâűé ďđîĺęň, ŕ ńňŕëî áűňü ďîńňđîčň íîâîĺ äĺđĺâî ňčďîâ.
+ // Reset link to the project. It leads next request to Project property
+ // will create new project, and accordingly will create new types tree.
//
#endif
ResetTypeTree();
#if DebugLocations
- // Îáíîâë˙ĺě GUI-äĺđĺâî âčçóŕëčçčđóţůĺĺ ŔŃŇ ňĺęóůĺăî ôŕéëŕ.
+ // Update GUI-tree visualizing AST of the current file.
//
int fileIndex = Location.GetFileIndex(filePath);
More information about the svn
mailing list