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. 334
      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 @@ @@ -33,127 +33,20 @@
<Files>
<File name="${ProjectName}.addin" CopyToOutputDirectory="Always"><![CDATA[<AddIn name = "${ProjectName}"
author = "${USER}"
url = ""
description = "TODO: Put description here">
<Runtime>
<Import assembly = "${ProjectName}.dll"/>
</Runtime>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "${ProjectName}Pad"
category = "Main"
title = "${ProjectName}Pad"
icon = "PadIcons.Output"
shortcut = "Control|Alt|T"
class = "${ProjectName}.TestPad"/>
</Path>
author = "${USER}"
url = ""
description = "TODO: Put description here">
<Runtime>
<Import assembly = "${ProjectName}.dll"/>
</Runtime>
<!-- Extend the SharpDevelop AddIn-Tree like this:
<Path name = ...>
<.../>
</Path>
-->
</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 name="Configuration/AssemblyInfo.cs" src="DefaultAssemblyInfo.cs"/>
<File name="AddInWritingHelp.txt" src="..\AddInWritingHelp.txt"/>

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

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

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

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

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

File diff suppressed because it is too large Load Diff

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

@ -362,7 +362,9 @@ TypeDecl<ModifierList m, List<AttributeSection> attributes> @@ -362,7 +362,9 @@ TypeDecl<ModifierList m, List<AttributeSection> attributes>
{ TypeParameterConstraintsClause<templates> }
(. newType.BodyStartLocation = t.EndLocation; .)
"{" ClassBody "}"
"{"
ClassBody
"}"
[ ";" ] (. newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
.)
@ -478,6 +480,7 @@ ClassBody @@ -478,6 +480,7 @@ ClassBody
{ (.List<AttributeSection> attributes = new List<AttributeSection>();
ModifierList m = new ModifierList();
.)
SYNC
{ AttributeSection<out section> (. attributes.Add(section); .) }
MemberModifiers<m>
ClassMemberDecl<m, attributes>
@ -505,7 +508,7 @@ StructBody @@ -505,7 +508,7 @@ StructBody
MemberModifiers<m>
StructMemberDecl<m, attributes>
}
"}"
"}"
.
InterfaceBase<out List<TypeReference> names>
@ -520,7 +523,7 @@ InterfaceBase<out List<TypeReference> names> @@ -520,7 +523,7 @@ InterfaceBase<out List<TypeReference> names>
InterfaceBody
= "{"
{ InterfaceMemberDecl }
{ SYNC InterfaceMemberDecl }
"}"
.
@ -531,7 +534,8 @@ EnumBody (. FieldDeclaration f; .) @@ -531,7 +534,8 @@ EnumBody (. FieldDeclaration f; .)
{ IF (NotFinalComma()) ","
EnumMemberDecl<out f> (. compilationUnit.AddChild(f); .)
}
[","] ] "}"
[","] ]
"}"
.
Type<out TypeReference type>
@ -1326,7 +1330,8 @@ Argument<out Expression argumentexpr> @@ -1326,7 +1330,8 @@ Argument<out Expression argumentexpr>
"ref" (. fd = FieldDirection.Ref; .)
| "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>
@ -1415,7 +1420,8 @@ LocalVariableDecl<out Statement stmt> @@ -1415,7 +1420,8 @@ LocalVariableDecl<out Statement stmt>
LocalVariableDeclarator<out VariableDeclaration var>
(. 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
@ -1426,6 +1432,7 @@ Statement @@ -1426,6 +1432,7 @@ Statement
Location startPos = la.Location;
.)
=
SYNC
(
/*--- labeled statement: */
IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
@ -1436,9 +1443,11 @@ Statement @@ -1436,9 +1443,11 @@ Statement
"=" 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); .)
/*--- local variable declaration: */
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
/* LL(1) confict: LocalVariableDecl *
* <-> StatementExpr *
* ident {"." ident} { "[" Expr ... */
@ -1459,17 +1468,108 @@ EmbeddedStatement<out Statement statement> @@ -1459,17 +1468,108 @@ EmbeddedStatement<out Statement statement>
statement = null;
.)
=
Block<out statement>
/*--- empty statement: */
| ";" (. statement = new EmptyStatement(); .)
/*--- checked / unchecked statement: */
| 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): */
| "if" (. Statement elseStatement = null; .)
(. Location startLocation = la.Location; .)
(
Block<out statement>
/*--- empty statement: */
| ";" (. statement = new EmptyStatement(); .)
/*--- checked / unchecked statement: */
| 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> ")"
EmbeddedStatement<out embeddedStatement>
(. Statement elseStatement = null; .)
[ "else" EmbeddedStatement<out elseStatement> ]
(. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .)
(. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) {
@ -1479,62 +1579,8 @@ EmbeddedStatement<out Statement statement> @@ -1479,62 +1579,8 @@ EmbeddedStatement<out Statement statement>
(elseStatement as IfElseStatement).TrueStatement[0]));
(statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections);
(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>
@ -1670,6 +1716,7 @@ StatementExpr<out Statement stmt> @@ -1670,6 +1716,7 @@ StatementExpr<out Statement stmt>
Expr<out Expression expr>
(. expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; .)
=
(. Location startLocation = la.Location; .)
UnaryExpr<out expr>
/*--- conditional expression: */
(
@ -1682,6 +1729,11 @@ Expr<out Expression expr> @@ -1682,6 +1729,11 @@ Expr<out Expression expr>
[ "?" 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> @@ -1752,79 +1804,83 @@ PrimaryExpr<out Expression pexpr>
pexpr = null;
.)
=
(. Location startLocation = la.Location; .)
(
"true" (.pexpr = new PrimitiveExpression(true, "true"); .)
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .)
| "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */
| Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .)
| IF (StartOfQueryExpression())
QueryExpression<out pexpr>
| IF (IdentAndDoubleColon())
Identifier (. type = new TypeReference(t.val); .)
"::" (. pexpr = new TypeReferenceExpression(type); .)
Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); .)
| "false" (.pexpr = new PrimitiveExpression(false, "false"); .)
| "null" (.pexpr = new PrimitiveExpression(null, "null"); .) /* from literal token */
| Literal (.pexpr = new PrimitiveExpression(t.literalValue, t.val); .)
| IF (StartOfQueryExpression())
QueryExpression<out pexpr>
| IF (IdentAndDoubleColon())
Identifier (. type = new TypeReference(t.val); .)
"::" (. pexpr = new TypeReferenceExpression(type); .)
Identifier (. if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); .)
/*--- simple name (IdentifierExpression): */
| Identifier
(. pexpr = new IdentifierExpression(t.val); .)
(. pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; .)
[ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr>
| IF (IsGenericInSimpleNameOrMemberAccess())
(. List<TypeReference> typeList; .)
TypeArgumentList<out typeList, false>
(. ((IdentifierExpression)pexpr).TypeArguments = typeList; .)
]
| IF (IsLambdaExpression()) /* Lambda expression */
LambdaExpression<out pexpr>
| Identifier
(. pexpr = new IdentifierExpression(t.val); .)
[ ShortedLambdaExpression<(IdentifierExpression)pexpr, out pexpr>
| IF (IsGenericInSimpleNameOrMemberAccess())
(. List<TypeReference> typeList; .)
TypeArgumentList<out typeList, false>
(. ((IdentifierExpression)pexpr).TypeArguments = typeList; .)
]
| IF (IsLambdaExpression()) /* Lambda expression */
LambdaExpression<out pexpr>
/*--- parenthesized expression: */
| "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
| /*--- predefined type member access: */
| "(" Expr<out expr> ")" (. pexpr = new ParenthesizedExpression(expr); .)
| /*--- predefined type member access: */
(. string val = null; .)
(
"bool" (. val = "bool"; .)
| "byte" (. val = "byte"; .)
| "char" (. val = "char"; .)
| "decimal" (. val = "decimal"; .)
| "double" (. val = "double"; .)
| "float" (. val = "float"; .)
| "int" (. val = "int"; .)
| "long" (. val = "long"; .)
| "object" (. val = "object"; .)
| "sbyte" (. val = "sbyte"; .)
| "short" (. val = "short"; .)
| "string" (. val = "string"; .)
| "uint" (. val = "uint"; .)
| "ulong" (. val = "ulong"; .)
| "ushort" (. val = "ushort"; .)
)
MemberAccess<out pexpr, new TypeReferenceExpression(val)>
( "bool" (. val = "bool"; .)
| "byte" (. val = "byte"; .)
| "char" (. val = "char"; .)
| "decimal" (. val = "decimal"; .)
| "double" (. val = "double"; .)
| "float" (. val = "float"; .)
| "int" (. val = "int"; .)
| "long" (. val = "long"; .)
| "object" (. val = "object"; .)
| "sbyte" (. val = "sbyte"; .)
| "short" (. val = "short"; .)
| "string" (. val = "string"; .)
| "uint" (. val = "uint"; .)
| "ulong" (. val = "ulong"; .)
| "ushort" (. val = "ushort"; .)
)
MemberAccess<out pexpr, new TypeReferenceExpression(val)>
/*--- this access: */
| "this" (. pexpr = new ThisReferenceExpression(); .)
| "this" (. pexpr = new ThisReferenceExpression(); .)
/*--- base access: */
| "base" (. Expression retExpr = 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; .)
| "base" (. pexpr = new BaseReferenceExpression(); .)
/* new ... - ObjectCreationExpression or ArrayCreateExpression */
| NewExpression<out expr> (.pexpr = expr; .)
| "typeof" "("
| NewExpression<out pexpr>
| "typeof" "("
(
IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .)
| TypeWithRestriction<out type, true, true>
) ")" (. pexpr = new TypeOfExpression(type); .)
| TypeWithRestriction<out type, true, true>
)
")" (. pexpr = new TypeOfExpression(type); .)
| "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
| "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(expr); .)
| "unchecked" "(" Expr<out expr> ")" (. pexpr = new UncheckedExpression(expr); .)
| "delegate" AnonymousMethodExpr<out expr> (. pexpr = expr; .)
| "default" "(" Type<out type> ")" (. pexpr = new DefaultValueExpression(type); .)
| "sizeof" "(" Type<out type> ")" (. pexpr = new SizeOfExpression(type); .)
| "checked" "(" Expr<out expr> ")" (. pexpr = new CheckedExpression(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.PostDecrement); .)
@ -1836,8 +1892,10 @@ PrimaryExpr<out Expression pexpr> @@ -1836,8 +1892,10 @@ PrimaryExpr<out Expression pexpr>
/*--- invocation 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);} .)
} ] ")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
{ "," Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
}
]
")" (. pexpr = new InvocationExpression(pexpr, parameters); .)
/*--- element access */
| (. /*if (isArrayCreation) Error("element access not allow on array creation");*/
List<Expression> indices = new List<Expression>();
@ -1845,6 +1903,12 @@ PrimaryExpr<out Expression pexpr> @@ -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); } .)
} "]" (. 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 @@ -117,6 +117,8 @@ namespace ICSharpCode.NRefactory
set { throw new NotSupportedException(); }
}
public object UserData { get; set; }
public object AcceptChildren(IAstVisitor visitor, object data)
{
foreach (INode n in nodes) {

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

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

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

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

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

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

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

@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public IViewContent ActiveViewContent {
get {
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];
} else if (ViewContents.Count == 1) {
return ViewContents[0];

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

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

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

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

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

@ -388,11 +388,6 @@ namespace ICSharpCode.SharpDevelop @@ -388,11 +388,6 @@ namespace ICSharpCode.SharpDevelop
LoggingService.Info("ParserUpdateThread stopped");
}
static IViewContent GetActiveViewContent()
{
return WorkbenchSingleton.Workbench.ActiveViewContent;
}
public static void ParseCurrentViewContent()
{
ParserUpdateStep();
@ -400,9 +395,22 @@ namespace ICSharpCode.SharpDevelop @@ -400,9 +395,22 @@ namespace ICSharpCode.SharpDevelop
static void ParserUpdateStep()
{
IViewContent activeViewContent;
IViewContent activeViewContent = null;
string fileName = null;
bool isUntitled = false;
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
// maybe workbench has been disposed while waiting for the SafeThreadCall
// can occur after workbench unload or after aborting SharpDevelop with
@ -412,8 +420,6 @@ namespace ICSharpCode.SharpDevelop @@ -412,8 +420,6 @@ namespace ICSharpCode.SharpDevelop
}
IEditable editable = activeViewContent as IEditable;
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;
if (!(fileName == null || fileName.Length == 0)) {
@ -425,7 +431,7 @@ namespace ICSharpCode.SharpDevelop @@ -425,7 +431,7 @@ namespace ICSharpCode.SharpDevelop
}
int hash = text.GetHashCode();
if (!lastUpdateHash.ContainsKey(fileName) || lastUpdateHash[fileName] != hash) {
parseInformation = ParseFile(fileName, text, !activeViewContent.PrimaryFile.IsUntitled);
parseInformation = ParseFile(fileName, text, !isUntitled);
lastUpdateHash[fileName] = hash;
updated = true;
}

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

@ -312,12 +312,29 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -312,12 +312,29 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
ParserService.ClearParseInformation(oldFileName);
SetIcon();
ParserService.ClearParseInformation(oldFileName);
textEditorControl.FileName = newFileName;
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
public void JumpTo(int line, int column)
{

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

@ -336,6 +336,19 @@ class Main { @@ -336,6 +336,19 @@ class Main {
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]
public void ExpressionContextInFieldInitializer()
{

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

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

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

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

Loading…
Cancel
Save