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

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

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

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

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* User: Omnibrain
* Date: 13.09.2004
* Time: 19:54
*
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
@ -31,9 +31,25 @@ namespace ICSharpCode.NRefactory.Tests.AST @@ -31,9 +31,25 @@ namespace ICSharpCode.NRefactory.Tests.AST
{
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
#region VB.NET
[Test]
public void VBNetSimpleInvocationExpressionTest()
{
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 @@ -34,6 +34,21 @@ namespace ICSharpCode.NRefactory.Tests.AST
{
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
#region VB.NET

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

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* User: Omnibrain
* Date: 18.09.2004
* Time: 06:36
*
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
@ -51,13 +51,20 @@ namespace ICSharpCode.NRefactory.Tests.AST @@ -51,13 +51,20 @@ namespace ICSharpCode.NRefactory.Tests.AST
}
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 + ";"));
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));
return parsedExpression;
}
}
}

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

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

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

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

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

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

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

@ -155,6 +155,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -155,6 +155,12 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
public static bool InvokeRequired {
get {
return ((Form)workbench).InvokeRequired;
}
}
/// <summary>
/// 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

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

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

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

@ -84,8 +84,11 @@ namespace ICSharpCode.Core @@ -84,8 +84,11 @@ namespace ICSharpCode.Core
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 = new Thread(new ThreadStart(LoadSolutionProjects));
loadSolutionProjectsThread.Priority = ThreadPriority.Lowest;
loadSolutionProjectsThread.IsBackground = true;
@ -149,12 +152,20 @@ namespace ICSharpCode.Core @@ -149,12 +152,20 @@ namespace ICSharpCode.Core
public static void StartParserThread()
{
abortParserUpdateThread = false;
Thread parserThread = new Thread(new ThreadStart(ParserUpdateThread));
parserThread.Priority = ThreadPriority.Lowest;
parserThread.IsBackground = true;
parserThread.Start();
}
public static void StopParserThread()
{
abortParserUpdateThread = true;
}
static bool abortParserUpdateThread = false;
static Dictionary<string, int> lastUpdateSize = new Dictionary<string, int>();
static void ParserUpdateThread()
@ -162,7 +173,7 @@ namespace ICSharpCode.Core @@ -162,7 +173,7 @@ namespace ICSharpCode.Core
// preload mscorlib, we're going to need it anyway
ProjectContentRegistry.GetMscorlibContent();
while (true) {
while (!abortParserUpdateThread) {
try {
ParserUpdateStep();
} catch (Exception e) {

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

@ -59,7 +59,12 @@ namespace ICSharpCode.Core @@ -59,7 +59,12 @@ namespace ICSharpCode.Core
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
int time = Environment.TickCount;
#endif

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

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

Loading…
Cancel
Save