Browse Source

Added support for code completion on partial classes.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@215 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
107881ee32
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAmbience.cs
  2. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetAmbience.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  4. 7
      src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs
  5. 154
      src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs
  6. 15
      src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs
  7. 13
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputFormatter.cs
  8. 148
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  9. 26
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/Enums.cs
  10. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  11. 6
      src/Main/Base/Project/Src/Dom/IDecoration.cs
  12. 16
      src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs
  13. 122
      src/Main/Base/Project/Src/Dom/Implementations/CompoundClass.cs
  14. 12
      src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs
  15. 12
      src/Main/Base/Project/Src/Dom/ModifierEnum.cs
  16. 41
      src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAmbience.cs

@ -96,7 +96,7 @@ namespace ICSharpCode.Core @@ -96,7 +96,7 @@ namespace ICSharpCode.Core
if (decoration.IsStatic) {
ret += "static ";
} else if (decoration.IsFinal) {
} else if (decoration.IsSealed) {
ret += "final ";
} else if (decoration.IsVirtual) {
ret += "virtual ";

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetAmbience.cs

@ -63,7 +63,7 @@ namespace VBNetBinding @@ -63,7 +63,7 @@ namespace VBNetBinding
}
if (decoration.IsAbstract) {
builder.Append("MustOverride ");
} else if (decoration.IsFinal) {
} else if (decoration.IsSealed) {
builder.Append("NotOverridable ");
} else if (decoration.IsVirtual) {
builder.Append("Overridable ");

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -256,7 +256,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -256,7 +256,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
public string GetValueAsString(string variableName)
{
if (!debugger.IsDebugging || debugger.IsProcessRunning) return null;
if (debugger == null || !debugger.IsDebugging || debugger.IsProcessRunning) return null;
VariableCollection collection = debugger.LocalVariables;
if (collection == null)
return null;

7
src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs

@ -140,14 +140,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -140,14 +140,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public abstract void PrintToken(int token);
protected void PrintToken(string text)
public void PrintText(string text)
{
this.text.Append(text);
}
public void PrintIdentifier(string identifier)
{
text.Append(identifier);
}
public abstract void PrintIdentifier(string identifier);
}
}

154
src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
using System;
using System.Text;
using System.Collections;
using System.Globalization;
using System.Diagnostics;
using ICSharpCode.NRefactory.Parser;
@ -125,14 +126,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -125,14 +126,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(TypeReference typeReference, object data)
{
if (typeReference.Type == null || typeReference.Type.Length ==0) {
outputFormatter.PrintIdentifier("void");
outputFormatter.PrintText("void");
} else {
if (typeReference.SystemType.Length > 0) {
outputFormatter.PrintIdentifier(ConvertTypeString(typeReference.SystemType));
outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType));
} else {
outputFormatter.PrintIdentifier(typeReference.Type);
outputFormatter.PrintText(typeReference.Type);
}
}
if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
outputFormatter.PrintToken(Tokens.LessThan);
AppendCommaSeparatedList(typeReference.GenericTypes);
outputFormatter.PrintToken(Tokens.GreaterThan);
}
for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
outputFormatter.PrintToken(Tokens.Times);
}
@ -183,7 +189,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -183,7 +189,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
if (attributeSection.AttributeTarget != null && attributeSection.AttributeTarget != String.Empty) {
outputFormatter.PrintIdentifier(attributeSection.AttributeTarget);
outputFormatter.PrintText(attributeSection.AttributeTarget);
outputFormatter.PrintToken(Tokens.Colon);
outputFormatter.Space();
}
@ -318,15 +324,27 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -318,15 +324,27 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
outputFormatter.Space();
outputFormatter.PrintIdentifier(typeDeclaration.Name);
if (typeDeclaration.Templates != null && typeDeclaration.Templates.Count > 0) {
outputFormatter.PrintToken(Tokens.LessThan);
for (int i = 0; i < typeDeclaration.Templates.Count; i++) {
if (i > 0) {
PrintFormattedComma();
}
outputFormatter.PrintIdentifier(typeDeclaration.Templates[i].Name);
}
outputFormatter.PrintToken(Tokens.GreaterThan);
}
if (typeDeclaration.BaseTypes != null && typeDeclaration.BaseTypes.Count > 0) {
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Colon);
outputFormatter.Space();
for (int i = 0; i < typeDeclaration.BaseTypes.Count; ++i) {
outputFormatter.Space();
outputFormatter.PrintIdentifier((string)typeDeclaration.BaseTypes[i]);
if (i + 1 < typeDeclaration.BaseTypes.Count) {
if (i > 0) {
PrintFormattedComma();
}
outputFormatter.PrintIdentifier((string)typeDeclaration.BaseTypes[i]);
}
}
@ -364,15 +382,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -364,15 +382,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(TemplateDefinition templateDefinition, object data)
{
if (templateDefinition.Bases.Count == 0)
return null;
outputFormatter.Space();
outputFormatter.PrintIdentifier("where");
outputFormatter.PrintText("where");
outputFormatter.Space();
outputFormatter.PrintIdentifier(templateDefinition.Name);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Colon);
outputFormatter.Space();
for (int i = 0; i < templateDefinition.Bases.Count; ++i) {
outputFormatter.Space();
nodeTracker.TrackedVisit(templateDefinition.Bases[i], data);
if (i + 1 < templateDefinition.Bases.Count) {
PrintFormattedComma();
@ -460,7 +481,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -460,7 +481,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
this.VisitAttributes(propertyGetRegion.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier("get");
outputFormatter.PrintText("get");
OutputBlock(propertyGetRegion.Block, prettyPrintOptions.PropertyGetBraceStyle);
return null;
}
@ -469,7 +490,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -469,7 +490,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
this.VisitAttributes(propertySetRegion.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier("set");
outputFormatter.PrintText("set");
OutputBlock(propertySetRegion.Block, prettyPrintOptions.PropertySetBraceStyle);
return null;
}
@ -507,7 +528,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -507,7 +528,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
VisitAttributes(eventAddRegion.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier("add");
outputFormatter.PrintText("add");
OutputBlock(eventAddRegion.Block, prettyPrintOptions.EventAddBraceStyle);
return null;
}
@ -516,7 +537,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -516,7 +537,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
VisitAttributes(eventRemoveRegion.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier("remove");
outputFormatter.PrintText("remove");
OutputBlock(eventRemoveRegion.Block, prettyPrintOptions.EventRemoveBraceStyle);
return null;
}
@ -701,24 +722,24 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -701,24 +722,24 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
VisitAttributes(declareDeclaration.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier(String.Format("[System.Runtime.InteropServices.DllImport({0}", declareDeclaration.Library));
outputFormatter.PrintText(String.Format("[System.Runtime.InteropServices.DllImport({0}", declareDeclaration.Library));
if (declareDeclaration.Alias != null && declareDeclaration.Alias.Length >0) {
outputFormatter.PrintIdentifier(String.Format(", EntryPoint={0}", declareDeclaration.Alias));
outputFormatter.PrintText(String.Format(", EntryPoint={0}", declareDeclaration.Alias));
}
switch (declareDeclaration.Charset) {
case CharsetModifier.ANSI:
outputFormatter.PrintIdentifier(", CharSet=System.Runtime.InteropServices.CharSet.Ansi");
outputFormatter.PrintText(", CharSet=System.Runtime.InteropServices.CharSet.Ansi");
break;
case CharsetModifier.Unicode:
outputFormatter.PrintIdentifier(", CharSet=System.Runtime.InteropServices.CharSet.Unicode");
outputFormatter.PrintText(", CharSet=System.Runtime.InteropServices.CharSet.Unicode");
break;
case CharsetModifier.Auto:
outputFormatter.PrintIdentifier(", CharSet=System.Runtime.InteropServices.CharSet.Auto");
outputFormatter.PrintText(", CharSet=System.Runtime.InteropServices.CharSet.Auto");
break;
}
outputFormatter.PrintIdentifier(")]");
outputFormatter.PrintText(")]");
outputFormatter.NewLine();
outputFormatter.Indent();
@ -896,7 +917,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -896,7 +917,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
Debug.Assert(yieldStatement != null);
Debug.Assert(yieldStatement.Statement != null);
outputFormatter.PrintIdentifier("yield");
outputFormatter.PrintText("yield");
outputFormatter.Space();
nodeTracker.TrackedVisit(yieldStatement.Statement, data);
return null;
@ -1117,7 +1138,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1117,7 +1138,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(StopStatement stopStatement, object data)
{
outputFormatter.PrintIdentifier("System.Diagnostics.Debugger.Break()");
outputFormatter.PrintText("System.Diagnostics.Debugger.Break()");
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
}
@ -1130,7 +1151,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1130,7 +1151,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(EndStatement endStatement, object data)
{
outputFormatter.PrintIdentifier("System.Environment.Exit(0)");
outputFormatter.PrintText("System.Environment.Exit(0)");
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
}
@ -1422,7 +1443,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1422,7 +1443,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
outputFormatter.PrintToken(Tokens.Break);
outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.PrintIdentifier("// might not be correct. Was : Exit " + exitStatement.ExitType);
outputFormatter.PrintText("// might not be correct. Was : Exit " + exitStatement.ExitType);
outputFormatter.NewLine();
return null;
}
@ -1444,9 +1465,90 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1444,9 +1465,90 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null;
}
string ConvertCharLiteral(char ch)
{
if (ch == '\'') return "\\'";
return ConvertChar(ch);
}
string ConvertChar(char ch)
{
switch (ch) {
case '\\':
return "\\\\";
case '\0':
return "\\0";
case '\a':
return "\\a";
case '\b':
return "\\b";
case '\f':
return "\\f";
case '\n':
return "\\n";
case '\r':
return "\\r";
case '\t':
return "\\t";
case '\v':
return "\\v";
default:
if (char.IsControl(ch)) {
return "\\u" + (int)ch;
} else {
return ch.ToString();
}
}
}
string ConvertString(string str)
{
StringBuilder sb = new StringBuilder();
foreach (char ch in str) {
if (ch == '"')
sb.Append("\\\"");
else
sb.Append(ConvertChar(ch));
}
return sb.ToString();
}
public object Visit(PrimitiveExpression primitiveExpression, object data)
{
outputFormatter.PrintIdentifier(primitiveExpression.StringValue);
if (primitiveExpression.Value == null) {
outputFormatter.PrintToken(Tokens.Null);
return null;
}
if (primitiveExpression.Value is bool) {
if ((bool)primitiveExpression.Value) {
outputFormatter.PrintToken(Tokens.True);
} else {
outputFormatter.PrintToken(Tokens.False);
}
return null;
}
if (primitiveExpression.Value is string) {
outputFormatter.PrintText('"' + ConvertString(primitiveExpression.Value.ToString()) + '"');
return null;
}
if (primitiveExpression.Value is char) {
outputFormatter.PrintText("'" + ConvertCharLiteral((char)primitiveExpression.Value) + "'");
return null;
}
if (primitiveExpression.Value is decimal) {
outputFormatter.PrintText(((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "m");
return null;
}
if (primitiveExpression.Value is float) {
outputFormatter.PrintText(((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "f");
return null;
}
outputFormatter.PrintIdentifier(primitiveExpression.Value.ToString());
return null;
}
@ -1470,7 +1572,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1470,7 +1572,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (binaryOperatorExpression.Op == BinaryOperatorType.ReferenceInequality)
outputFormatter.PrintToken(Tokens.Not);
outputFormatter.PrintIdentifier("object.ReferenceEquals");
outputFormatter.PrintText("object.ReferenceEquals");
if (prettyPrintOptions.BeforeMethodCallParentheses) {
outputFormatter.Space();
}
@ -1974,7 +2076,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1974,7 +2076,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
public object Visit(GlobalReferenceExpression globalReferenceExpression, object data) {
outputFormatter.PrintIdentifier("global::");
outputFormatter.PrintText("global::");
return null;
}

15
src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (token == Tokens.Semicolon && !EmitSemicolon) {
return;
}
PrintToken(Tokens.GetTokenString(token));
PrintText(Tokens.GetTokenString(token));
}
Stack braceStack = new Stack();
@ -118,13 +118,20 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -118,13 +118,20 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
}
public override void PrintIdentifier(string identifier)
{
if (Keywords.GetToken(identifier) >= 0)
PrintText("@");
PrintText(identifier);
}
public override void PrintComment(Comment comment)
{
switch (comment.CommentType) {
case CommentType.Block:
PrintToken("/*");
PrintToken(comment.CommentText);
PrintToken("*/");
PrintText("/*");
PrintText(comment.CommentText);
PrintText("*/");
break;
case CommentType.Documentation:
WriteInPreviousLine("///" + comment.CommentText);

13
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputFormatter.cs

@ -29,7 +29,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -29,7 +29,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override void PrintToken(int token)
{
PrintToken(Tokens.GetTokenString(token));
PrintText(Tokens.GetTokenString(token));
}
public override void PrintIdentifier(string identifier)
{
if (Keywords.GetToken(identifier) < 0) {
PrintText(identifier);
} else {
PrintText("[");
PrintText(identifier);
PrintText("]");
}
}
public override void PrintComment(Comment comment)

148
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs

@ -3,6 +3,7 @@ using System.Text; @@ -3,6 +3,7 @@ using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
@ -118,14 +119,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -118,14 +119,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(TypeReference typeReference, object data)
{
if (typeReference.Type == null || typeReference.Type.Length ==0) {
outputFormatter.PrintIdentifier("Void");
outputFormatter.PrintText("Void");
} else {
if (typeReference.SystemType.Length > 0) {
outputFormatter.PrintIdentifier(ConvertTypeString(typeReference.SystemType));
outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType));
} else {
outputFormatter.PrintIdentifier(typeReference.Type);
}
}
if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
outputFormatter.PrintToken(Tokens.Of);
outputFormatter.Space();
AppendCommaSeparatedList(typeReference.GenericTypes);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
outputFormatter.PrintToken(Tokens.Times);
}
@ -145,7 +153,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -145,7 +153,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(AttributeSection attributeSection, object data)
{
outputFormatter.Indent();
outputFormatter.PrintIdentifier("<");
outputFormatter.PrintText("<");
if (attributeSection.AttributeTarget != null && attributeSection.AttributeTarget != String.Empty) {
outputFormatter.PrintIdentifier(attributeSection.AttributeTarget);
outputFormatter.PrintToken(Tokens.Colon);
@ -160,9 +168,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -160,9 +168,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
if ("assembly".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)
|| "module".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)) {
outputFormatter.PrintIdentifier(">");
outputFormatter.PrintText(">");
} else {
outputFormatter.PrintIdentifier("> _");
outputFormatter.PrintText("> _");
}
outputFormatter.NewLine();
return null;
@ -214,7 +222,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -214,7 +222,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (((Using)usingDeclaration.Usings[i]).IsAlias) {
outputFormatter.PrintIdentifier(((Using)usingDeclaration.Usings[i]).Alias);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.PrintToken(Tokens.As);
outputFormatter.Space();
}
outputFormatter.PrintIdentifier(((Using)usingDeclaration.Usings[i]).Name);
@ -266,6 +274,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -266,6 +274,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return Tokens.Class;
}
void PrintTemplates(List<TemplateDefinition> templates)
{
if (templates != null && templates.Count > 0) {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
outputFormatter.PrintToken(Tokens.Of);
outputFormatter.Space();
AppendCommaSeparatedList(templates);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
}
public object Visit(TypeDeclaration typeDeclaration, object data)
{
VisitAttributes(typeDeclaration.Attributes, data);
@ -277,6 +296,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -277,6 +296,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(typeToken);
outputFormatter.Space();
outputFormatter.PrintIdentifier(typeDeclaration.Name);
PrintTemplates(typeDeclaration.Templates);
outputFormatter.NewLine();
if (typeDeclaration.BaseTypes != null) {
@ -296,10 +318,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -296,10 +318,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
}
foreach (TemplateDefinition templateDefinition in typeDeclaration.Templates) {
nodeTracker.TrackedVisit(templateDefinition, data);
}
++outputFormatter.IndentationLevel;
TypeDeclaration oldType = currentType;
currentType = typeDeclaration;
@ -320,7 +338,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -320,7 +338,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(TemplateDefinition templateDefinition, object data)
{
// TODO: TemplateDefinition
outputFormatter.PrintIdentifier(templateDefinition.Name);
if (templateDefinition.Bases.Count > 0) {
outputFormatter.PrintText(" As ");
if (templateDefinition.Bases.Count == 1) {
nodeTracker.TrackedVisit(templateDefinition.Bases[0], data);
} else {
outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
AppendCommaSeparatedList(templateDefinition.Bases);
outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
}
}
return null;
}
@ -340,6 +368,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -340,6 +368,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintIdentifier(delegateDeclaration.Name);
PrintTemplates(delegateDeclaration.Templates);
outputFormatter.PrintToken(Tokens.OpenParenthesis);
AppendCommaSeparatedList(delegateDeclaration.Parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
@ -544,7 +575,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -544,7 +575,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent();
OutputModifier(eventDeclaration.Modifier);
if (customEvent) {
outputFormatter.PrintIdentifier("Custom");
outputFormatter.PrintText("Custom");
outputFormatter.Space();
}
@ -587,8 +618,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -587,8 +618,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
VisitAttributes(eventAddRegion.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier("AddHandler");
outputFormatter.PrintToken(Tokens.OpenParenthesis);
outputFormatter.PrintText("AddHandler(");
if (eventAddRegion.Parameters.Count == 0) {
outputFormatter.PrintToken(Tokens.ByVal);
outputFormatter.Space();
@ -610,7 +640,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -610,7 +640,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent();
outputFormatter.PrintToken(Tokens.End);
outputFormatter.Space();
outputFormatter.PrintIdentifier("AddHandler");
outputFormatter.PrintText("AddHandler");
outputFormatter.NewLine();
return null;
}
@ -619,7 +649,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -619,7 +649,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
VisitAttributes(eventRemoveRegion.Attributes, data);
outputFormatter.Indent();
outputFormatter.PrintIdentifier("RemoveHandler");
outputFormatter.PrintText("RemoveHandler");
outputFormatter.PrintToken(Tokens.OpenParenthesis);
if (eventRemoveRegion.Parameters.Count == 0) {
outputFormatter.PrintToken(Tokens.ByVal);
@ -642,7 +672,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -642,7 +672,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent();
outputFormatter.PrintToken(Tokens.End);
outputFormatter.Space();
outputFormatter.PrintIdentifier("RemoveHandler");
outputFormatter.PrintText("RemoveHandler");
outputFormatter.NewLine();
return null;
}
@ -675,6 +705,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -675,6 +705,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
outputFormatter.Space();
outputFormatter.PrintIdentifier(methodDeclaration.Name);
PrintTemplates(methodDeclaration.Templates);
outputFormatter.PrintToken(Tokens.OpenParenthesis);
AppendCommaSeparatedList(methodDeclaration.Parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
@ -859,13 +892,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -859,13 +892,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Lib);
outputFormatter.Space();
outputFormatter.PrintIdentifier('"' + declareDeclaration.Library + '"');
outputFormatter.PrintText('"' + declareDeclaration.Library + '"');
outputFormatter.Space();
if (declareDeclaration.Alias.Length > 0) {
outputFormatter.PrintToken(Tokens.Alias);
outputFormatter.Space();
outputFormatter.PrintIdentifier('"' + declareDeclaration.Alias + '"');
outputFormatter.PrintText('"' + declareDeclaration.Alias + '"');
outputFormatter.Space();
}
@ -1241,10 +1274,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1241,10 +1274,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(GotoCaseStatement gotoCaseStatement, object data)
{
// TODO: implement me!
outputFormatter.PrintIdentifier("' goto case ");
outputFormatter.PrintText("goto case ");
if (gotoCaseStatement.IsDefaultCase) {
outputFormatter.PrintIdentifier("default");
outputFormatter.PrintText("default");
} else {
nodeTracker.TrackedVisit(gotoCaseStatement.Expression, null);
}
@ -1615,29 +1647,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1615,29 +1647,17 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
}
string ConvertChar(char ch)
{
switch (ch) {
case '\0':
case '\a':
case '\b':
case '\f':
case '\t':
case '\v':
case '\r':
case '\n':
return "\" & Microsoft.VisualBasic.Chr(" + ((int)ch) + ") & \"";
case '"':
return "\"\"";
}
return ch.ToString();
}
string ConvertString(string str)
{
StringBuilder sb = new StringBuilder();
foreach (char ch in str) {
sb.Append(ConvertChar(ch));
if (char.IsControl(ch)) {
sb.Append("\" & Microsoft.VisualBasic.Chr(" + ((int)ch) + ") & \"");
} else if (ch == '"') {
sb.Append("\"\"");
} else {
sb.Append(ch);
}
}
return sb.ToString();
}
@ -1658,22 +1678,22 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1658,22 +1678,22 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
if (primitiveExpression.Value is string) {
outputFormatter.PrintIdentifier('"' + ConvertString(primitiveExpression.Value.ToString()) + '"');
outputFormatter.PrintText('"' + ConvertString(primitiveExpression.Value.ToString()) + '"');
return null;
}
if (primitiveExpression.Value is char) {
outputFormatter.PrintIdentifier(ConvertCharLiteral((char)primitiveExpression.Value));
outputFormatter.PrintText(ConvertCharLiteral((char)primitiveExpression.Value));
return null;
}
if (primitiveExpression.Value is decimal) {
outputFormatter.PrintIdentifier(primitiveExpression.Value + "D");
outputFormatter.PrintText(((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D");
return null;
}
if (primitiveExpression.Value is float) {
outputFormatter.PrintIdentifier(primitiveExpression.Value + "F");
outputFormatter.PrintText(((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F");
return null;
}
@ -1737,16 +1757,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1737,16 +1757,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
break;
case BinaryOperatorType.AsCast:
outputFormatter.PrintIdentifier("TryCast(");
outputFormatter.PrintText("TryCast(");
nodeTracker.TrackedVisit(binaryOperatorExpression.Left, data);
outputFormatter.PrintIdentifier(", ");
outputFormatter.PrintText(", ");
nodeTracker.TrackedVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintIdentifier(")");
outputFormatter.PrintText(")");
return null;
case BinaryOperatorType.TypeCheck:
outputFormatter.PrintIdentifier("TypeOf ");
outputFormatter.PrintText("TypeOf ");
nodeTracker.TrackedVisit(binaryOperatorExpression.Left, data);
outputFormatter.PrintIdentifier(" Is ");
outputFormatter.PrintText(" Is ");
nodeTracker.TrackedVisit(binaryOperatorExpression.Right, data);
return null;
@ -1824,15 +1844,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1824,15 +1844,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null;
case UnaryOperatorType.Decrement:
outputFormatter.PrintIdentifier("System.Threading.Interlocked.Decrement(");
outputFormatter.PrintText("System.Threading.Interlocked.Decrement(");
nodeTracker.TrackedVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintIdentifier(")");
outputFormatter.PrintText(")");
return null;
case UnaryOperatorType.Increment:
outputFormatter.PrintIdentifier("System.Threading.Interlocked.Increment(");
outputFormatter.PrintText("System.Threading.Interlocked.Increment(");
nodeTracker.TrackedVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintIdentifier(")");
outputFormatter.PrintText(")");
return null;
case UnaryOperatorType.Minus:
@ -1848,19 +1868,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1848,19 +1868,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null;
case UnaryOperatorType.PostDecrement:
outputFormatter.PrintIdentifier("System.Math.Max(System.Threading.Interlocked.Decrement(");
outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Decrement(");
nodeTracker.TrackedVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintIdentifier("),");
outputFormatter.PrintText("),");
nodeTracker.TrackedVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintIdentifier(" + 1)");
outputFormatter.PrintText(" + 1)");
return null;
case UnaryOperatorType.PostIncrement:
outputFormatter.PrintIdentifier("System.Math.Max(System.Threading.Interlocked.Increment(");
outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Increment(");
nodeTracker.TrackedVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintIdentifier("),");
outputFormatter.PrintText("),");
nodeTracker.TrackedVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintIdentifier(" - 1)");
outputFormatter.PrintText(" - 1)");
return null;
case UnaryOperatorType.Star:
@ -2163,7 +2183,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2163,7 +2183,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(ConditionalExpression conditionalExpression, object data)
{
// No representation in VB.NET, but VB conversion is possible.
outputFormatter.PrintIdentifier("Microsoft.VisualBasic.IIf");
outputFormatter.PrintText("Microsoft.VisualBasic.IIf");
outputFormatter.PrintToken(Tokens.OpenParenthesis);
nodeTracker.TrackedVisit(conditionalExpression.Condition, data);
outputFormatter.PrintToken(Tokens.Comma);
@ -2299,9 +2319,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2299,9 +2319,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Comma);
outputFormatter.Space();
}
if ((i + 1) % 10 == 0) {
if ((i + 1) % 6 == 0) {
outputFormatter.PrintText("_ ");
outputFormatter.NewLine();
outputFormatter.Indent();
outputFormatter.PrintText("\t");
}
}
}

26
src/Libraries/NRefactory/Project/Src/Parser/AST/General/Enums.cs

@ -5,13 +5,13 @@ namespace ICSharpCode.NRefactory.Parser.AST @@ -5,13 +5,13 @@ namespace ICSharpCode.NRefactory.Parser.AST
[Flags]
public enum Modifier // TODO: Rename to Modifiers
{
// Access
// Access
Private = 0x0001,
Internal = 0x0002, // == Friend
Protected = 0x0004,
Public = 0x0008,
Dim = 0x0010, // VB.NET SPECIFIC
// Scope
Abstract = 0x0010, // == MustOverride/MustInherit
Virtual = 0x0020,
@ -21,15 +21,15 @@ namespace ICSharpCode.NRefactory.Parser.AST @@ -21,15 +21,15 @@ namespace ICSharpCode.NRefactory.Parser.AST
Readonly = 0x0200,
Const = 0x0400,
New = 0x0800, // == Shadows
Partial = 0x40000,
Partial = 0x1000,
// Special
Extern = 0x1000,
Volatile = 0x2000,
Unsafe = 0x4000,
Overloads = 0x8000, // VB specific
WithEvents = 0x10000, // VB specific
Default = 0x20000, // VB specific
// Special
Extern = 0x2000,
Volatile = 0x4000,
Unsafe = 0x8000,
Overloads = 0x10000, // VB specific
WithEvents = 0x20000, // VB specific
Default = 0x40000, // VB specific
// Modifier scopes
None = 0x0000,
@ -61,9 +61,9 @@ namespace ICSharpCode.NRefactory.Parser.AST @@ -61,9 +61,9 @@ namespace ICSharpCode.NRefactory.Parser.AST
Constructors = Public | Protected | Internal | Private | Extern,
All = Private | Internal | Protected | Public |
Abstract | Virtual | Sealed | Static | Partial |
Override | Readonly | Const | New |
Extern | Volatile | Unsafe | Overloads | WithEvents
Abstract | Virtual | Sealed | Static | Partial |
Override | Readonly | Const | New |
Extern | Volatile | Unsafe | Overloads | WithEvents
}
public enum Types // TODO: Rename to ClassType

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -674,6 +674,7 @@ @@ -674,6 +674,7 @@
<Compile Include="Src\TextEditor\Gui\Editor\CompletionWindow\AbstractCompletionDataProvider.cs" />
<Compile Include="Src\Dom\ExpressionContext.cs" />
<Compile Include="Src\TextEditor\Gui\Editor\CompletionWindow\CachedCompletionDataProvider.cs" />
<Compile Include="Src\Dom\Implementations\CompoundClass.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

6
src/Main/Base/Project/Src/Dom/IDecoration.cs

@ -65,11 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -65,11 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get;
}
bool IsFinal {
get;
}
bool IsSpecialName {
bool IsPartial {
get;
}

16
src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs

@ -166,22 +166,14 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -166,22 +166,14 @@ namespace ICSharpCode.SharpDevelop.Dom
return (modifiers & ModifierEnum.Override) == ModifierEnum.Override;
}
}
public bool IsFinal {
get {
return (modifiers & ModifierEnum.Final) == ModifierEnum.Final;
}
}
public bool IsSpecialName {
public bool IsNew {
get {
return (modifiers & ModifierEnum.SpecialName) == ModifierEnum.SpecialName;
return (modifiers & ModifierEnum.New) == ModifierEnum.New;
}
}
public bool IsNew {
public bool IsPartial {
get {
return (modifiers & ModifierEnum.New) == ModifierEnum.New;
return (modifiers & ModifierEnum.Partial) == ModifierEnum.Partial;
}
}

122
src/Main/Base/Project/Src/Dom/Implementations/CompoundClass.cs

@ -0,0 +1,122 @@ @@ -0,0 +1,122 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version value="$version"/>
// </file>
using System;
using System.Diagnostics;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// A class made up of multiple partial classes.
/// </summary>
public class CompoundClass : DefaultClass
{
List<IClass> parts = new List<IClass>();
/// <summary>
/// Gets the parts this class is based on.
/// </summary>
public List<IClass> Parts {
get {
return parts;
}
}
/// <summary>
/// Creates a new CompoundClass with the specified class as first part.
/// </summary>
public CompoundClass(IClass firstPart) : base(firstPart.CompilationUnit, firstPart.FullyQualifiedName)
{
parts.Add(firstPart);
UpdateInformationFromParts();
}
/// <summary>
/// Re-calculate information from class parts (Modifier, Base classes, Type parameters etc.)
/// </summary>
public void UpdateInformationFromParts()
{
// Common for all parts:
this.ClassType = parts[0].ClassType;
ModifierEnum modifier = ModifierEnum.None;
this.BaseTypes.Clear();
this.TypeParameters.Clear();
foreach (IClass part in parts) {
modifier |= part.Modifiers;
this.BaseTypes.AddRange(part.BaseTypes);
this.TypeParameters.AddRange(part.TypeParameters);
}
this.Modifiers = modifier;
}
public override List<IClass> InnerClasses {
get {
List<IClass> l = new List<IClass>();
foreach (IClass part in parts) {
l.AddRange(part.InnerClasses);
}
return l;
}
}
public override List<IField> Fields {
get {
List<IField> l = new List<IField>();
foreach (IClass part in parts) {
l.AddRange(part.Fields);
}
return l;
}
}
public override List<IProperty> Properties {
get {
List<IProperty> l = new List<IProperty>();
foreach (IClass part in parts) {
l.AddRange(part.Properties);
}
return l;
}
}
public override List<IIndexer> Indexer {
get {
List<IIndexer> l = new List<IIndexer>();
foreach (IClass part in parts) {
l.AddRange(part.Indexer);
}
return l;
}
}
public override List<IMethod> Methods {
get {
List<IMethod> l = new List<IMethod>();
foreach (IClass part in parts) {
l.AddRange(part.Methods);
}
return l;
}
}
public override List<IEvent> Events {
get {
List<IEvent> l = new List<IEvent>();
foreach (IClass part in parts) {
l.AddRange(part.Events);
}
return l;
}
}
}
}

12
src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs

@ -81,7 +81,6 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -81,7 +81,6 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public ClassType ClassType {
get {
return classType;
@ -199,7 +198,8 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -199,7 +198,8 @@ namespace ICSharpCode.SharpDevelop.Dom
return cmp;
}
}
return -1;
/*
if (Region != null) {
cmp = Region.CompareTo(value.Region);
if (cmp != 0) {
@ -231,7 +231,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -231,7 +231,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if(cmp != 0)
return cmp;
return DiffUtility.Compare(Events, value.Events);
return DiffUtility.Compare(Events, value.Events);*/
}
int IComparable.CompareTo(object o)
@ -355,10 +355,6 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -355,10 +355,6 @@ namespace ICSharpCode.SharpDevelop.Dom
public IClass GetInnermostClass(int caretLine, int caretColumn)
{
if (InnerClasses == null) {
return this;
}
foreach (IClass c in InnerClasses) {
if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) {
return c.GetInnermostClass(caretLine, caretColumn);
@ -517,7 +513,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -517,7 +513,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return true;
}
} catch (Exception e) {
Console.WriteLine(e);
MessageService.ShowError(e);
}
return false;
}

12
src/Main/Base/Project/Src/Dom/ModifierEnum.cs

@ -27,19 +27,19 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -27,19 +27,19 @@ namespace ICSharpCode.SharpDevelop.Dom
Readonly = 0x0200,
Const = 0x0400,
New = 0x0800,
Partial = 0x1000,
// Special
Extern = 0x1000,
Volatile = 0x2000,
Unsafe = 0x4000,
ProtectedAndInternal = Internal | Protected,
ProtectedOrInternal = 0x8000,
// Literal = 0x10000, <-- == Const now!!!
SpecialName = 0x20000,
Overloads = 0x10000, // VB specific
WithEvents = 0x20000, // VB specific
Default = 0x40000, // VB specific
Final = 0x40000,
Partial = 0x80000,
ProtectedAndInternal = Internal | Protected,
ProtectedOrInternal = 0x80000,
}
}

41
src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

@ -180,6 +180,34 @@ namespace ICSharpCode.Core @@ -180,6 +180,34 @@ namespace ICSharpCode.Core
protected void AddClassToNamespaceListInternal(IClass addClass)
{
if (addClass.IsPartial) {
Console.WriteLine(addClass);
Console.Write("Adding partial class... ");
Dictionary<string, IClass> classes = GetClasses(language);
CompoundClass compound = null;
if (classes.ContainsKey(addClass.FullyQualifiedName))
compound = classes[addClass.FullyQualifiedName] as CompoundClass;
if (compound != null) {
// possibly replace existing class (look for CU with same filename)
for (int i = 0; i < compound.Parts.Count; i++) {
if (compound.Parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) {
compound.Parts[i] = addClass;
compound.UpdateInformationFromParts();
Console.WriteLine("Replaced!");
return;
}
}
compound.Parts.Add(addClass);
compound.UpdateInformationFromParts();
Console.WriteLine("Added!");
return;
} else {
addClass = new CompoundClass(addClass);
Console.WriteLine("Compound created!");
Console.WriteLine(addClass);
}
}
foreach (Dictionary<string, IClass> classes in ClassLists) {
classes[addClass.FullyQualifiedName] = addClass;
}
@ -295,6 +323,17 @@ namespace ICSharpCode.Core @@ -295,6 +323,17 @@ namespace ICSharpCode.Core
void RemoveClass(IClass @class)
{
if (@class.IsPartial) {
// remove a part of a partial class
CompoundClass compound = (CompoundClass)GetClasses(language)[@class.FullyQualifiedName];
compound.Parts.Remove(@class);
if (compound.Parts.Count > 0) {
compound.UpdateInformationFromParts();
return;
} else {
@class = compound; // all parts removed, remove compound class
}
}
string nSpace = @class.Namespace;
if (nSpace == null) {
nSpace = String.Empty;
@ -308,8 +347,6 @@ namespace ICSharpCode.Core @@ -308,8 +347,6 @@ namespace ICSharpCode.Core
classes.Remove(fullyQualifiedName);
}
// Remove class from namespace lists
List<IClass> classList = GetNamespaces(this.language)[nSpace].Classes;
for (int i = 0; i < classList.Count; i++) {

Loading…
Cancel
Save