Browse Source

Fixed bug in C# parser that could generate null reference as method invocation argument (+added unit tests).

Fixed bug regarding FileSystemWatcher to prevent crash when file was changed externally.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@136 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
0b5f2e9148
  1. BIN
      doc/technotes/AddInBuildingGuide.sxw
  2. 13
      src/AddIns/Misc/StartPage/Project/Src/Main.cs
  3. 334
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  4. 11
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  5. 18
      src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs
  6. 15
      src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs
  7. 13
      src/Libraries/NRefactory/Test/Parser/ParseUtilCSharp.cs
  8. 6
      src/Main/Base/Project/Src/Commands/AutostartCommands.cs
  9. 27
      src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs
  10. 4
      src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs
  11. 6
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  12. 43
      src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs
  13. 15
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  14. 7
      src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs
  15. 64
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

BIN
doc/technotes/AddInBuildingGuide.sxw

Binary file not shown.

13
src/AddIns/Misc/StartPage/Project/Src/Main.cs

@ -6,6 +6,7 @@ using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.BrowserDisplayBinding; using ICSharpCode.SharpDevelop.BrowserDisplayBinding;
namespace ICSharpCode.StartPage namespace ICSharpCode.StartPage
@ -17,6 +18,18 @@ namespace ICSharpCode.StartPage
{ {
public StartPageView() : base(new Uri("startpage://start/")) public StartPageView() : base(new Uri("startpage://start/"))
{ {
ProjectService.SolutionLoaded += HandleCombineOpened;
}
void HandleCombineOpened(object sender, SolutionEventArgs e)
{
WorkbenchWindow.CloseWindow(true);
}
public override void Dispose()
{
ProjectService.SolutionLoaded -= HandleCombineOpened;
base.Dispose();
} }
} }

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

@ -1091,39 +1091,39 @@ out p);
} }
void TypeParameterList( void TypeParameterList(
#line 2107 "cs.ATG" #line 2110 "cs.ATG"
List<TemplateDefinition> templates) { List<TemplateDefinition> templates) {
#line 2109 "cs.ATG" #line 2112 "cs.ATG"
AttributeSection section; AttributeSection section;
ArrayList attributes = new ArrayList(); ArrayList attributes = new ArrayList();
Expect(22); Expect(22);
while (la.kind == 17) { while (la.kind == 17) {
AttributeSection( AttributeSection(
#line 2113 "cs.ATG" #line 2116 "cs.ATG"
out section); out section);
#line 2113 "cs.ATG" #line 2116 "cs.ATG"
attributes.Add(section); attributes.Add(section);
} }
Expect(1); Expect(1);
#line 2114 "cs.ATG" #line 2117 "cs.ATG"
templates.Add(new TemplateDefinition(t.val, attributes)); templates.Add(new TemplateDefinition(t.val, attributes));
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
while (la.kind == 17) { while (la.kind == 17) {
AttributeSection( AttributeSection(
#line 2115 "cs.ATG" #line 2118 "cs.ATG"
out section); out section);
#line 2115 "cs.ATG" #line 2118 "cs.ATG"
attributes.Add(section); attributes.Add(section);
} }
Expect(1); Expect(1);
#line 2116 "cs.ATG" #line 2119 "cs.ATG"
templates.Add(new TemplateDefinition(t.val, attributes)); templates.Add(new TemplateDefinition(t.val, attributes));
} }
Expect(21); Expect(21);
@ -1157,25 +1157,25 @@ out qualident);
} }
void TypeParameterConstraintsClause( void TypeParameterConstraintsClause(
#line 2120 "cs.ATG" #line 2123 "cs.ATG"
List<TemplateDefinition> templates) { List<TemplateDefinition> templates) {
#line 2121 "cs.ATG" #line 2124 "cs.ATG"
string name = ""; TypeReference type; string name = ""; TypeReference type;
Expect(1); Expect(1);
#line 2123 "cs.ATG" #line 2126 "cs.ATG"
if (t.val != "where") Error("where expected"); if (t.val != "where") Error("where expected");
Expect(1); Expect(1);
#line 2124 "cs.ATG" #line 2127 "cs.ATG"
name = t.val; name = t.val;
Expect(9); Expect(9);
TypeParameterConstraintsClauseBase( TypeParameterConstraintsClauseBase(
#line 2126 "cs.ATG" #line 2129 "cs.ATG"
out type); out type);
#line 2127 "cs.ATG" #line 2130 "cs.ATG"
TemplateDefinition td = null; TemplateDefinition td = null;
foreach (TemplateDefinition d in templates) { foreach (TemplateDefinition d in templates) {
if (d.Name == name) { if (d.Name == name) {
@ -1188,10 +1188,10 @@ out type);
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
TypeParameterConstraintsClauseBase( TypeParameterConstraintsClauseBase(
#line 2136 "cs.ATG" #line 2139 "cs.ATG"
out type); out type);
#line 2137 "cs.ATG" #line 2140 "cs.ATG"
td = null; td = null;
foreach (TemplateDefinition d in templates) { foreach (TemplateDefinition d in templates) {
if (d.Name == name) { if (d.Name == name) {
@ -2553,20 +2553,20 @@ out type);
} }
void TypeName( void TypeName(
#line 2089 "cs.ATG" #line 2092 "cs.ATG"
out string qualident, out List<TypeReference> types) { out string qualident, out List<TypeReference> types) {
#line 2090 "cs.ATG" #line 2093 "cs.ATG"
List<TypeReference> t; types = new List<TypeReference>(); List<TypeReference> t; types = new List<TypeReference>();
Qualident( Qualident(
#line 2092 "cs.ATG" #line 2095 "cs.ATG"
out qualident); out qualident);
if (la.kind == 22) { if (la.kind == 22) {
TypeArgumentList( TypeArgumentList(
#line 2093 "cs.ATG" #line 2096 "cs.ATG"
out t); out t);
#line 2093 "cs.ATG" #line 2096 "cs.ATG"
types = t; types = t;
} }
} }
@ -4161,24 +4161,24 @@ out expr);
} }
void ConditionalOrExpr( void ConditionalOrExpr(
#line 1967 "cs.ATG" #line 1970 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 1968 "cs.ATG" #line 1971 "cs.ATG"
Expression expr; Expression expr;
ConditionalAndExpr( ConditionalAndExpr(
#line 1970 "cs.ATG" #line 1973 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 25) { while (la.kind == 25) {
lexer.NextToken(); lexer.NextToken();
UnaryExpr( UnaryExpr(
#line 1970 "cs.ATG" #line 1973 "cs.ATG"
out expr); out expr);
ConditionalAndExpr( ConditionalAndExpr(
#line 1970 "cs.ATG" #line 1973 "cs.ATG"
ref expr); ref expr);
#line 1970 "cs.ATG" #line 1973 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr);
} }
} }
@ -4421,125 +4421,125 @@ out type);
ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters);
if (StartOf(21)) { if (StartOf(21)) {
Argument( Argument(
#line 1902 "cs.ATG" #line 1903 "cs.ATG"
out expr); out expr);
#line 1902 "cs.ATG" #line 1903 "cs.ATG"
parameters.Add(expr); if (expr != null) { parameters.Add(expr); }
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
Argument( Argument(
#line 1903 "cs.ATG" #line 1904 "cs.ATG"
out expr); out expr);
#line 1903 "cs.ATG" #line 1904 "cs.ATG"
parameters.Add(expr); if (expr != null) { parameters.Add(expr); }
} }
} }
Expect(20); Expect(20);
#line 1903 "cs.ATG" #line 1906 "cs.ATG"
pexpr = oce; pexpr = oce;
} else if (la.kind == 17) { } else if (la.kind == 17) {
#line 1905 "cs.ATG" #line 1908 "cs.ATG"
isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace;
lexer.NextToken(); lexer.NextToken();
#line 1906 "cs.ATG" #line 1909 "cs.ATG"
int dims = 0; int dims = 0;
ArrayList rank = new ArrayList(); ArrayList rank = new ArrayList();
ArrayList parameterExpression = new ArrayList(); ArrayList parameterExpression = new ArrayList();
if (StartOf(4)) { if (StartOf(4)) {
Expr( Expr(
#line 1910 "cs.ATG" #line 1913 "cs.ATG"
out expr); out expr);
#line 1910 "cs.ATG" #line 1913 "cs.ATG"
if (expr != null) { parameterExpression.Add(expr); } if (expr != null) { parameterExpression.Add(expr); }
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
Expr( Expr(
#line 1912 "cs.ATG" #line 1915 "cs.ATG"
out expr); out expr);
#line 1912 "cs.ATG" #line 1915 "cs.ATG"
if (expr != null) { parameterExpression.Add(expr); } if (expr != null) { parameterExpression.Add(expr); }
} }
Expect(18); Expect(18);
#line 1914 "cs.ATG" #line 1917 "cs.ATG"
parameters.Add(new ArrayCreationParameter(parameterExpression)); parameters.Add(new ArrayCreationParameter(parameterExpression));
ace.Parameters = parameters; ace.Parameters = parameters;
while ( while (
#line 1917 "cs.ATG" #line 1920 "cs.ATG"
IsDims()) { IsDims()) {
Expect(17); Expect(17);
#line 1917 "cs.ATG" #line 1920 "cs.ATG"
dims =0; dims =0;
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
#line 1918 "cs.ATG" #line 1921 "cs.ATG"
dims++; dims++;
} }
#line 1918 "cs.ATG" #line 1921 "cs.ATG"
rank.Add(dims); rank.Add(dims);
parameters.Add(new ArrayCreationParameter(dims)); parameters.Add(new ArrayCreationParameter(dims));
Expect(18); Expect(18);
} }
#line 1922 "cs.ATG" #line 1925 "cs.ATG"
if (rank.Count > 0) { if (rank.Count > 0) {
ace.Rank = (int[])rank.ToArray(typeof (int)); ace.Rank = (int[])rank.ToArray(typeof (int));
} }
if (la.kind == 15) { if (la.kind == 15) {
ArrayInitializer( ArrayInitializer(
#line 1926 "cs.ATG" #line 1929 "cs.ATG"
out expr); out expr);
#line 1926 "cs.ATG" #line 1929 "cs.ATG"
ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.ArrayInitializer = (ArrayInitializerExpression)expr;
} }
} else if (la.kind == 13 || la.kind == 18) { } else if (la.kind == 13 || la.kind == 18) {
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
#line 1928 "cs.ATG" #line 1931 "cs.ATG"
dims++; dims++;
} }
#line 1929 "cs.ATG" #line 1932 "cs.ATG"
parameters.Add(new ArrayCreationParameter(dims)); parameters.Add(new ArrayCreationParameter(dims));
Expect(18); Expect(18);
while ( while (
#line 1931 "cs.ATG" #line 1934 "cs.ATG"
IsDims()) { IsDims()) {
Expect(17); Expect(17);
#line 1931 "cs.ATG" #line 1934 "cs.ATG"
dims =0; dims =0;
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
#line 1931 "cs.ATG" #line 1934 "cs.ATG"
dims++; dims++;
} }
#line 1931 "cs.ATG" #line 1934 "cs.ATG"
parameters.Add(new ArrayCreationParameter(dims)); parameters.Add(new ArrayCreationParameter(dims));
Expect(18); Expect(18);
} }
ArrayInitializer( ArrayInitializer(
#line 1931 "cs.ATG" #line 1934 "cs.ATG"
out expr); out expr);
#line 1931 "cs.ATG" #line 1934 "cs.ATG"
ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters;
} else SynErr(177); } else SynErr(177);
} else SynErr(178); } else SynErr(178);
@ -4549,20 +4549,20 @@ out expr);
lexer.NextToken(); lexer.NextToken();
Expect(19); Expect(19);
if ( if (
#line 1937 "cs.ATG" #line 1940 "cs.ATG"
NotVoidPointer()) { NotVoidPointer()) {
Expect(121); Expect(121);
#line 1937 "cs.ATG" #line 1940 "cs.ATG"
type = new TypeReference("void"); type = new TypeReference("void");
} else if (StartOf(8)) { } else if (StartOf(8)) {
Type( Type(
#line 1938 "cs.ATG" #line 1941 "cs.ATG"
out type); out type);
} else SynErr(179); } else SynErr(179);
Expect(20); Expect(20);
#line 1939 "cs.ATG" #line 1942 "cs.ATG"
pexpr = new TypeOfExpression(type); pexpr = new TypeOfExpression(type);
break; break;
} }
@ -4570,11 +4570,11 @@ out type);
lexer.NextToken(); lexer.NextToken();
Expect(19); Expect(19);
Type( Type(
#line 1940 "cs.ATG" #line 1943 "cs.ATG"
out type); out type);
Expect(20); Expect(20);
#line 1940 "cs.ATG" #line 1943 "cs.ATG"
pexpr = new SizeOfExpression(type); pexpr = new SizeOfExpression(type);
break; break;
} }
@ -4582,11 +4582,11 @@ out type);
lexer.NextToken(); lexer.NextToken();
Expect(19); Expect(19);
Expr( Expr(
#line 1941 "cs.ATG" #line 1944 "cs.ATG"
out expr); out expr);
Expect(20); Expect(20);
#line 1941 "cs.ATG" #line 1944 "cs.ATG"
pexpr = new CheckedExpression(expr); pexpr = new CheckedExpression(expr);
break; break;
} }
@ -4594,11 +4594,11 @@ out expr);
lexer.NextToken(); lexer.NextToken();
Expect(19); Expect(19);
Expr( Expr(
#line 1942 "cs.ATG" #line 1945 "cs.ATG"
out expr); out expr);
Expect(20); Expect(20);
#line 1942 "cs.ATG" #line 1945 "cs.ATG"
pexpr = new UncheckedExpression(expr); pexpr = new UncheckedExpression(expr);
break; break;
} }
@ -4609,353 +4609,353 @@ out expr);
if (la.kind == 30) { if (la.kind == 30) {
lexer.NextToken(); lexer.NextToken();
#line 1946 "cs.ATG" #line 1949 "cs.ATG"
pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement);
} else if (la.kind == 31) { } else if (la.kind == 31) {
lexer.NextToken(); lexer.NextToken();
#line 1947 "cs.ATG" #line 1950 "cs.ATG"
pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement);
} else SynErr(181); } else SynErr(181);
} else if (la.kind == 46) { } else if (la.kind == 46) {
lexer.NextToken(); lexer.NextToken();
Expect(1); Expect(1);
#line 1950 "cs.ATG" #line 1953 "cs.ATG"
pexpr = new PointerReferenceExpression(pexpr, t.val); pexpr = new PointerReferenceExpression(pexpr, t.val);
} else if (la.kind == 14) { } else if (la.kind == 14) {
lexer.NextToken(); lexer.NextToken();
Expect(1); Expect(1);
#line 1951 "cs.ATG" #line 1954 "cs.ATG"
pexpr = new FieldReferenceExpression(pexpr, t.val); pexpr = new FieldReferenceExpression(pexpr, t.val);
} else if (la.kind == 19) { } else if (la.kind == 19) {
lexer.NextToken(); lexer.NextToken();
#line 1953 "cs.ATG" #line 1956 "cs.ATG"
ArrayList parameters = new ArrayList(); ArrayList parameters = new ArrayList();
if (StartOf(21)) { if (StartOf(21)) {
Argument( Argument(
#line 1954 "cs.ATG" #line 1957 "cs.ATG"
out expr); out expr);
#line 1954 "cs.ATG" #line 1957 "cs.ATG"
parameters.Add(expr); if (expr != null) {parameters.Add(expr);}
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
Argument( Argument(
#line 1955 "cs.ATG" #line 1958 "cs.ATG"
out expr); out expr);
#line 1955 "cs.ATG" #line 1958 "cs.ATG"
parameters.Add(expr); if (expr != null) {parameters.Add(expr);}
} }
} }
Expect(20); Expect(20);
#line 1956 "cs.ATG" #line 1959 "cs.ATG"
pexpr = new InvocationExpression(pexpr, parameters); pexpr = new InvocationExpression(pexpr, parameters);
} else { } else {
#line 1958 "cs.ATG" #line 1961 "cs.ATG"
if (isArrayCreation) Error("element access not allow on array creation"); if (isArrayCreation) Error("element access not allow on array creation");
ArrayList indices = new ArrayList(); ArrayList indices = new ArrayList();
lexer.NextToken(); lexer.NextToken();
Expr( Expr(
#line 1961 "cs.ATG" #line 1964 "cs.ATG"
out expr); out expr);
#line 1961 "cs.ATG" #line 1964 "cs.ATG"
if (expr != null) { indices.Add(expr); } if (expr != null) { indices.Add(expr); }
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
Expr( Expr(
#line 1962 "cs.ATG" #line 1965 "cs.ATG"
out expr); out expr);
#line 1962 "cs.ATG" #line 1965 "cs.ATG"
if (expr != null) { indices.Add(expr); } if (expr != null) { indices.Add(expr); }
} }
Expect(18); Expect(18);
#line 1963 "cs.ATG" #line 1966 "cs.ATG"
pexpr = new IndexerExpression(pexpr, indices); pexpr = new IndexerExpression(pexpr, indices);
} }
} }
} }
void ConditionalAndExpr( void ConditionalAndExpr(
#line 1973 "cs.ATG" #line 1976 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 1974 "cs.ATG" #line 1977 "cs.ATG"
Expression expr; Expression expr;
InclusiveOrExpr( InclusiveOrExpr(
#line 1976 "cs.ATG" #line 1979 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 24) { while (la.kind == 24) {
lexer.NextToken(); lexer.NextToken();
UnaryExpr( UnaryExpr(
#line 1976 "cs.ATG" #line 1979 "cs.ATG"
out expr); out expr);
InclusiveOrExpr( InclusiveOrExpr(
#line 1976 "cs.ATG" #line 1979 "cs.ATG"
ref expr); ref expr);
#line 1976 "cs.ATG" #line 1979 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr);
} }
} }
void InclusiveOrExpr( void InclusiveOrExpr(
#line 1979 "cs.ATG" #line 1982 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 1980 "cs.ATG" #line 1983 "cs.ATG"
Expression expr; Expression expr;
ExclusiveOrExpr( ExclusiveOrExpr(
#line 1982 "cs.ATG" #line 1985 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 28) { while (la.kind == 28) {
lexer.NextToken(); lexer.NextToken();
UnaryExpr( UnaryExpr(
#line 1982 "cs.ATG" #line 1985 "cs.ATG"
out expr); out expr);
ExclusiveOrExpr( ExclusiveOrExpr(
#line 1982 "cs.ATG" #line 1985 "cs.ATG"
ref expr); ref expr);
#line 1982 "cs.ATG" #line 1985 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr);
} }
} }
void ExclusiveOrExpr( void ExclusiveOrExpr(
#line 1985 "cs.ATG" #line 1988 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 1986 "cs.ATG" #line 1989 "cs.ATG"
Expression expr; Expression expr;
AndExpr( AndExpr(
#line 1988 "cs.ATG" #line 1991 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 29) { while (la.kind == 29) {
lexer.NextToken(); lexer.NextToken();
UnaryExpr( UnaryExpr(
#line 1988 "cs.ATG" #line 1991 "cs.ATG"
out expr); out expr);
AndExpr( AndExpr(
#line 1988 "cs.ATG" #line 1991 "cs.ATG"
ref expr); ref expr);
#line 1988 "cs.ATG" #line 1991 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr);
} }
} }
void AndExpr( void AndExpr(
#line 1991 "cs.ATG" #line 1994 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 1992 "cs.ATG" #line 1995 "cs.ATG"
Expression expr; Expression expr;
EqualityExpr( EqualityExpr(
#line 1994 "cs.ATG" #line 1997 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 27) { while (la.kind == 27) {
lexer.NextToken(); lexer.NextToken();
UnaryExpr( UnaryExpr(
#line 1994 "cs.ATG" #line 1997 "cs.ATG"
out expr); out expr);
EqualityExpr( EqualityExpr(
#line 1994 "cs.ATG" #line 1997 "cs.ATG"
ref expr); ref expr);
#line 1994 "cs.ATG" #line 1997 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr);
} }
} }
void EqualityExpr( void EqualityExpr(
#line 1997 "cs.ATG" #line 2000 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 1999 "cs.ATG" #line 2002 "cs.ATG"
Expression expr; Expression expr;
BinaryOperatorType op = BinaryOperatorType.None; BinaryOperatorType op = BinaryOperatorType.None;
RelationalExpr( RelationalExpr(
#line 2003 "cs.ATG" #line 2006 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 32 || la.kind == 33) { while (la.kind == 32 || la.kind == 33) {
if (la.kind == 33) { if (la.kind == 33) {
lexer.NextToken(); lexer.NextToken();
#line 2006 "cs.ATG" #line 2009 "cs.ATG"
op = BinaryOperatorType.InEquality; op = BinaryOperatorType.InEquality;
} else { } else {
lexer.NextToken(); lexer.NextToken();
#line 2007 "cs.ATG" #line 2010 "cs.ATG"
op = BinaryOperatorType.Equality; op = BinaryOperatorType.Equality;
} }
UnaryExpr( UnaryExpr(
#line 2009 "cs.ATG" #line 2012 "cs.ATG"
out expr); out expr);
RelationalExpr( RelationalExpr(
#line 2009 "cs.ATG" #line 2012 "cs.ATG"
ref expr); ref expr);
#line 2009 "cs.ATG" #line 2012 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr); outExpr = new BinaryOperatorExpression(outExpr, op, expr);
} }
} }
void RelationalExpr( void RelationalExpr(
#line 2013 "cs.ATG" #line 2016 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 2015 "cs.ATG" #line 2018 "cs.ATG"
TypeReference type; TypeReference type;
Expression expr; Expression expr;
BinaryOperatorType op = BinaryOperatorType.None; BinaryOperatorType op = BinaryOperatorType.None;
ShiftExpr( ShiftExpr(
#line 2020 "cs.ATG" #line 2023 "cs.ATG"
ref outExpr); ref outExpr);
while (StartOf(26)) { while (StartOf(26)) {
if (StartOf(27)) { if (StartOf(27)) {
if (la.kind == 22) { if (la.kind == 22) {
lexer.NextToken(); lexer.NextToken();
#line 2023 "cs.ATG" #line 2026 "cs.ATG"
op = BinaryOperatorType.LessThan; op = BinaryOperatorType.LessThan;
} else if (la.kind == 21) { } else if (la.kind == 21) {
lexer.NextToken(); lexer.NextToken();
#line 2024 "cs.ATG" #line 2027 "cs.ATG"
op = BinaryOperatorType.GreaterThan; op = BinaryOperatorType.GreaterThan;
} else if (la.kind == 35) { } else if (la.kind == 35) {
lexer.NextToken(); lexer.NextToken();
#line 2025 "cs.ATG" #line 2028 "cs.ATG"
op = BinaryOperatorType.LessThanOrEqual; op = BinaryOperatorType.LessThanOrEqual;
} else if (la.kind == 34) { } else if (la.kind == 34) {
lexer.NextToken(); lexer.NextToken();
#line 2026 "cs.ATG" #line 2029 "cs.ATG"
op = BinaryOperatorType.GreaterThanOrEqual; op = BinaryOperatorType.GreaterThanOrEqual;
} else SynErr(182); } else SynErr(182);
UnaryExpr( UnaryExpr(
#line 2028 "cs.ATG" #line 2031 "cs.ATG"
out expr); out expr);
ShiftExpr( ShiftExpr(
#line 2028 "cs.ATG" #line 2031 "cs.ATG"
ref expr); ref expr);
#line 2028 "cs.ATG" #line 2031 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr); outExpr = new BinaryOperatorExpression(outExpr, op, expr);
} else { } else {
if (la.kind == 83) { if (la.kind == 83) {
lexer.NextToken(); lexer.NextToken();
#line 2031 "cs.ATG" #line 2034 "cs.ATG"
op = BinaryOperatorType.IS; op = BinaryOperatorType.IS;
} else if (la.kind == 48) { } else if (la.kind == 48) {
lexer.NextToken(); lexer.NextToken();
#line 2032 "cs.ATG" #line 2035 "cs.ATG"
op = BinaryOperatorType.AS; op = BinaryOperatorType.AS;
} else SynErr(183); } else SynErr(183);
Type( Type(
#line 2034 "cs.ATG" #line 2037 "cs.ATG"
out type); out type);
#line 2034 "cs.ATG" #line 2037 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type)); outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type));
} }
} }
} }
void ShiftExpr( void ShiftExpr(
#line 2038 "cs.ATG" #line 2041 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 2040 "cs.ATG" #line 2043 "cs.ATG"
Expression expr; Expression expr;
BinaryOperatorType op = BinaryOperatorType.None; BinaryOperatorType op = BinaryOperatorType.None;
AdditiveExpr( AdditiveExpr(
#line 2044 "cs.ATG" #line 2047 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 36 || while (la.kind == 36 ||
#line 2047 "cs.ATG" #line 2050 "cs.ATG"
IsShiftRight()) { IsShiftRight()) {
if (la.kind == 36) { if (la.kind == 36) {
lexer.NextToken(); lexer.NextToken();
#line 2046 "cs.ATG" #line 2049 "cs.ATG"
op = BinaryOperatorType.ShiftLeft; op = BinaryOperatorType.ShiftLeft;
} else { } else {
Expect(21); Expect(21);
Expect(21); Expect(21);
#line 2048 "cs.ATG" #line 2051 "cs.ATG"
op = BinaryOperatorType.ShiftRight; op = BinaryOperatorType.ShiftRight;
} }
UnaryExpr( UnaryExpr(
#line 2051 "cs.ATG" #line 2054 "cs.ATG"
out expr); out expr);
AdditiveExpr( AdditiveExpr(
#line 2051 "cs.ATG" #line 2054 "cs.ATG"
ref expr); ref expr);
#line 2051 "cs.ATG" #line 2054 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr); outExpr = new BinaryOperatorExpression(outExpr, op, expr);
} }
} }
void AdditiveExpr( void AdditiveExpr(
#line 2055 "cs.ATG" #line 2058 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 2057 "cs.ATG" #line 2060 "cs.ATG"
Expression expr; Expression expr;
BinaryOperatorType op = BinaryOperatorType.None; BinaryOperatorType op = BinaryOperatorType.None;
MultiplicativeExpr( MultiplicativeExpr(
#line 2061 "cs.ATG" #line 2064 "cs.ATG"
ref outExpr); ref outExpr);
while (la.kind == 4 || la.kind == 5) { while (la.kind == 4 || la.kind == 5) {
if (la.kind == 4) { if (la.kind == 4) {
lexer.NextToken(); lexer.NextToken();
#line 2064 "cs.ATG" #line 2067 "cs.ATG"
op = BinaryOperatorType.Add; op = BinaryOperatorType.Add;
} else { } else {
lexer.NextToken(); lexer.NextToken();
#line 2065 "cs.ATG" #line 2068 "cs.ATG"
op = BinaryOperatorType.Subtract; op = BinaryOperatorType.Subtract;
} }
UnaryExpr( UnaryExpr(
#line 2067 "cs.ATG" #line 2070 "cs.ATG"
out expr); out expr);
MultiplicativeExpr( MultiplicativeExpr(
#line 2067 "cs.ATG" #line 2070 "cs.ATG"
ref expr); ref expr);
#line 2067 "cs.ATG" #line 2070 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr); outExpr = new BinaryOperatorExpression(outExpr, op, expr);
} }
} }
void MultiplicativeExpr( void MultiplicativeExpr(
#line 2071 "cs.ATG" #line 2074 "cs.ATG"
ref Expression outExpr) { ref Expression outExpr) {
#line 2073 "cs.ATG" #line 2076 "cs.ATG"
Expression expr; Expression expr;
BinaryOperatorType op = BinaryOperatorType.None; BinaryOperatorType op = BinaryOperatorType.None;
@ -4963,84 +4963,84 @@ ref Expression outExpr) {
if (la.kind == 6) { if (la.kind == 6) {
lexer.NextToken(); lexer.NextToken();
#line 2079 "cs.ATG" #line 2082 "cs.ATG"
op = BinaryOperatorType.Multiply; op = BinaryOperatorType.Multiply;
} else if (la.kind == 7) { } else if (la.kind == 7) {
lexer.NextToken(); lexer.NextToken();
#line 2080 "cs.ATG" #line 2083 "cs.ATG"
op = BinaryOperatorType.Divide; op = BinaryOperatorType.Divide;
} else { } else {
lexer.NextToken(); lexer.NextToken();
#line 2081 "cs.ATG" #line 2084 "cs.ATG"
op = BinaryOperatorType.Modulus; op = BinaryOperatorType.Modulus;
} }
UnaryExpr( UnaryExpr(
#line 2083 "cs.ATG" #line 2086 "cs.ATG"
out expr); out expr);
#line 2083 "cs.ATG" #line 2086 "cs.ATG"
outExpr = new BinaryOperatorExpression(outExpr, op, expr); outExpr = new BinaryOperatorExpression(outExpr, op, expr);
} }
} }
void TypeArgumentList( void TypeArgumentList(
#line 2096 "cs.ATG" #line 2099 "cs.ATG"
out List<TypeReference> types) { out List<TypeReference> types) {
#line 2098 "cs.ATG" #line 2101 "cs.ATG"
types = new List<TypeReference>(); types = new List<TypeReference>();
TypeReference type = null; TypeReference type = null;
Expect(22); Expect(22);
Type( Type(
#line 2102 "cs.ATG" #line 2105 "cs.ATG"
out type); out type);
#line 2102 "cs.ATG" #line 2105 "cs.ATG"
types.Add(type); types.Add(type);
while (la.kind == 13) { while (la.kind == 13) {
lexer.NextToken(); lexer.NextToken();
Type( Type(
#line 2103 "cs.ATG" #line 2106 "cs.ATG"
out type); out type);
#line 2103 "cs.ATG" #line 2106 "cs.ATG"
types.Add(type); types.Add(type);
} }
Expect(21); Expect(21);
} }
void TypeParameterConstraintsClauseBase( void TypeParameterConstraintsClauseBase(
#line 2148 "cs.ATG" #line 2151 "cs.ATG"
out TypeReference type) { out TypeReference type) {
#line 2149 "cs.ATG" #line 2152 "cs.ATG"
TypeReference t; type = null; TypeReference t; type = null;
if (la.kind == 107) { if (la.kind == 107) {
lexer.NextToken(); lexer.NextToken();
#line 2151 "cs.ATG" #line 2154 "cs.ATG"
type = new TypeReference("struct"); type = new TypeReference("struct");
} else if (la.kind == 57) { } else if (la.kind == 57) {
lexer.NextToken(); lexer.NextToken();
#line 2152 "cs.ATG" #line 2155 "cs.ATG"
type = new TypeReference("struct"); type = new TypeReference("struct");
} else if (la.kind == 87) { } else if (la.kind == 87) {
lexer.NextToken(); lexer.NextToken();
Expect(19); Expect(19);
Expect(20); Expect(20);
#line 2153 "cs.ATG" #line 2156 "cs.ATG"
type = new TypeReference("struct"); type = new TypeReference("struct");
} else if (StartOf(8)) { } else if (StartOf(8)) {
Type( Type(
#line 2154 "cs.ATG" #line 2157 "cs.ATG"
out t); out t);
#line 2154 "cs.ATG" #line 2157 "cs.ATG"
type = t; type = t;
} else SynErr(184); } else SynErr(184);
} }

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

@ -1899,8 +1899,11 @@ PrimaryExpr<out Expression pexpr>
/* Note: a delegate creation expression allow only a single Expr * /* Note: a delegate creation expression allow only a single Expr *
* not an argument list, but this is not distinguished here */ * not an argument list, but this is not distinguished here */
( (
"(" (. ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); .) [ Argument<out expr> (. parameters.Add(expr); .) "(" (. ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); .)
{ "," Argument<out expr> (. parameters.Add(expr); .) } ] ")" (. pexpr = oce; .) [ Argument<out expr> (. if (expr != null) { parameters.Add(expr); } .)
{ "," Argument<out expr> (. if (expr != null) { parameters.Add(expr); } .) }
]
")" (. pexpr = oce; .)
/*--- array creation expression: */ /*--- array creation expression: */
| (. isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; .) | (. isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; .)
"[" (. int dims = 0; "[" (. int dims = 0;
@ -1951,8 +1954,8 @@ PrimaryExpr<out Expression pexpr>
| "." ident (. pexpr = new FieldReferenceExpression(pexpr, t.val);.) | "." ident (. pexpr = new FieldReferenceExpression(pexpr, t.val);.)
/*--- invocation expression: */ /*--- invocation expression: */
| "(" (. ArrayList parameters = new ArrayList(); .) | "(" (. ArrayList parameters = new ArrayList(); .)
[ Argument<out expr> (. parameters.Add(expr); .) [ Argument<out expr> (. if (expr != null) {parameters.Add(expr);} .)
{ "," Argument<out expr> (. 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");

18
src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs

@ -3,7 +3,7 @@
* User: Omnibrain * User: Omnibrain
* Date: 13.09.2004 * Date: 13.09.2004
* Time: 19:54 * Time: 19:54
* *
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
@ -31,9 +31,25 @@ namespace ICSharpCode.NRefactory.Tests.AST
{ {
CheckSimpleInvoke((InvocationExpression)ParseUtilCSharp.ParseExpression("myMethod()", typeof(InvocationExpression))); CheckSimpleInvoke((InvocationExpression)ParseUtilCSharp.ParseExpression("myMethod()", typeof(InvocationExpression)));
} }
[Test]
public void CSharpInvalidNestedInvocationExpressionTest()
{
// this test was written because this bug caused the AbstractASTVisitor to crash
InvocationExpression expr = (InvocationExpression)ParseUtilCSharp.ParseExpression("WriteLine(myMethod(,))", typeof(InvocationExpression), true);
Assert.IsTrue(expr.TargetObject is IdentifierExpression);
Assert.AreEqual("WriteLine", ((IdentifierExpression)expr.TargetObject).Identifier);
Assert.AreEqual(1, expr.Parameters.Count); // here a second null parameter was added incorrectly
Assert.IsTrue(expr.Parameters[0] is InvocationExpression);
CheckSimpleInvoke((InvocationExpression)expr.Parameters[0]);
}
#endregion #endregion
#region VB.NET #region VB.NET
[Test]
public void VBNetSimpleInvocationExpressionTest() public void VBNetSimpleInvocationExpressionTest()
{ {
CheckSimpleInvoke((InvocationExpression)ParseUtilVBNet.ParseExpression("myMethod()", typeof(InvocationExpression))); CheckSimpleInvoke((InvocationExpression)ParseUtilVBNet.ParseExpression("myMethod()", typeof(InvocationExpression)));

15
src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs

@ -34,6 +34,21 @@ namespace ICSharpCode.NRefactory.Tests.AST
{ {
CheckSimpleObjectCreateExpression((ObjectCreateExpression)ParseUtilCSharp.ParseExpression("new MyObject(1, 2, 3)", typeof(ObjectCreateExpression))); CheckSimpleObjectCreateExpression((ObjectCreateExpression)ParseUtilCSharp.ParseExpression("new MyObject(1, 2, 3)", typeof(ObjectCreateExpression)));
} }
[Test]
public void CSharpInvalidNestedObjectCreateExpressionTest()
{
// this test was written because this bug caused the AbstractASTVisitor to crash
InvocationExpression expr = (InvocationExpression)ParseUtilCSharp.ParseExpression("WriteLine(new MyObject(1, 2, 3,))", typeof(InvocationExpression), true);
Assert.IsTrue(expr.TargetObject is IdentifierExpression);
Assert.AreEqual("WriteLine", ((IdentifierExpression)expr.TargetObject).Identifier);
Assert.AreEqual(1, expr.Parameters.Count); // here a second null parameter was added incorrectly
Assert.IsTrue(expr.Parameters[0] is ObjectCreateExpression);
CheckSimpleObjectCreateExpression((ObjectCreateExpression)expr.Parameters[0]);
}
#endregion #endregion
#region VB.NET #region VB.NET

13
src/Libraries/NRefactory/Test/Parser/ParseUtilCSharp.cs

@ -3,7 +3,7 @@
* User: Omnibrain * User: Omnibrain
* Date: 18.09.2004 * Date: 18.09.2004
* Time: 06:36 * Time: 06:36
* *
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
@ -51,13 +51,20 @@ namespace ICSharpCode.NRefactory.Tests.AST
} }
public static object ParseExpression(string expr, Type type) public static object ParseExpression(string expr, Type type)
{
return ParseExpression(expr, type, false);
}
public static object ParseExpression(string expr, Type type, bool expectErrors)
{ {
IParser parser = ParserFactory.CreateParser(SupportedLanguages.CSharp, new StringReader(expr + ";")); IParser parser = ParserFactory.CreateParser(SupportedLanguages.CSharp, new StringReader(expr + ";"));
object parsedExpression = parser.ParseExpression(); object parsedExpression = parser.ParseExpression();
Assert.AreEqual("", parser.Errors.ErrorOutput); if (expectErrors)
Assert.IsTrue(parser.Errors.ErrorOutput.Length > 0, "There were errors expected, but parser finished without errors.");
else
Assert.AreEqual("", parser.Errors.ErrorOutput);
Assert.IsTrue(type.IsAssignableFrom(parsedExpression.GetType()), String.Format("Parsed expression was {0} instead of {1} ({2})", parsedExpression.GetType(), type, parsedExpression)); Assert.IsTrue(type.IsAssignableFrom(parsedExpression.GetType()), String.Format("Parsed expression was {0} instead of {1} ({2})", parsedExpression.GetType(), type, parsedExpression));
return parsedExpression; return parsedExpression;
} }
} }
} }

6
src/Main/Base/Project/Src/Commands/AutostartCommands.cs

@ -114,8 +114,6 @@ namespace ICSharpCode.SharpDevelop.Commands
public override void Run() public override void Run()
{ {
ParserService.StartParserThread();
Form f = (Form)WorkbenchSingleton.Workbench; Form f = (Form)WorkbenchSingleton.Workbench;
f.Show(); f.Show();
@ -156,10 +154,14 @@ namespace ICSharpCode.SharpDevelop.Commands
f.Focus(); // windows.forms focus workaround f.Focus(); // windows.forms focus workaround
ParserService.StartParserThread();
// finally run the workbench window ... // finally run the workbench window ...
Application.AddMessageFilter(new FormKeyHandler()); Application.AddMessageFilter(new FormKeyHandler());
Application.Run(f); Application.Run(f);
ParserService.StopParserThread();
// save the workbench memento in the ide properties // save the workbench memento in the ide properties
try { try {
PropertyService.Set(workbenchMemento, WorkbenchSingleton.Workbench.CreateMemento()); PropertyService.Set(workbenchMemento, WorkbenchSingleton.Workbench.CreateMemento());

27
src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs

@ -46,6 +46,7 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
{ {
htmlViewPane = new HtmlViewPane(showNavigation); htmlViewPane = new HtmlViewPane(showNavigation);
htmlViewPane.WebBrowser.DocumentTitleChanged += new EventHandler(TitleChange); htmlViewPane.WebBrowser.DocumentTitleChanged += new EventHandler(TitleChange);
htmlViewPane.Closed += PaneClosed;
} }
public BrowserPane(Uri uri) : this(true) public BrowserPane(Uri uri) : this(true)
@ -60,6 +61,7 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
public override void Dispose() public override void Dispose()
{ {
htmlViewPane.Dispose(); htmlViewPane.Dispose();
base.Dispose();
} }
public override void Load(string url) public override void Load(string url)
@ -72,13 +74,18 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
Load(url); Load(url);
} }
void PaneClosed(object sender, EventArgs e)
{
WorkbenchWindow.CloseWindow(true);
}
void TitleChange(object sender, EventArgs e) void TitleChange(object sender, EventArgs e)
{ {
string title = htmlViewPane.WebBrowser.DocumentTitle; string title = htmlViewPane.WebBrowser.DocumentTitle;
if (title == null || title.Length == 0) if (title == null || title.Length == 0)
TitleName = "Browser"; TitleName = "Browser";
else else
TitleName = title; TitleName = title;
} }
} }
@ -98,6 +105,18 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
} }
} }
public event EventHandler Closed;
/// <summary>
/// Closes the ViewContent that contains this HtmlViewPane.
/// </summary>
public void Close()
{
if (Closed != null) {
Closed(this, EventArgs.Empty);
}
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);

4
src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs

@ -156,7 +156,9 @@ namespace ICSharpCode.SharpDevelop.Gui
void SetWorkDone() void SetWorkDone()
{ {
statusProgressBar.Value = workDone; if (workDone < totalWork) {
statusProgressBar.Value = workDone;
}
} }
public void Done() public void Done()

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

@ -155,6 +155,12 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
public static bool InvokeRequired {
get {
return ((Form)workbench).InvokeRequired;
}
}
/// <summary> /// <summary>
/// Makes a call GUI threadsafe. WARNING: This method waits for the result of the /// Makes a call GUI threadsafe. WARNING: This method waits for the result of the
/// operation, which can result in a dead-lock when the main thread waits for this /// operation, which can result in a dead-lock when the main thread waits for this

43
src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs

@ -151,6 +151,7 @@ namespace ICSharpCode.Core
newProjectContent.project = project; newProjectContent.project = project;
newProjectContent.language = project.LanguageProperties; newProjectContent.language = project.LanguageProperties;
newProjectContent.referencedContents.Add(ProjectContentRegistry.GetMscorlibContent()); newProjectContent.referencedContents.Add(ProjectContentRegistry.GetMscorlibContent());
newProjectContent.initializing = true;
return newProjectContent; return newProjectContent;
} }
@ -165,27 +166,46 @@ namespace ICSharpCode.Core
} }
IProject project; IProject project;
// project is only used for initialization, the field is set to null after bool initializing;
// initialization has completed.
internal void Initialize1() internal void Initialize1()
{ {
foreach (ProjectItem item in project.Items.ToArray()) { ProjectItem[] items = project.Items.ToArray();
if (project == null) return; // abort initialization ProjectService.ReferenceAdded += OnReferenceAdded;
foreach (ProjectItem item in items) {
if (!initializing) return; // abort initialization
switch (item.ItemType) { switch (item.ItemType) {
case ItemType.Reference: case ItemType.Reference:
case ItemType.ProjectReference: case ItemType.ProjectReference:
IProjectContent referencedContent = ProjectContentRegistry.GetProjectContentForReference(item as ReferenceProjectItem); AddReference(item as ReferenceProjectItem);
if (referencedContent != null) {
referencedContents.Add(referencedContent);
}
break; break;
} }
} }
} }
delegate void AddReferenceDelegate(ReferenceProjectItem reference);
void AddReference(ReferenceProjectItem reference)
{
try {
IProjectContent referencedContent = ProjectContentRegistry.GetProjectContentForReference(reference);
if (referencedContent != null) {
referencedContents.Add(referencedContent);
}
} catch (Exception e) {
MessageService.ShowError(e);
}
}
void OnReferenceAdded(object sender, ProjectReferenceEventArgs e)
{
if (e.Project != project) return;
new AddReferenceDelegate(AddReference).BeginInvoke(e.ReferenceProjectItem, null, null);
}
internal void Initialize2() internal void Initialize2()
{ {
if (!initializing) return;
ProjectItem[] arr = project.Items.ToArray(); ProjectItem[] arr = project.Items.ToArray();
try { try {
StatusBarService.ProgressMonitor.BeginTask("Parsing " + project.Name + "...", arr.Length); StatusBarService.ProgressMonitor.BeginTask("Parsing " + project.Name + "...", arr.Length);
@ -199,17 +219,18 @@ namespace ICSharpCode.Core
UpdateCompilationUnit(null, parseInfo.BestCompilationUnit as ICompilationUnit, item.FileName, true); UpdateCompilationUnit(null, parseInfo.BestCompilationUnit as ICompilationUnit, item.FileName, true);
} }
} }
if (project == null) return; if (!initializing) return;
} }
} finally { } finally {
StatusBarService.ProgressMonitor.Done(); StatusBarService.ProgressMonitor.Done();
project = null; initializing = false;
} }
} }
public void Dispose() public void Dispose()
{ {
project = null; ProjectService.ReferenceAdded -= OnReferenceAdded;
initializing = false;
} }
public Hashtable AddClassToNamespaceList(IClass addClass) public Hashtable AddClassToNamespaceList(IClass addClass)

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

@ -84,8 +84,11 @@ namespace ICSharpCode.Core
static void OpenCombine(object sender, SolutionEventArgs e) static void OpenCombine(object sender, SolutionEventArgs e)
{ {
if (loadSolutionProjectsThread != null) if (loadSolutionProjectsThread != null) {
if (!abortLoadSolutionProjectsThread)
throw new InvalidOperationException("Cannot open new combine without closing old combine!");
loadSolutionProjectsThread.Join(); loadSolutionProjectsThread.Join();
}
loadSolutionProjectsThread = new Thread(new ThreadStart(LoadSolutionProjects)); loadSolutionProjectsThread = new Thread(new ThreadStart(LoadSolutionProjects));
loadSolutionProjectsThread.Priority = ThreadPriority.Lowest; loadSolutionProjectsThread.Priority = ThreadPriority.Lowest;
loadSolutionProjectsThread.IsBackground = true; loadSolutionProjectsThread.IsBackground = true;
@ -149,12 +152,20 @@ namespace ICSharpCode.Core
public static void StartParserThread() public static void StartParserThread()
{ {
abortParserUpdateThread = false;
Thread parserThread = new Thread(new ThreadStart(ParserUpdateThread)); Thread parserThread = new Thread(new ThreadStart(ParserUpdateThread));
parserThread.Priority = ThreadPriority.Lowest; parserThread.Priority = ThreadPriority.Lowest;
parserThread.IsBackground = true; parserThread.IsBackground = true;
parserThread.Start(); parserThread.Start();
} }
public static void StopParserThread()
{
abortParserUpdateThread = true;
}
static bool abortParserUpdateThread = false;
static Dictionary<string, int> lastUpdateSize = new Dictionary<string, int>(); static Dictionary<string, int> lastUpdateSize = new Dictionary<string, int>();
static void ParserUpdateThread() static void ParserUpdateThread()
@ -162,7 +173,7 @@ namespace ICSharpCode.Core
// preload mscorlib, we're going to need it anyway // preload mscorlib, we're going to need it anyway
ProjectContentRegistry.GetMscorlibContent(); ProjectContentRegistry.GetMscorlibContent();
while (true) { while (!abortParserUpdateThread) {
try { try {
ParserUpdateStep(); ParserUpdateStep();
} catch (Exception e) { } catch (Exception e) {

7
src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs

@ -59,7 +59,12 @@ namespace ICSharpCode.Core
return contents[item.Include]; return contents[item.Include];
} }
StatusBarService.ProgressMonitor.BeginTask("Loading " + item.Include + "...", 100); string shortName = item.Include;
int pos = shortName.IndexOf(',');
if (pos > 0)
shortName = shortName.Substring(0, pos);
StatusBarService.ProgressMonitor.BeginTask("Loading " + shortName + "...", 100);
#if DEBUG #if DEBUG
int time = Environment.TickCount; int time = Environment.TickCount;
#endif #endif

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

@ -91,7 +91,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
// KSL Start, New lines // KSL Start, New lines
FileSystemWatcher watcher; FileSystemWatcher watcher;
bool wasChangedExternally = false; bool wasChangedExternally = false;
// KSL End // KSL End
public bool EnableUndo { public bool EnableUndo {
get { get {
@ -107,9 +107,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
// ParserUpdateThread uses the text property via IEditable, I had an exception // ParserUpdateThread uses the text property via IEditable, I had an exception
// because multiple threads were accessing the GapBufferStrategy at the same time. // because multiple threads were accessing the GapBufferStrategy at the same time.
private delegate string GetTextDelegate();
private delegate void SetTextDelegate(string value);
string GetText() string GetText()
{ {
return textAreaControl.Document.TextContent; return textAreaControl.Document.TextContent;
@ -122,10 +119,16 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public string Text { public string Text {
get { get {
return (string)WorkbenchSingleton.SafeThreadCall(this, "GetText", null); if (WorkbenchSingleton.InvokeRequired)
return (string)WorkbenchSingleton.SafeThreadCall(this, "GetText", null);
else
return GetText();
} }
set { set {
WorkbenchSingleton.SafeThreadCall(this, "SetText", value); if (WorkbenchSingleton.InvokeRequired)
WorkbenchSingleton.SafeThreadCall(this, "SetText", value);
else
SetText(value);
} }
} }
@ -189,7 +192,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
// KSL Start, New lines // KSL Start, New lines
// textAreaControl.FileNameChanged += new EventHandler(FileNameChangedEvent); // textAreaControl.FileNameChanged += new EventHandler(FileNameChangedEvent);
((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Activated += new EventHandler(GotFocusEvent); ((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Activated += new EventHandler(GotFocusEvent);
// KSL End // KSL End
} }
@ -233,32 +236,34 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
void GotFocusEvent(object sender, EventArgs e) void GotFocusEvent(object sender, EventArgs e)
{ {
lock (this) { if (wasChangedExternally) {
if (wasChangedExternally) { wasChangedExternally = false;
wasChangedExternally = false;
string message = StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.TextEditorDisplayBinding.FileAlteredMessage}", new string[,] {{"File", Path.GetFullPath(textAreaControl.FileName)}});
string message = StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.TextEditorDisplayBinding.FileAlteredMessage}", new string[,] {{"File", Path.GetFullPath(textAreaControl.FileName)}}); if (MessageBox.Show(message,
if (MessageBox.Show(message, StringParser.Parse("${res:MainWindow.DialogName}"),
StringParser.Parse("${res:MainWindow.DialogName}"), MessageBoxButtons.YesNo,
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
MessageBoxIcon.Question) == DialogResult.Yes) { Load(textAreaControl.FileName);
Load(textAreaControl.FileName); } else {
} else { IsDirty = true;
IsDirty = true;
}
} }
} }
} }
void OnFileChangedEvent(object sender, FileSystemEventArgs e) void OnFileChangedEvent(object sender, FileSystemEventArgs e)
{ {
lock (this) { if(e.ChangeType != WatcherChangeTypes.Deleted) {
if(e.ChangeType != WatcherChangeTypes.Deleted) { wasChangedExternally = true;
wasChangedExternally = true; if (textAreaControl.IsHandleCreated)
if (((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Focused) { textAreaControl.BeginInvoke(new MethodInvoker(OnFileChangedEventInvoked));
GotFocusEvent(this, EventArgs.Empty); }
} }
}
void OnFileChangedEventInvoked()
{
if (((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Focused) {
GotFocusEvent(this, EventArgs.Empty);
} }
} }
@ -278,6 +283,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public override void Dispose() public override void Dispose()
{ {
((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Activated -= new EventHandler(GotFocusEvent); ((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Activated -= new EventHandler(GotFocusEvent);
if (this.watcher != null) {
this.watcher.Dispose();
}
textAreaControl.Dispose(); textAreaControl.Dispose();
} }
@ -349,7 +357,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
// int lineNr = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.Document.Caret.Offset); // int lineNr = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.Document.Caret.Offset);
// LineSegment lineSegment = textAreaControl.Document.GetLineSegment(lineNr); // LineSegment lineSegment = textAreaControl.Document.GetLineSegment(lineNr);
// textAreaControl.Document.Caret.Offset = Math.Min(lineSegment.Offset + lineSegment.Length, textAreaControl.Document.Caret.Offset); // textAreaControl.Document.Caret.Offset = Math.Min(lineSegment.Offset + lineSegment.Length, textAreaControl.Document.Caret.Offset);
// //
// textAreaControl.OptionsChanged(); // textAreaControl.OptionsChanged();
// textAreaControl.Refresh(); // textAreaControl.Refresh();
} }

Loading…
Cancel
Save