Browse Source

Ported changes from Fidalgo rev 2038, ivokovacka.

Fixed more NRefactory bugs.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@373 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
21af77e33d
  1. 36
      src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs
  2. 7
      src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs
  3. 4
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  4. 21
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeReference.cs
  5. 1319
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  6. 3
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  7. 116
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  8. 46
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs

36
src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs

@ -133,9 +133,9 @@ namespace HtmlHelp2
if(firstChild.tagName == "B" && firstChild.innerText == sectionName) { if(firstChild.tagName == "B" && firstChild.innerText == sectionName) {
if(spanChild.tagName == "SPAN" && (string)spanChild.getAttribute("className", 0) == "content") { if(spanChild.tagName == "SPAN" && (string)spanChild.getAttribute("className", 0) == "content") {
spanChild.insertAdjacentHTML("beforeEnd", spanChild.insertAdjacentHTML("beforeEnd",
String.Format("<span class=\"link\" onmouseover=\"window.status='{0}'\" onmouseout=\"window.status=''\" onclick=\"Click('{0}');\">{1}</span><br>", String.Format("<span class=\"link\" onmouseover=\"window.status='{0}'\" onmouseout=\"window.status=''\" onclick=\"Click('{0}');\">{1}</span><br>",
topicUrl, topicName) topicUrl, topicName)
); );
return; return;
} }
@ -152,12 +152,12 @@ namespace HtmlHelp2
} }
dynamicHelpBrowser.Document.body.insertAdjacentHTML("beforeEnd", dynamicHelpBrowser.Document.body.insertAdjacentHTML("beforeEnd",
String.Format("<span class=\"section\"><img id=\"image_{0}\" src=\"OpenBook.png\" style=\"width:16px;height:16px;margin-right:5px;\">" + String.Format("<span class=\"section\"><img id=\"image_{0}\" src=\"OpenBook.png\" style=\"width:16px;height:16px;margin-right:5px;\">" +
"<b style=\"cursor:pointer\" onclick=\"ExpandCollapse({0})\">{1}</b><br>" + "<b style=\"cursor:pointer\" onclick=\"ExpandCollapse({0})\">{1}</b><br>" +
"<span class=\"content\" id=\"content_{0}\">" + "<span class=\"content\" id=\"content_{0}\">" +
"<span class=\"link\" onmouseover=\"window.status='{2}'\" onmouseout=\"window.status=''\" onclick=\"Click('{2}');\">{3}</span><br></span></span>", "<span class=\"link\" onmouseover=\"window.status='{2}'\" onmouseout=\"window.status=''\" onclick=\"Click('{2}');\">{3}</span><br></span></span>",
this.internalIndex.ToString(), sectionName, topicUrl, topicName) this.internalIndex.ToString(), sectionName, topicUrl, topicName)
); );
this.internalIndex++; this.internalIndex++;
} }
@ -188,6 +188,12 @@ namespace HtmlHelp2
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (doc != null) {
mshtml.HTMLDocumentEvents2_Event docEvents = (mshtml.HTMLDocumentEvents2_Event)doc;
docEvents.oncontextmenu -= new HTMLDocumentEvents2_oncontextmenuEventHandler(DocumentEventsOnContextMenu);
int c = Marshal.ReleaseComObject(doc);
doc = null;
}
base.Dispose(disposing); base.Dispose(disposing);
if (disposing) axWebBrowser.Dispose(); if (disposing) axWebBrowser.Dispose();
} }
@ -266,8 +272,14 @@ namespace HtmlHelp2
private void DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e) private void DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
{ {
try { try {
mshtml.HTMLDocumentEvents2_Event docEvents;
if (doc != null) {
docEvents = (mshtml.HTMLDocumentEvents2_Event)doc;
docEvents.oncontextmenu -= new HTMLDocumentEvents2_oncontextmenuEventHandler(DocumentEventsOnContextMenu);
Marshal.ReleaseComObject(doc);
}
doc = (mshtml.HTMLDocument)axWebBrowser.Document; doc = (mshtml.HTMLDocument)axWebBrowser.Document;
mshtml.HTMLDocumentEvents2_Event docEvents = (mshtml.HTMLDocumentEvents2_Event)doc; docEvents = (mshtml.HTMLDocumentEvents2_Event)doc;
docEvents.oncontextmenu += new HTMLDocumentEvents2_oncontextmenuEventHandler(DocumentEventsOnContextMenu); docEvents.oncontextmenu += new HTMLDocumentEvents2_oncontextmenuEventHandler(DocumentEventsOnContextMenu);
} }
catch { catch {
@ -276,8 +288,8 @@ namespace HtmlHelp2
private void StatusBarChanged(object sender, DWebBrowserEvents2_StatusTextChangeEvent e) private void StatusBarChanged(object sender, DWebBrowserEvents2_StatusTextChangeEvent e)
{ {
IStatusBarService statusBarService = (IStatusBarService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService)); IStatusBarService statusBarService = (IStatusBarService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService));
statusBarService.SetMessage(e.text); statusBarService.SetMessage(e.text);
} }
private bool DocumentEventsOnContextMenu(IHTMLEventObj e) private bool DocumentEventsOnContextMenu(IHTMLEventObj e)

7
src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs

@ -31,9 +31,10 @@ namespace HtmlHelp2Service
private static bool IsClassRegistered(string classId) private static bool IsClassRegistered(string classId)
{ {
try { try {
RegistryKey tempRegKey = Registry.ClassesRoot.OpenSubKey(String.Format("CLSID\\{0}\\InprocServer32", classId)); using (RegistryKey tempRegKey = Registry.ClassesRoot.OpenSubKey(String.Format("CLSID\\{0}\\InprocServer32", classId))) {
string help2Dll = (string)tempRegKey.GetValue(""); string help2Dll = (string)tempRegKey.GetValue("");
return (help2Dll != null && help2Dll != "" && File.Exists(help2Dll)); return (help2Dll != null && help2Dll != "" && File.Exists(help2Dll));
}
} }
catch { catch {
return false; return false;

4
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

@ -385,8 +385,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
ReaderRead(); ReaderRead();
} }
if (HandleLineEnd(ch)) { if (HandleLineEnd(ch)) {
sb.Append('\n'); sb.Append("\r\n");
originalValue.Append('\n'); originalValue.Append("\r\n");
} else { } else {
sb.Append(ch); sb.Append(ch);
originalValue.Append(ch); originalValue.Append(ch);

21
src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeReference.cs

@ -13,7 +13,7 @@ using System.Text;
namespace ICSharpCode.NRefactory.Parser.AST namespace ICSharpCode.NRefactory.Parser.AST
{ {
public class TypeReference : AbstractNode, INullable public class TypeReference : AbstractNode, INullable, ICloneable
{ {
string type = ""; string type = "";
string systemType = ""; string systemType = "";
@ -74,6 +74,25 @@ namespace ICSharpCode.NRefactory.Parser.AST
return vbtypes; return vbtypes;
} }
object ICloneable.Clone()
{
return this.Clone();
}
public TypeReference Clone()
{
TypeReference c = new TypeReference(type, systemType);
c.pointerNestingLevel = pointerNestingLevel;
if (rankSpecifier != null) {
c.rankSpecifier = (int[])rankSpecifier.Clone();
}
foreach (TypeReference r in genericTypes) {
c.genericTypes.Add(r.Clone());
}
c.isGlobal = isGlobal;
return c;
}
public string Type { public string Type {
get { get {
return type; return type;

1319
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

3
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -1502,12 +1502,13 @@ VariableDeclarator<List<VariableDeclaration> fieldDeclaration>
if(type.RankSpecifier != null) { if(type.RankSpecifier != null) {
Error("array rank only allowed one time"); Error("array rank only allowed one time");
} else { } else {
type.RankSpecifier = new int[] { dimension.Count - 1 };
for (int i = 0; i < dimension.Count; i++) for (int i = 0; i < dimension.Count; i++)
dimension[i] = Expression.AddInteger((Expression)dimension[i], 1); dimension[i] = Expression.AddInteger((Expression)dimension[i], 1);
rank = new ArrayList(); rank = new ArrayList();
rank.Add(new ArrayCreationParameter(dimension)); rank.Add(new ArrayCreationParameter(dimension));
expr = new ArrayCreateExpression(type, rank); expr = new ArrayCreateExpression(type, rank);
type = type.Clone();
type.RankSpecifier = new int[] { dimension.Count - 1 };
} }
} }
.) .)

116
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -29,13 +29,13 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
/// </summary> /// </summary>
public class NewProjectDialog : BaseSharpDevelopForm public class NewProjectDialog : BaseSharpDevelopForm
{ {
Container components = new System.ComponentModel.Container(); protected Container components = new System.ComponentModel.Container();
ArrayList alltemplates = new ArrayList(); protected ArrayList alltemplates = new ArrayList();
ArrayList categories = new ArrayList(); protected ArrayList categories = new ArrayList();
Hashtable icons = new Hashtable(); protected Hashtable icons = new Hashtable();
bool openCombine; protected bool openCombine;
public NewProjectDialog(bool openCombine) public NewProjectDialog(bool openCombine)
{ {
@ -47,12 +47,16 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
InitializeView(); InitializeView();
((TreeView)ControlDictionary["categoryTreeView"]).Select(); ((TreeView)ControlDictionary["categoryTreeView"]).Select();
((TextBox)ControlDictionary["locationTextBox"]).Text = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.NewProjectDialog.DefaultPath", Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "SharpDevelop Projects")).ToString(); ((TextBox)ControlDictionary["locationTextBox"]).Text = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.DefaultPath", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SharpDevelop Projects"));
StartPosition = FormStartPosition.CenterParent; StartPosition = FormStartPosition.CenterParent;
Icon = null; Icon = null;
} }
void InitializeView() public NewProjectDialog()
{
}
protected virtual void InitializeView()
{ {
ImageList smalllist = new ImageList(); ImageList smalllist = new ImageList();
ImageList imglist = new ImageList(); ImageList imglist = new ImageList();
@ -116,7 +120,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
} }
// TODO : insert sub categories // TODO : insert sub categories
Category GetCategory(string categoryname) protected Category GetCategory(string categoryname)
{ {
foreach (Category category in categories) { foreach (Category category in categories) {
if (category.Text == categoryname) if (category.Text == categoryname)
@ -127,22 +131,24 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
return newcategory; return newcategory;
} }
void InitializeTemplates() protected virtual void InitializeTemplates()
{ {
foreach (ProjectTemplate template in ProjectTemplate.ProjectTemplates) { foreach (ProjectTemplate template in ProjectTemplate.ProjectTemplates) {
TemplateItem titem = new TemplateItem(template); TemplateItem titem = new TemplateItem(template);
if (titem.Template.Icon != null) { if (titem.Template.Icon != null) {
icons[titem.Template.Icon] = 0; // "create template icon" icons[titem.Template.Icon] = 0; // "create template icon"
} }
Category cat = GetCategory(titem.Template.Category); if (template.NewProjectDialogVisible == true) {
cat.Templates.Add(titem); Category cat = GetCategory(titem.Template.Category);
if (cat.Templates.Count == 1) cat.Templates.Add(titem);
titem.Selected = true; if (cat.Templates.Count == 1)
titem.Selected = true;
}
alltemplates.Add(titem); alltemplates.Add(titem);
} }
} }
void CategoryChange(object sender, TreeViewEventArgs e) protected void CategoryChange(object sender, TreeViewEventArgs e)
{ {
((ListView)ControlDictionary["templateListView"]).Items.Clear(); ((ListView)ControlDictionary["templateListView"]).Items.Clear();
if (((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode != null) { if (((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode != null) {
@ -188,7 +194,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
return ProjectLocation + name; return ProjectLocation + name;
} }
} }
string ProjectLocation { string ProjectLocation {
get { get {
string location = ((TextBox)ControlDictionary["locationTextBox"]).Text.TrimEnd('\\', '/', Path.DirectorySeparatorChar); string location = ((TextBox)ControlDictionary["locationTextBox"]).Text.TrimEnd('\\', '/', Path.DirectorySeparatorChar);
@ -218,7 +224,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
solutionPath = solutionPath.Substring(0, maxLength + 3) + "..."; solutionPath = solutionPath.Substring(0, maxLength + 3) + "...";
} }
} }
} catch (Exception ex) { } catch (Exception ex) {
MessageService.ShowError(ex); MessageService.ShowError(ex);
} }
ControlDictionary["createInLabel"].Text = ResourceService.GetString("Dialog.NewProject.ProjectAtDescription")+ " " + solutionPath; ControlDictionary["createInLabel"].Text = ResourceService.GetString("Dialog.NewProject.ProjectAtDescription")+ " " + solutionPath;
@ -303,38 +309,38 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
/* /*
if (item.Template.LanguageName != null && item.Template.LanguageName.Length > 0) { if (item.Template.LanguageName != null && item.Template.LanguageName.Length > 0) {
} }
if (item.Template.WizardPath != null) { if (item.Template.WizardPath != null) {
Properties customizer = new Properties(); Properties customizer = new Properties();
customizer.Set("Template", item.Template); customizer.Set("Template", item.Template);
customizer.Set("Creator", this); customizer.Set("Creator", this);
WizardDialog wizard = new WizardDialog("Project Wizard", customizer, item.Template.WizardPath); WizardDialog wizard = new WizardDialog("Project Wizard", customizer, item.Template.WizardPath);
if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
} }
} }
NewCombineLocation = FileUtility.GetDirectoryNameWithSeparator(ProjectLocation) + ((TextBox)ControlDictionary["nameTextBox"]).Text + ".cmbx"; NewCombineLocation = FileUtility.GetDirectoryNameWithSeparator(ProjectLocation) + ((TextBox)ControlDictionary["nameTextBox"]).Text + ".cmbx";
if (File.Exists(NewCombineLocation)) { if (File.Exists(NewCombineLocation)) {
DialogResult result = MessageBox.Show("Combine file " + NewCombineLocation + " already exists, do you want to overwrite\nthe existing file ?", "File already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); DialogResult result = MessageBox.Show("Combine file " + NewCombineLocation + " already exists, do you want to overwrite\nthe existing file ?", "File already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
switch(result) { switch(result) {
case DialogResult.Yes: case DialogResult.Yes:
cmb.SaveCombine(NewCombineLocation);
break;
case DialogResult.No:
break;
}
} else {
cmb.SaveCombine(NewCombineLocation); cmb.SaveCombine(NewCombineLocation);
break; }
case DialogResult.No: } else {
break; MessageBox.Show(ResourceService.GetString("Dialog.NewProject.EmptyProjectFieldWarning"), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} else { */
cmb.SaveCombine(NewCombineLocation);
}
} else {
MessageBox.Show(ResourceService.GetString("Dialog.NewProject.EmptyProjectFieldWarning"), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
*/
} }
} }
@ -360,7 +366,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
} }
} }
void InitializeComponents() protected void InitializeComponents()
{ {
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.NewProjectDialog.xfrm")); SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.NewProjectDialog.xfrm"));
@ -413,11 +419,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
/// <summary> /// <summary>
/// Represents a category /// Represents a category
/// </summary> /// </summary>
internal class Category : TreeNode public class Category : TreeNode
{ {
ArrayList categories = new ArrayList(); ArrayList categories = new ArrayList();
ArrayList templates = new ArrayList(); ArrayList templates = new ArrayList();
// string name; // string name;
public Category(string name) : base(name) public Category(string name) : base(name)
{ {
@ -425,11 +431,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
ImageIndex = 1; ImageIndex = 1;
} }
// public string Name { // public string Name {
// get { // get {
// return name; // return name;
// } // }
// } // }
public ArrayList Categories { public ArrayList Categories {
get { get {
return categories; return categories;
@ -445,7 +451,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
/// <summary> /// <summary>
/// Holds a new file template /// Holds a new file template
/// </summary> /// </summary>
internal class TemplateItem : ListViewItem public class TemplateItem : ListViewItem
{ {
ProjectTemplate template; ProjectTemplate template;

46
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs

@ -54,10 +54,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
string description = null; string description = null;
string icon = null; string icon = null;
string wizardpath = null; string wizardpath = null;
bool newProjectDialogVisible = true;
ArrayList actions = new ArrayList(); ArrayList actions = new ArrayList();
CombineDescriptor combineDescriptor = null; CombineDescriptor combineDescriptor = null;
ProjectDescriptor projectDescriptor = null;
#region Template Properties #region Template Properties
public string WizardPath { public string WizardPath {
@ -113,15 +117,27 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
return icon; return icon;
} }
} }
public bool NewProjectDialogVisible {
get {
return newProjectDialogVisible;
}
}
[Browsable(false)] [Browsable(false)]
public CombineDescriptor CombineDescriptor public CombineDescriptor CombineDescriptor {
{ get {
get
{
return combineDescriptor; return combineDescriptor;
} }
} }
[Browsable(false)]
public ProjectDescriptor ProjectDescriptor {
get {
return projectDescriptor;
}
}
#endregion #endregion
protected ProjectTemplate(string fileName) protected ProjectTemplate(string fileName)
@ -139,6 +155,12 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
created = doc.DocumentElement.GetAttribute("created"); created = doc.DocumentElement.GetAttribute("created");
lastmodified = doc.DocumentElement.GetAttribute("lastModified"); lastmodified = doc.DocumentElement.GetAttribute("lastModified");
string newProjectDialogVisibleAttr = doc.DocumentElement.GetAttribute("newprojectdialogvisible");
if (newProjectDialogVisibleAttr != null && newProjectDialogVisibleAttr.Length != 0) {
if (newProjectDialogVisibleAttr.ToLower() == "false")
newProjectDialogVisible = false;
}
XmlElement config = doc.DocumentElement["TemplateConfiguration"]; XmlElement config = doc.DocumentElement["TemplateConfiguration"];
if (config["Wizard"] != null) { if (config["Wizard"] != null) {
@ -161,6 +183,10 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
combineDescriptor = CombineDescriptor.CreateCombineDescriptor(doc.DocumentElement["Combine"]); combineDescriptor = CombineDescriptor.CreateCombineDescriptor(doc.DocumentElement["Combine"]);
} }
if (doc.DocumentElement["Project"] != null) {
projectDescriptor = ProjectDescriptor.CreateProjectDescriptor(doc.DocumentElement["Project"]);
}
// Read Actions; // Read Actions;
if (doc.DocumentElement["Actions"] != null) { if (doc.DocumentElement["Actions"] != null) {
foreach (XmlElement el in doc.DocumentElement["Actions"]) { foreach (XmlElement el in doc.DocumentElement["Actions"]) {
@ -191,12 +217,18 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
customizer.Set("ProjectTemplate", this); customizer.Set("ProjectTemplate", this);
WizardDialog wizard = new WizardDialog("Project Wizard", customizer, wizardpath); WizardDialog wizard = new WizardDialog("Project Wizard", customizer, wizardpath);
if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
lastCombine = combineDescriptor.CreateCombine(projectCreateInformation, this.languagename); if (combineDescriptor != null)
lastCombine = combineDescriptor.CreateCombine(projectCreateInformation, this.languagename);
else if (projectDescriptor != null)
lastCombine = projectDescriptor.CreateProject(projectCreateInformation, this.languagename).FileName;
} else { } else {
return null; return null;
} }
} else { } else {
lastCombine = combineDescriptor.CreateCombine(projectCreateInformation, this.languagename); if (combineDescriptor != null)
lastCombine = combineDescriptor.CreateCombine(projectCreateInformation, this.languagename);
else if (projectDescriptor != null)
lastCombine = projectDescriptor.CreateProject(projectCreateInformation, this.languagename).FileName;
} }
return lastCombine; return lastCombine;

Loading…
Cancel
Save