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 @@ -133,9 +133,9 @@ namespace HtmlHelp2
if(firstChild.tagName == "B" && firstChild.innerText == sectionName) {
if(spanChild.tagName == "SPAN" && (string)spanChild.getAttribute("className", 0) == "content") {
spanChild.insertAdjacentHTML("beforeEnd",
String.Format("<span class=\"link\" onmouseover=\"window.status='{0}'\" onmouseout=\"window.status=''\" onclick=\"Click('{0}');\">{1}</span><br>",
topicUrl, topicName)
);
String.Format("<span class=\"link\" onmouseover=\"window.status='{0}'\" onmouseout=\"window.status=''\" onclick=\"Click('{0}');\">{1}</span><br>",
topicUrl, topicName)
);
return;
}
@ -152,12 +152,12 @@ namespace HtmlHelp2 @@ -152,12 +152,12 @@ namespace HtmlHelp2
}
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;\">" +
"<b style=\"cursor:pointer\" onclick=\"ExpandCollapse({0})\">{1}</b><br>" +
"<span class=\"content\" id=\"content_{0}\">" +
"<span class=\"link\" onmouseover=\"window.status='{2}'\" onmouseout=\"window.status=''\" onclick=\"Click('{2}');\">{3}</span><br></span></span>",
this.internalIndex.ToString(), sectionName, topicUrl, topicName)
);
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>" +
"<span class=\"content\" id=\"content_{0}\">" +
"<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++;
}
@ -188,6 +188,12 @@ namespace HtmlHelp2 @@ -188,6 +188,12 @@ namespace HtmlHelp2
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);
if (disposing) axWebBrowser.Dispose();
}
@ -266,8 +272,14 @@ namespace HtmlHelp2 @@ -266,8 +272,14 @@ namespace HtmlHelp2
private void DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
{
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;
mshtml.HTMLDocumentEvents2_Event docEvents = (mshtml.HTMLDocumentEvents2_Event)doc;
docEvents = (mshtml.HTMLDocumentEvents2_Event)doc;
docEvents.oncontextmenu += new HTMLDocumentEvents2_oncontextmenuEventHandler(DocumentEventsOnContextMenu);
}
catch {
@ -276,8 +288,8 @@ namespace HtmlHelp2 @@ -276,8 +288,8 @@ namespace HtmlHelp2
private void StatusBarChanged(object sender, DWebBrowserEvents2_StatusTextChangeEvent e)
{
IStatusBarService statusBarService = (IStatusBarService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService));
statusBarService.SetMessage(e.text);
IStatusBarService statusBarService = (IStatusBarService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService));
statusBarService.SetMessage(e.text);
}
private bool DocumentEventsOnContextMenu(IHTMLEventObj e)

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

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

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

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

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

@ -13,7 +13,7 @@ using System.Text; @@ -13,7 +13,7 @@ using System.Text;
namespace ICSharpCode.NRefactory.Parser.AST
{
public class TypeReference : AbstractNode, INullable
public class TypeReference : AbstractNode, INullable, ICloneable
{
string type = "";
string systemType = "";
@ -74,6 +74,25 @@ namespace ICSharpCode.NRefactory.Parser.AST @@ -74,6 +74,25 @@ namespace ICSharpCode.NRefactory.Parser.AST
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 {
get {
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> @@ -1502,12 +1502,13 @@ VariableDeclarator<List<VariableDeclaration> fieldDeclaration>
if(type.RankSpecifier != null) {
Error("array rank only allowed one time");
} else {
type.RankSpecifier = new int[] { dimension.Count - 1 };
for (int i = 0; i < dimension.Count; i++)
dimension[i] = Expression.AddInteger((Expression)dimension[i], 1);
rank = new ArrayList();
rank.Add(new ArrayCreationParameter(dimension));
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 @@ -29,13 +29,13 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
/// </summary>
public class NewProjectDialog : BaseSharpDevelopForm
{
Container components = new System.ComponentModel.Container();
protected Container components = new System.ComponentModel.Container();
ArrayList alltemplates = new ArrayList();
ArrayList categories = new ArrayList();
Hashtable icons = new Hashtable();
protected ArrayList alltemplates = new ArrayList();
protected ArrayList categories = new ArrayList();
protected Hashtable icons = new Hashtable();
bool openCombine;
protected bool openCombine;
public NewProjectDialog(bool openCombine)
{
@ -47,12 +47,16 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -47,12 +47,16 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
InitializeView();
((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;
Icon = null;
}
void InitializeView()
public NewProjectDialog()
{
}
protected virtual void InitializeView()
{
ImageList smalllist = new ImageList();
ImageList imglist = new ImageList();
@ -116,7 +120,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -116,7 +120,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
}
// TODO : insert sub categories
Category GetCategory(string categoryname)
protected Category GetCategory(string categoryname)
{
foreach (Category category in categories) {
if (category.Text == categoryname)
@ -127,22 +131,24 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -127,22 +131,24 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
return newcategory;
}
void InitializeTemplates()
protected virtual void InitializeTemplates()
{
foreach (ProjectTemplate template in ProjectTemplate.ProjectTemplates) {
TemplateItem titem = new TemplateItem(template);
if (titem.Template.Icon != null) {
icons[titem.Template.Icon] = 0; // "create template icon"
}
Category cat = GetCategory(titem.Template.Category);
cat.Templates.Add(titem);
if (cat.Templates.Count == 1)
titem.Selected = true;
if (template.NewProjectDialogVisible == true) {
Category cat = GetCategory(titem.Template.Category);
cat.Templates.Add(titem);
if (cat.Templates.Count == 1)
titem.Selected = true;
}
alltemplates.Add(titem);
}
}
void CategoryChange(object sender, TreeViewEventArgs e)
protected void CategoryChange(object sender, TreeViewEventArgs e)
{
((ListView)ControlDictionary["templateListView"]).Items.Clear();
if (((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode != null) {
@ -188,7 +194,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -188,7 +194,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
return ProjectLocation + name;
}
}
string ProjectLocation {
get {
string location = ((TextBox)ControlDictionary["locationTextBox"]).Text.TrimEnd('\\', '/', Path.DirectorySeparatorChar);
@ -218,7 +224,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -218,7 +224,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
solutionPath = solutionPath.Substring(0, maxLength + 3) + "...";
}
}
} catch (Exception ex) {
} catch (Exception ex) {
MessageService.ShowError(ex);
}
ControlDictionary["createInLabel"].Text = ResourceService.GetString("Dialog.NewProject.ProjectAtDescription")+ " " + solutionPath;
@ -303,38 +309,38 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -303,38 +309,38 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
DialogResult = DialogResult.OK;
/*
if (item.Template.LanguageName != null && item.Template.LanguageName.Length > 0) {
}
if (item.Template.WizardPath != null) {
Properties customizer = new Properties();
customizer.Set("Template", item.Template);
customizer.Set("Creator", this);
WizardDialog wizard = new WizardDialog("Project Wizard", customizer, item.Template.WizardPath);
if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
DialogResult = DialogResult.OK;
}
}
NewCombineLocation = FileUtility.GetDirectoryNameWithSeparator(ProjectLocation) + ((TextBox)ControlDictionary["nameTextBox"]).Text + ".cmbx";
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);
switch(result) {
case DialogResult.Yes:
if (item.Template.LanguageName != null && item.Template.LanguageName.Length > 0) {
}
if (item.Template.WizardPath != null) {
Properties customizer = new Properties();
customizer.Set("Template", item.Template);
customizer.Set("Creator", this);
WizardDialog wizard = new WizardDialog("Project Wizard", customizer, item.Template.WizardPath);
if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
DialogResult = DialogResult.OK;
}
}
NewCombineLocation = FileUtility.GetDirectoryNameWithSeparator(ProjectLocation) + ((TextBox)ControlDictionary["nameTextBox"]).Text + ".cmbx";
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);
switch(result) {
case DialogResult.Yes:
cmb.SaveCombine(NewCombineLocation);
break;
case DialogResult.No:
break;
}
} else {
cmb.SaveCombine(NewCombineLocation);
break;
case DialogResult.No:
break;
}
} else {
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 @@ -360,7 +366,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
}
}
void InitializeComponents()
protected void InitializeComponents()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.NewProjectDialog.xfrm"));
@ -413,11 +419,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -413,11 +419,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
/// <summary>
/// Represents a category
/// </summary>
internal class Category : TreeNode
public class Category : TreeNode
{
ArrayList categories = new ArrayList();
ArrayList templates = new ArrayList();
// string name;
// string name;
public Category(string name) : base(name)
{
@ -425,11 +431,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -425,11 +431,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
ImageIndex = 1;
}
// public string Name {
// get {
// return name;
// }
// }
// public string Name {
// get {
// return name;
// }
// }
public ArrayList Categories {
get {
return categories;
@ -445,7 +451,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -445,7 +451,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
/// <summary>
/// Holds a new file template
/// </summary>
internal class TemplateItem : ListViewItem
public class TemplateItem : ListViewItem
{
ProjectTemplate template;

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

@ -54,10 +54,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -54,10 +54,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
string description = null;
string icon = null;
string wizardpath = null;
bool newProjectDialogVisible = true;
ArrayList actions = new ArrayList();
CombineDescriptor combineDescriptor = null;
ProjectDescriptor projectDescriptor = null;
#region Template Properties
public string WizardPath {
@ -113,15 +117,27 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -113,15 +117,27 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
return icon;
}
}
public bool NewProjectDialogVisible {
get {
return newProjectDialogVisible;
}
}
[Browsable(false)]
public CombineDescriptor CombineDescriptor
{
get
{
public CombineDescriptor CombineDescriptor {
get {
return combineDescriptor;
}
}
[Browsable(false)]
public ProjectDescriptor ProjectDescriptor {
get {
return projectDescriptor;
}
}
#endregion
protected ProjectTemplate(string fileName)
@ -139,6 +155,12 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -139,6 +155,12 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
created = doc.DocumentElement.GetAttribute("created");
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"];
if (config["Wizard"] != null) {
@ -161,6 +183,10 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -161,6 +183,10 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
combineDescriptor = CombineDescriptor.CreateCombineDescriptor(doc.DocumentElement["Combine"]);
}
if (doc.DocumentElement["Project"] != null) {
projectDescriptor = ProjectDescriptor.CreateProjectDescriptor(doc.DocumentElement["Project"]);
}
// Read Actions;
if (doc.DocumentElement["Actions"] != null) {
foreach (XmlElement el in doc.DocumentElement["Actions"]) {
@ -191,12 +217,18 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -191,12 +217,18 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
customizer.Set("ProjectTemplate", this);
WizardDialog wizard = new WizardDialog("Project Wizard", customizer, wizardpath);
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 {
return null;
}
} 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;

Loading…
Cancel
Save