Browse Source

Update to Cecil 0.6.

Fixed some bugs.
C# parser: include position information for statements/expressions.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2708 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
2d94d3128c
  1. 133
      data/templates/project/CSharp/SharpDevelopAddin.xpt
  2. 34
      src/Libraries/NRefactory/Project/Src/Ast/AbstractNode.cs
  3. 5
      src/Libraries/NRefactory/Project/Src/Ast/INode.cs
  4. 2650
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  5. 328
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  6. 2
      src/Libraries/NRefactory/Project/Src/SnippetParser.cs
  7. 11
      src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
  8. 8
      src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs
  9. 10
      src/Main/Base/Project/Src/Gui/Pads/FileScout.cs
  10. 2
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
  11. 2
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  12. 5
      src/Main/Base/Project/Src/Services/DisplayBinding/ShellExecuteDisplayBinding.cs
  13. 26
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  14. 19
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
  15. 13
      src/Main/Base/Test/CSharpExpressionFinderTests.cs
  16. 5
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs
  17. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs

133
data/templates/project/CSharp/SharpDevelopAddin.xpt

@ -33,127 +33,20 @@
<Files> <Files>
<File name="${ProjectName}.addin" CopyToOutputDirectory="Always"><![CDATA[<AddIn name = "${ProjectName}" <File name="${ProjectName}.addin" CopyToOutputDirectory="Always"><![CDATA[<AddIn name = "${ProjectName}"
author = "${USER}" author = "${USER}"
url = "" url = ""
description = "TODO: Put description here"> description = "TODO: Put description here">
<Runtime> <Runtime>
<Import assembly = "${ProjectName}.dll"/> <Import assembly = "${ProjectName}.dll"/>
</Runtime> </Runtime>
<Path name = "/SharpDevelop/Workbench/Pads"> <!-- Extend the SharpDevelop AddIn-Tree like this:
<Pad id = "${ProjectName}Pad" <Path name = ...>
category = "Main" <.../>
title = "${ProjectName}Pad" </Path>
icon = "PadIcons.Output" -->
shortcut = "Control|Alt|T"
class = "${ProjectName}.TestPad"/>
</Path>
</AddIn> </AddIn>
]]></File>
<File name="Resources/MyUserControl.xfrm" buildAction="EmbeddedResource">
<![CDATA[<?xml version="1.0" encoding="utf-8"?>
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="MyUserControl" />
<ClientSize value="{Width=230, Height=160}" />
<Controls>
<System.Windows.Forms.Button>
<Name value="testButton" />
<Location value="{X=63,Y=97}" />
<Text value="A button" />
<Size value="{Width=75, Height=23}" />
<Anchor value="None" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<TabIndex value="1" />
</System.Windows.Forms.Button>
<System.Windows.Forms.Label>
<Name value="label1" />
<Location value="{X=38,Y=19}" />
<Text value="Hello, World!" />
<Size value="{Width=100, Height=23}" />
<TabIndex value="0" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.UserControl>
</Components>
]]></File>
<File name="Src/MyUserControl.cs">
<![CDATA[${StandardHeader.C#}
using System;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
namespace ${ProjectName}
{
public class MyUserControl : BaseSharpDevelopUserControl
{
public MyUserControl()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("${ProjectName}.Resources.MyUserControl.xfrm"));
Get<Button>("test").Click += ButtonClick;
}
void ButtonClick(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("The button was clicked!");
}
}
}
]]></File>
<File name="Src/TestPad.cs">
<![CDATA[${StandardHeader.C#}
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ${ProjectName}
{
/// <summary>
/// Description of the pad content
/// </summary>
public class TestPad : AbstractPadContent
{
MyUserControl ctl;
/// <summary>
/// Creates a new TestPad object
/// </summary>
public TestPad()
{
ctl = new MyUserControl();
}
/// <summary>
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
/// </summary>
public override Control Control {
get {
return ctl;
}
}
/// <summary>
/// Refreshes the pad
/// </summary>
public override void RedrawContent()
{
// TODO: Refresh the whole pad control here, renew all resource strings whatever
// Note that you do not need to recreate the control.
}
/// <summary>
/// Cleans up all used resources
/// </summary>
public override void Dispose()
{
ctl.Dispose();
}
}
}
]]></File> ]]></File>
<File name="Configuration/AssemblyInfo.cs" src="DefaultAssemblyInfo.cs"/> <File name="Configuration/AssemblyInfo.cs" src="DefaultAssemblyInfo.cs"/>
<File name="AddInWritingHelp.txt" src="..\AddInWritingHelp.txt"/> <File name="AddInWritingHelp.txt" src="..\AddInWritingHelp.txt"/>

34
src/Libraries/NRefactory/Project/Src/Ast/AbstractNode.cs

@ -15,38 +15,12 @@ namespace ICSharpCode.NRefactory.Ast
{ {
public abstract class AbstractNode : INode public abstract class AbstractNode : INode
{ {
INode parent;
List<INode> children = new List<INode>(); List<INode> children = new List<INode>();
Location startLocation; public INode Parent { get; set; }
Location endLocation; public Location StartLocation { get; set; }
public Location EndLocation { get; set; }
public INode Parent { public object UserData { get; set; }
get {
return parent;
}
set {
parent = value;
}
}
public Location StartLocation {
get {
return startLocation;
}
set {
startLocation = value;
}
}
public Location EndLocation {
get {
return endLocation;
}
set {
endLocation = value;
}
}
public List<INode> Children { public List<INode> Children {
get { get {

5
src/Libraries/NRefactory/Project/Src/Ast/INode.cs

@ -31,6 +31,11 @@ namespace ICSharpCode.NRefactory.Ast
set; set;
} }
object UserData {
get;
set;
}
/// <summary> /// <summary>
/// Visits all children /// Visits all children
/// </summary> /// </summary>

2650
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

328
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -362,7 +362,9 @@ TypeDecl<ModifierList m, List<AttributeSection> attributes>
{ TypeParameterConstraintsClause<templates> } { TypeParameterConstraintsClause<templates> }
(. newType.BodyStartLocation = t.EndLocation; .) (. newType.BodyStartLocation = t.EndLocation; .)
"{" ClassBody "}" "{"
ClassBody
"}"
[ ";" ] (. newType.EndLocation = t.Location; [ ";" ] (. newType.EndLocation = t.Location;
compilationUnit.BlockEnd(); compilationUnit.BlockEnd();
.) .)
@ -478,6 +480,7 @@ ClassBody
{ (.List<AttributeSection> attributes = new List<AttributeSection>(); { (.List<AttributeSection> attributes = new List<AttributeSection>();
ModifierList m = new ModifierList(); ModifierList m = new ModifierList();
.) .)
SYNC
{ AttributeSection<out section> (. attributes.Add(section); .) } { AttributeSection<out section> (. attributes.Add(section); .) }
MemberModifiers<m> MemberModifiers<m>
ClassMemberDecl<m, attributes> ClassMemberDecl<m, attributes>
@ -520,7 +523,7 @@ InterfaceBase<out List<TypeReference> names>
InterfaceBody InterfaceBody
= "{" = "{"
{ InterfaceMemberDecl } { SYNC InterfaceMemberDecl }
"}" "}"
. .
@ -531,7 +534,8 @@ EnumBody (. FieldDeclaration f; .)
{ IF (NotFinalComma()) "," { IF (NotFinalComma()) ","
EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .) EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
} }
[","] ] "}" [","] ]
"}"
. .
Type<out TypeReference type> Type<out TypeReference type>
@ -1326,7 +1330,8 @@ Argument<out Expression argumentexpr>
"ref" (. fd = FieldDirection.Ref; .) "ref" (. fd = FieldDirection.Ref; .)
| "out" (. fd = FieldDirection.Out; .) | "out" (. fd = FieldDirection.Out; .)
] ]
Expr<out expr> (. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .) Expr<out expr>
(. argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; .)
. .
AssignmentOperator<out AssignmentOperatorType op> AssignmentOperator<out AssignmentOperatorType op>
@ -1415,7 +1420,8 @@ LocalVariableDecl<out Statement stmt>
LocalVariableDeclarator<out VariableDeclaration var> LocalVariableDeclarator<out VariableDeclaration var>
(. Expression expr = null; .) (. Expression expr = null; .)
= =
Identifier (. var = new VariableDeclaration(t.val); .) [ "=" VariableInitializer<out expr> (. var.Initializer = expr; .) ] Identifier (. var = new VariableDeclaration(t.val); .)
[ "=" VariableInitializer<out expr> (. var.Initializer = expr; .) ]
. .
Statement Statement
@ -1426,6 +1432,7 @@ Statement
Location startPos = la.Location; Location startPos = la.Location;
.) .)
= =
SYNC
( (
/*--- labeled statement: */ /*--- labeled statement: */
IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .) IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
@ -1436,9 +1443,11 @@ Statement
"=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .)
{ "," Identifier (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) } { "," Identifier (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) }
";" (. compilationUnit.AddChild(var); .) ";" (. compilationUnit.AddChild(var); .)
/*--- local variable declaration: */ /*--- local variable declaration: */
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .) | IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
/* LL(1) confict: LocalVariableDecl * /* LL(1) confict: LocalVariableDecl *
* <-> StatementExpr * * <-> StatementExpr *
* ident {"." ident} { "[" Expr ... */ * ident {"." ident} { "[" Expr ... */
@ -1459,17 +1468,108 @@ EmbeddedStatement<out Statement statement>
statement = null; statement = null;
.) .)
= =
Block<out statement> (. Location startLocation = la.Location; .)
/*--- empty statement: */ (
| ";" (. statement = new EmptyStatement(); .) Block<out statement>
/*--- checked / unchecked statement: */
| IF (UnCheckedAndLBrace()) (. Statement block; bool isChecked = true; .) /*--- empty statement: */
("checked" | "unchecked" (. isChecked = false;.) ) | ";" (. statement = new EmptyStatement(); .)
Block<out block> (. statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); .)
/*--- selection statements (if, switch): */ /*--- checked / unchecked statement: */
| "if" (. Statement elseStatement = null; .) | IF (UnCheckedAndLBrace()) (. Statement block; bool isChecked = true; .)
("checked" | "unchecked" (. isChecked = false;.) )
Block<out block> (. statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); .)
/*--- selection statements (if, switch): */
| IfStatement<out statement>
| "switch" (. List<SwitchSection> switchSections = new List<SwitchSection>(); .)
"(" Expr<out expr> ")"
"{" SwitchSections<switchSections>
"}" (. statement = new SwitchStatement(expr, switchSections); .)
/*--- iteration statements (while, do, for, foreach): */
| "while" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement>
(. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);.)
| "do" EmbeddedStatement<out embeddedStatement> "while"
"(" Expr<out expr> ")" ";"
(. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); .)
| "for" (. List<Statement> initializer = null; List<Statement> iterator = null; .)
"(" [ ForInitializer<out initializer> ] ";"
[ Expr<out expr> ] ";"
[ ForIterator<out iterator> ] ")"
EmbeddedStatement<out embeddedStatement> (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .)
| "foreach" "(" Type<out type> Identifier (. string varName = t.val; .)
"in" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement>
(. statement = new ForeachStatement(type, varName , expr, embeddedStatement); .)
/*--- jump statements (break, contine, goto, return, throw): */
| "break" ";" (. statement = new BreakStatement(); .)
| "continue" ";" (. statement = new ContinueStatement(); .)
| GotoStatement<out statement>
| IF (IsYieldStatement()) "yield"
( "return" Expr<out expr> (. statement = new YieldStatement(new ReturnStatement(expr)); .)
| "break" (. statement = new YieldStatement(new BreakStatement()); .) )
";"
| "return" [ Expr<out expr> ] ";" (. statement = new ReturnStatement(expr); .)
| "throw" [ Expr<out expr> ] ";" (. statement = new ThrowStatement(expr); .)
/*--- expression statement: */
| StatementExpr<out statement> SYNC ";"
/*--- try statement: */
| TryStatement<out statement>
/*--- lock satement: */
| "lock" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new LockStatement(expr, embeddedStatement); .)
/*--- using statement: */
| (.Statement resourceAcquisitionStmt = null; .)
"using" "("
ResourceAcquisition<out resourceAcquisitionStmt> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); .)
/*--- unsafe statement: */
| "unsafe" Block<out embeddedStatement> (. statement = new UnsafeStatement(embeddedStatement); .)
/*--- fixed statement: */
| "fixed"
"(" Type<out type> (. if (type.PointerNestingLevel == 0) Error("can only fix pointer types");
List<VariableDeclaration> pointerDeclarators = new List<VariableDeclaration>(1);
.)
Identifier (. string identifier = t.val; .)
"=" Expr<out expr> (. pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); .)
{
"," Identifier (. identifier = t.val; .)
"=" Expr<out expr> (. pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); .)
}
")" EmbeddedStatement<out embeddedStatement> (. statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); .)
)
(. if (statement != null) {
statement.StartLocation = startLocation;
statement.EndLocation = t.EndLocation;
}
.)
.
IfStatement<out Statement statement>
(.
Expression expr = null;
Statement embeddedStatement = null;
statement = null;
.)
=
"if"
"(" Expr<out expr> ")" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> EmbeddedStatement<out embeddedStatement>
(. Statement elseStatement = null; .)
[ "else" EmbeddedStatement<out elseStatement> ] [ "else" EmbeddedStatement<out elseStatement> ]
(. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .) (. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .)
(. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { (. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) {
@ -1479,62 +1579,8 @@ EmbeddedStatement<out Statement statement>
(elseStatement as IfElseStatement).TrueStatement[0])); (elseStatement as IfElseStatement).TrueStatement[0]));
(statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections);
(statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement;
} .) }
| "switch" (. List<SwitchSection> switchSections = new List<SwitchSection>(); .) .)
"(" Expr<out expr> ")"
"{" SwitchSections<switchSections>
"}" (. statement = new SwitchStatement(expr, switchSections); .)
/*--- iteration statements (while, do, for, foreach): */
| "while" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);.)
| "do" EmbeddedStatement<out embeddedStatement> "while"
"(" Expr<out expr> ")" ";" (. statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); .)
| "for" (. List<Statement> initializer = null; List<Statement> iterator = null; .)
"(" [ ForInitializer<out initializer> ] ";"
[ Expr<out expr> ] ";"
[ ForIterator<out iterator> ] ")"
EmbeddedStatement<out embeddedStatement> (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .)
| "foreach" "(" Type<out type> Identifier (. string varName = t.val; Location start = t.Location;.)
"in" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new ForeachStatement(type, varName , expr, embeddedStatement);
statement.EndLocation = t.EndLocation;
.)
/*--- jump statements (break, contine, goto, return, throw): */
| "break" ";" (. statement = new BreakStatement(); .)
| "continue" ";" (. statement = new ContinueStatement(); .)
| GotoStatement<out statement>
| IF (IsYieldStatement()) "yield" ( "return" Expr<out expr> (. statement = new YieldStatement(new ReturnStatement(expr)); .)
| "break" (. statement = new YieldStatement(new BreakStatement()); .) ) ";"
| "return" [ Expr<out expr> ] ";" (. statement = new ReturnStatement(expr); .)
| "throw" [ Expr<out expr> ] ";" (. statement = new ThrowStatement(expr); .)
/*--- expression statement: */
| StatementExpr<out statement> ";"
/*--- try statement: */
| TryStatement<out statement>
/*--- lock satement: */
| "lock" "(" Expr<out expr> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new LockStatement(expr, embeddedStatement); .)
/*--- using statement: */
| (.Statement resourceAcquisitionStmt = null; .)
"using" "("
ResourceAcquisition<out resourceAcquisitionStmt> ")"
EmbeddedStatement<out embeddedStatement> (. statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); .)
/*--- unsafe statement: */
| "unsafe" Block<out embeddedStatement> (. statement = new UnsafeStatement(embeddedStatement); .)
/*--- fixed statement: */
| "fixed"
"(" Type<out type> (. if (type.PointerNestingLevel == 0) Error("can only fix pointer types");
List<VariableDeclaration> pointerDeclarators = new List<VariableDeclaration>(1);
.)
Identifier (. string identifier = t.val; .)
"=" Expr<out expr> (. pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); .)
{
"," Identifier (. identifier = t.val; .)
"=" Expr<out expr> (. pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); .)
}
")" EmbeddedStatement<out embeddedStatement> (. statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); .)
. .
ForInitializer<out List<Statement> initializer> ForInitializer<out List<Statement> initializer>
@ -1670,6 +1716,7 @@ StatementExpr<out Statement stmt>
Expr<out Expression expr> Expr<out Expression expr>
(. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .) (. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .)
= =
(. Location startLocation = la.Location; .)
UnaryExpr<out expr> UnaryExpr<out expr>
/*--- conditional expression: */ /*--- conditional expression: */
( (
@ -1682,6 +1729,11 @@ Expr<out Expression expr>
[ "?" Expr<out expr1> ":" Expr<out expr2> (. expr = new ConditionalExpression(expr, expr1, expr2); .) ] [ "?" Expr<out expr1> ":" Expr<out expr2> (. expr = new ConditionalExpression(expr, expr1, expr2); .) ]
) )
) )
(. if (expr != null) {
expr.StartLocation = startLocation;
expr.EndLocation = t.EndLocation;
}
.)
. .
@ -1752,79 +1804,83 @@ PrimaryExpr<out Expression pexpr>
pexpr = null; pexpr = null;
.) .)
= =
(. Location startLocation = la.Location; .)
( (
"true" (.pexpr = new PrimitiveExpression(true, "true"); .) "true" (.pexpr = new PrimitiveExpression(true, "true"); .)
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .) | "false" (.pexpr = new PrimitiveExpression(false, "false"); .)
| "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */ | "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */
| Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .) | Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .)
| IF (StartOfQueryExpression()) | IF (StartOfQueryExpression())
QueryExpression<out pexpr> QueryExpression<out pexpr>
| IF (IdentAndDoubleColon()) | IF (IdentAndDoubleColon())
Identifier (. type = new TypeReference(t.val); .) Identifier (. type = new TypeReference(t.val); .)
"::" (. pexpr = new TypeReferenceExpression(type); .) "::" (. pexpr = new TypeReferenceExpression(type); .)
Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); .) Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); .)
/*--- simple name (IdentifierExpression): */ /*--- simple name (IdentifierExpression): */
| Identifier | Identifier
(. pexpr = new IdentifierExpression(t.val); .) (. pexpr = new IdentifierExpression(t.val); .)
(. pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; .)
[ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr>
[ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr> | IF (IsGenericInSimpleNameOrMemberAccess())
| IF (IsGenericInSimpleNameOrMemberAccess()) (. List<TypeReference> typeList; .)
(. List<TypeReference> typeList; .) TypeArgumentList<out typeList, false>
TypeArgumentList<out typeList, false> (. ((IdentifierExpression)pexpr).TypeArguments = typeList; .)
(. ((IdentifierExpression)pexpr).TypeArguments = typeList; .) ]
] | IF (IsLambdaExpression()) /* Lambda expression */
| IF (IsLambdaExpression()) /* Lambda expression */ LambdaExpression<out pexpr>
LambdaExpression<out pexpr>
/*--- parenthesized expression: */ /*--- parenthesized expression: */
| "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .) | "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
| /*--- predefined type member access: */
| /*--- predefined type member access: */
(. string val = null; .) (. string val = null; .)
( ( "bool" (. val = "bool"; .)
"bool" (. val = "bool"; .) | "byte" (. val = "byte"; .)
| "byte" (. val = "byte"; .) | "char" (. val = "char"; .)
| "char" (. val = "char"; .) | "decimal" (. val = "decimal"; .)
| "decimal" (. val = "decimal"; .) | "double" (. val = "double"; .)
| "double" (. val = "double"; .) | "float" (. val = "float"; .)
| "float" (. val = "float"; .) | "int" (. val = "int"; .)
| "int" (. val = "int"; .) | "long" (. val = "long"; .)
| "long" (. val = "long"; .) | "object" (. val = "object"; .)
| "object" (. val = "object"; .) | "sbyte" (. val = "sbyte"; .)
| "sbyte" (. val = "sbyte"; .) | "short" (. val = "short"; .)
| "short" (. val = "short"; .) | "string" (. val = "string"; .)
| "string" (. val = "string"; .) | "uint" (. val = "uint"; .)
| "uint" (. val = "uint"; .) | "ulong" (. val = "ulong"; .)
| "ulong" (. val = "ulong"; .) | "ushort" (. val = "ushort"; .)
| "ushort" (. val = "ushort"; .)
) )
MemberAccess<out pexpr, new TypeReferenceExpression(val)> MemberAccess<out pexpr, new TypeReferenceExpression(val)>
/*--- this access: */ /*--- this access: */
| "this" (. pexpr = new ThisReferenceExpression(); .) | "this" (. pexpr = new ThisReferenceExpression(); .)
/*--- base access: */ /*--- base access: */
| "base" (. Expression retExpr = new BaseReferenceExpression(); .) | "base" (. pexpr = new BaseReferenceExpression(); .)
(
MemberAccess<out retExpr, retExpr>
| "[" Expr<out expr> (. List<Expression> indices = new List<Expression>(); if (expr != null) { indices.Add(expr); } .)
{ "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .) }
"]" (. retExpr = new IndexerExpression(retExpr, indices); .)
) (. pexpr = retExpr; .)
/* new ... - ObjectCreationExpression or ArrayCreateExpression */ /* new ... - ObjectCreationExpression or ArrayCreateExpression */
| NewExpression<out expr> (.pexpr = expr; .) | NewExpression<out pexpr>
| "typeof" "(" | "typeof" "("
( (
IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .) IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .)
| TypeWithRestriction<out type, true, true> | TypeWithRestriction<out type, true, true>
) ")" (. pexpr = new TypeOfExpression(type); .) )
")" (. pexpr = new TypeOfExpression(type); .)
| "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .) | "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
| "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(expr); .) | "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
| "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .) | "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(expr); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .) | "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
) )
(. if (pexpr != null) {
pexpr.StartLocation = startLocation;
pexpr.EndLocation = t.EndLocation;
}
.)
{ {
(. startLocation = la.Location; .)
( (
"++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .) "++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .)
| "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .) | "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .)
@ -1836,8 +1892,10 @@ PrimaryExpr<out Expression pexpr>
/*--- invocation expression: */ /*--- invocation expression: */
| "(" (. List<Expression> parameters = new List<Expression>(); .) | "(" (. List<Expression> parameters = new List<Expression>(); .)
[ Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .) [ Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
{ "," Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .) { "," Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
} ] ")" (. pexpr = new InvocationExpression(pexpr, parameters); .) }
]
")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
/*--- element access */ /*--- element access */
| (. /*if (isArrayCreation) Error("element access not allow on array creation");*/ | (. /*if (isArrayCreation) Error("element access not allow on array creation");*/
List<Expression> indices = new List<Expression>(); List<Expression> indices = new List<Expression>();
@ -1845,6 +1903,12 @@ PrimaryExpr<out Expression pexpr>
"[" Expr<out expr> (. if (expr != null) { indices.Add(expr); } .) "[" Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
{ "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .) { "," Expr<out expr> (. if (expr != null) { indices.Add(expr); } .)
} "]" (. pexpr = new IndexerExpression(pexpr, indices); .) } "]" (. pexpr = new IndexerExpression(pexpr, indices); .)
(. if (pexpr != null) {
pexpr.StartLocation = startLocation;
pexpr.EndLocation = t.EndLocation;
}
.)
} }
. .

2
src/Libraries/NRefactory/Project/Src/SnippetParser.cs

@ -117,6 +117,8 @@ namespace ICSharpCode.NRefactory
set { throw new NotSupportedException(); } set { throw new NotSupportedException(); }
} }
public object UserData { get; set; }
public object AcceptChildren(IAstVisitor visitor, object data) public object AcceptChildren(IAstVisitor visitor, object data)
{ {
foreach (INode n in nodes) { foreach (INode n in nodes) {

11
src/Main/Base/Project/Src/Gui/AbstractViewContent.cs

@ -53,13 +53,22 @@ namespace ICSharpCode.SharpDevelop.Gui
IWorkbenchWindow IViewContent.WorkbenchWindow { IWorkbenchWindow IViewContent.WorkbenchWindow {
get { return workbenchWindow; } get { return workbenchWindow; }
set { workbenchWindow = value; } set {
if (workbenchWindow != value) {
workbenchWindow = value;
OnWorkbenchWindowChanged();
}
}
} }
public IWorkbenchWindow WorkbenchWindow { public IWorkbenchWindow WorkbenchWindow {
get { return workbenchWindow; } get { return workbenchWindow; }
} }
protected virtual void OnWorkbenchWindowChanged()
{
}
string tabPageText = "TabPageText"; string tabPageText = "TabPageText";
public event EventHandler TabPageTextChanged; public event EventHandler TabPageTextChanged;

8
src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs

@ -38,6 +38,14 @@ namespace ICSharpCode.SharpDevelop.Gui
set; set;
} }
/// <summary>
/// Gets/Sets the icon of the view content.
/// </summary>
System.Drawing.Icon Icon {
get;
set;
}
/// <summary> /// <summary>
/// Is raised when the ActiveViewContent property has changed. /// Is raised when the ActiveViewContent property has changed.
/// </summary> /// </summary>

10
src/Main/Base/Project/Src/Gui/Pads/FileScout.cs

@ -19,7 +19,7 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
{ {
public class DriveObject sealed class DriveObject
{ {
DriveInfo driveInfo; DriveInfo driveInfo;
string text = null; string text = null;
@ -64,7 +64,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
class IconManager sealed class IconManager
{ {
private static ImageList icons = new ImageList(); private static ImageList icons = new ImageList();
private static Hashtable iconIndecies = new Hashtable(); private static Hashtable iconIndecies = new Hashtable();
@ -110,7 +110,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
public class FileList : ListView sealed class FileList : ListView
{ {
private FileSystemWatcher watcher; private FileSystemWatcher watcher;
@ -305,7 +305,7 @@ namespace ICSharpCode.SharpDevelop.Gui
EndUpdate(); EndUpdate();
} }
public class FileListItem : ListViewItem internal class FileListItem : ListViewItem
{ {
string fullname; string fullname;
public string FullName { public string FullName {
@ -403,7 +403,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
public class ShellTree : TreeView sealed class ShellTree : TreeView
{ {
public string NodePath { public string NodePath {
get { get {

2
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public IViewContent ActiveViewContent { public IViewContent ActiveViewContent {
get { get {
Debug.Assert(WorkbenchSingleton.InvokeRequired == false); Debug.Assert(WorkbenchSingleton.InvokeRequired == false);
if (viewTabControl != null && viewTabControl.SelectedIndex >= 0) { if (viewTabControl != null && viewTabControl.SelectedIndex >= 0 && viewTabControl.SelectedIndex < ViewContents.Count) {
return ViewContents[viewTabControl.SelectedIndex]; return ViewContents[viewTabControl.SelectedIndex];
} else if (ViewContents.Count == 1) { } else if (ViewContents.Count == 1) {
return ViewContents[0]; return ViewContents[0];

2
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -144,6 +144,8 @@ namespace ICSharpCode.SharpDevelop.Gui
public STAThreadCaller(Control ctl) public STAThreadCaller(Control ctl)
{ {
if (ctl == null)
throw new ArgumentNullException("ctl");
this.ctl = ctl; this.ctl = ctl;
} }

5
src/Main/Base/Project/Src/Services/DisplayBinding/ShellExecuteDisplayBinding.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using System.Diagnostics; using System.Diagnostics;
@ -27,7 +28,9 @@ namespace ICSharpCode.SharpDevelop
// TODO: warn user that the file must be saved // TODO: warn user that the file must be saved
} }
try { try {
Process.Start(file.FileName); Process.Start(new ProcessStartInfo(file.FileName) {
WorkingDirectory = Path.GetDirectoryName(file.FileName)
});
} catch (Exception ex) { } catch (Exception ex) {
MessageService.ShowError(ex.Message); MessageService.ShowError(ex.Message);
} }

26
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -388,11 +388,6 @@ namespace ICSharpCode.SharpDevelop
LoggingService.Info("ParserUpdateThread stopped"); LoggingService.Info("ParserUpdateThread stopped");
} }
static IViewContent GetActiveViewContent()
{
return WorkbenchSingleton.Workbench.ActiveViewContent;
}
public static void ParseCurrentViewContent() public static void ParseCurrentViewContent()
{ {
ParserUpdateStep(); ParserUpdateStep();
@ -400,9 +395,22 @@ namespace ICSharpCode.SharpDevelop
static void ParserUpdateStep() static void ParserUpdateStep()
{ {
IViewContent activeViewContent; IViewContent activeViewContent = null;
string fileName = null;
bool isUntitled = false;
try { try {
activeViewContent = WorkbenchSingleton.SafeThreadFunction<IViewContent>(GetActiveViewContent); WorkbenchSingleton.SafeThreadCall(
delegate {
try {
activeViewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (activeViewContent != null && activeViewContent.PrimaryFile != null) {
fileName = activeViewContent.PrimaryFileName;
isUntitled = activeViewContent.PrimaryFile.IsUntitled;
}
} catch (Exception ex) {
MessageService.ShowError(ex.ToString());
}
});
} catch (InvalidOperationException) { // includes ObjectDisposedException } catch (InvalidOperationException) { // includes ObjectDisposedException
// maybe workbench has been disposed while waiting for the SafeThreadCall // maybe workbench has been disposed while waiting for the SafeThreadCall
// can occur after workbench unload or after aborting SharpDevelop with // can occur after workbench unload or after aborting SharpDevelop with
@ -412,8 +420,6 @@ namespace ICSharpCode.SharpDevelop
} }
IEditable editable = activeViewContent as IEditable; IEditable editable = activeViewContent as IEditable;
if (editable != null) { if (editable != null) {
#warning PrimaryFileName is not thread-safe, move all property accesses that are not guaranteed to be thread-safe into GetActiveViewContent
string fileName = activeViewContent.PrimaryFileName;
string text = null; string text = null;
if (!(fileName == null || fileName.Length == 0)) { if (!(fileName == null || fileName.Length == 0)) {
@ -425,7 +431,7 @@ namespace ICSharpCode.SharpDevelop
} }
int hash = text.GetHashCode(); int hash = text.GetHashCode();
if (!lastUpdateHash.ContainsKey(fileName) || lastUpdateHash[fileName] != hash) { if (!lastUpdateHash.ContainsKey(fileName) || lastUpdateHash[fileName] != hash) {
parseInformation = ParseFile(fileName, text, !activeViewContent.PrimaryFile.IsUntitled); parseInformation = ParseFile(fileName, text, !isUntitled);
lastUpdateHash[fileName] = hash; lastUpdateHash[fileName] = hash;
updated = true; updated = true;
} }

19
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -312,12 +312,29 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
} }
ParserService.ClearParseInformation(oldFileName); SetIcon();
ParserService.ClearParseInformation(oldFileName);
textEditorControl.FileName = newFileName; textEditorControl.FileName = newFileName;
ParserService.ParseViewContent(this); ParserService.ParseViewContent(this);
} }
protected override void OnWorkbenchWindowChanged()
{
base.OnWorkbenchWindowChanged();
SetIcon();
}
void SetIcon()
{
if (this.WorkbenchWindow != null) {
System.Drawing.Icon icon = ResourceService.GetIcon(IconService.GetImageForFile(this.PrimaryFileName));
if (icon != null) {
this.WorkbenchWindow.Icon = icon;
}
}
}
#region IPositionable implementation #region IPositionable implementation
public void JumpTo(int line, int column) public void JumpTo(int line, int column)
{ {

13
src/Main/Base/Test/CSharpExpressionFinderTests.cs

@ -336,6 +336,19 @@ class Main {
Assert.AreEqual(ExpressionContext.ObjectCreation.ToString(), result.Context.ToString()); Assert.AreEqual(ExpressionContext.ObjectCreation.ToString(), result.Context.ToString());
} }
[Test]
public void FindObjectCreationContextForConstructorInsight4()
{
const string program = @"using System; using System.Text;
class Main {
void M() {
StringBuilder b = new StringBuilderBla";
ExpressionResult result = ef.FindExpression(program, program.Length - 3);
Assert.AreEqual("StringBuilder", result.Expression);
Assert.AreEqual(ExpressionContext.ObjectCreation.ToString(), result.Context.ToString());
}
[Test] [Test]
public void ExpressionContextInFieldInitializer() public void ExpressionContextInFieldInitializer()
{ {

5
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs

@ -264,10 +264,13 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
while ((token = lexer.NextToken()) != null) { while ((token = lexer.NextToken()) != null) {
if (token.kind == Tokens.EOF) break; if (token.kind == Tokens.EOF) break;
if (targetPosition < token.EndLocation) { if (targetPosition <= token.Location) {
break; break;
} }
ApplyToken(token); ApplyToken(token);
if (targetPosition < token.EndLocation) {
break;
}
lastToken = token.kind; lastToken = token.kind;
} }

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CecilReader.cs

@ -453,7 +453,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (field.IsLiteral) if (field.IsLiteral)
m |= ModifierEnum.Const; m |= ModifierEnum.Const;
else if (field.IsReadOnly) else if (field.IsInitOnly)
m |= ModifierEnum.Readonly; m |= ModifierEnum.Readonly;
if ((field.Attributes & FieldAttributes.Public) == FieldAttributes.Public) if ((field.Attributes & FieldAttributes.Public) == FieldAttributes.Public)

Loading…
Cancel
Save