Browse Source

Support right-click > add using on type names when the "using" is missing.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2586 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
c989cbc19e
  1. 8
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  2. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  3. 154
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAdvancedHighlighter.cs
  4. 525
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/ExpressionFinder.cs
  5. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs
  6. 1
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
  7. 1
      src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.csproj
  8. 6
      src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
  9. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  10. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  11. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  12. 226
      src/Libraries/ICSharpCode.TextEditor/Project/Resources/CSharp-Mode.xshd
  13. 39
      src/Main/Base/Project/Src/Services/RefactoringService/NamespaceRefactoringService.cs
  14. 54
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs
  15. 5
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs
  16. 11
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs
  17. 16
      src/Main/Base/Test/CSharpExpressionFinderTests.cs
  18. 41
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/ExpressionFinder.cs
  19. 9
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs
  20. 3
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs
  21. 8
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/IProjectContent.cs
  22. 3
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/RefactoringProvider.cs
  23. 26
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ResolveResult.cs

8
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin

@ -57,6 +57,12 @@ @@ -57,6 +57,12 @@
<CodeCompletionBinding id = "CSharp" extensions = ".cs" class = "CSharpBinding.CSharpCompletionBinding"/>
</Path>
<!--
<Path name = "/AddIns/DefaultTextEditor/AdvancedHighlighter/C#">
<Class id = "CSharpHighlighter" class = "CSharpBinding.CSharpAdvancedHighlighter"/>
</Path>
-->
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/C#">
<DialogPanel id = "Application"
label = "${res:Dialog.ProjectOptions.ApplicationSettings}"
@ -105,3 +111,5 @@ @@ -105,3 +111,5 @@
class = "CSharpBinding.CSharpLanguageBinding" />
</Path>
</AddIn>

1
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -45,6 +45,7 @@ @@ -45,6 +45,7 @@
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<EmbeddedResource Include="Resources\BuildOptions.xfrm" />
<Compile Include="Src\CSharpAdvancedHighlighter.cs" />
<Compile Include="Src\CSharpLanguageBinding.cs" />
<Compile Include="Src\FormattingStrategy\CSharpFormattingStrategy.cs" />
<Compile Include="Src\FormattingStrategy\DocumentAccessor.cs" />

154
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAdvancedHighlighter.cs

@ -0,0 +1,154 @@ @@ -0,0 +1,154 @@
/*
* Created by SharpDevelop.
* User: Daniel
* Date: 24.06.2007
* Time: 15:29
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace CSharpBinding
{
public class CSharpAdvancedHighlighter : AsynchronousAdvancedHighlighter
{
public override void Initialize(TextEditorControl textEditor)
{
base.Initialize(textEditor);
ParserService.ParserUpdateStepFinished += OnUpdateStep;
}
public override void Dispose()
{
ParserService.ParserUpdateStepFinished -= OnUpdateStep;
base.Dispose();
}
void OnUpdateStep(object sender, ParserUpdateStepEventArgs e)
{
if (FileUtility.IsEqualFileName(e.FileName, this.TextEditor.FileName)) {
ParseInformation parseInfo = e.ParseInformation;
// if (parseInfo == null && this.storedParseInformation)
// parseInfo = ParserService.GetParseInformation(this.TextEditor.FileName);
// if (parseInfo != null) {
// ICompilationUnit cu = parseInfo.MostRecentCompilationUnit;
// }
WorkbenchSingleton.SafeThreadAsyncCall(MarkOutstanding);
}
}
static bool IsInMultilineCommentOrStringLiteral(LineSegment line)
{
if (line.HighlightSpanStack == null || line.HighlightSpanStack.IsEmpty) {
return false;
}
return !line.HighlightSpanStack.Peek().StopEOL;
}
protected override void MarkWords(int lineNumber, LineSegment currentLine, List<TextWord> words)
{
if (IsInMultilineCommentOrStringLiteral(currentLine)) {
return;
}
ParseInformation parseInfo = ParserService.GetParseInformation(this.TextEditor.FileName);
if (parseInfo == null) return;
CSharpExpressionFinder finder = new CSharpExpressionFinder(parseInfo);
Func<string, int, ExpressionResult> findExpressionMethod;
IClass callingClass = parseInfo.MostRecentCompilationUnit.GetInnermostClass(lineNumber, 0);
if (callingClass != null) {
if (GetCurrentMember(callingClass, lineNumber, 0) != null) {
findExpressionMethod = finder.FindFullExpressionInMethod;
} else {
findExpressionMethod = finder.FindFullExpressionInTypeDeclaration;
}
} else {
findExpressionMethod = finder.FindFullExpression;
}
string lineText = this.Document.GetText(currentLine.Offset, currentLine.Length);
bool changedLine = false;
// now go through the word list:
foreach (TextWord word in words) {
if (word.IsWhiteSpace) continue;
if (char.IsLetter(lineText[word.Offset]) || lineText[word.Offset] == '_') {
ExpressionResult result = findExpressionMethod(lineText, word.Offset);
if (result.Expression != null) {
// result.Expression
if (ICSharpCode.NRefactory.Parser.CSharp.Keywords.GetToken(result.Expression) >= 0)
continue;
// convert text editor to DOM coordinates:
resolveCount++;
ResolveResult rr = ParserService.Resolve(result, lineNumber + 1, word.Offset + 1, this.TextEditor.FileName, this.TextEditor.Text);
if (rr is MixedResolveResult || rr is TypeResolveResult) {
changedLine = true;
word.SyntaxColor = this.Document.HighlightingStrategy.GetColorFor("TypeReference");
} else if (rr == null) {
changedLine = true;
word.SyntaxColor = this.Document.HighlightingStrategy.GetColorFor("UnknownEntity");
}
}
}
}
if (markingOutstanding && changedLine) {
this.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber));
}
}
static IMember GetCurrentMember(IClass callingClass, int caretLine, int caretColumn)
{
if (callingClass == null)
return null;
foreach (IMethod method in callingClass.Methods) {
if (method.Region.IsInside(caretLine, caretColumn) || method.BodyRegion.IsInside(caretLine, caretColumn)) {
return method;
}
}
foreach (IProperty property in callingClass.Properties) {
if (property.Region.IsInside(caretLine, caretColumn) || property.BodyRegion.IsInside(caretLine, caretColumn)) {
return property;
}
}
return null;
}
bool markingOutstanding;
int resolveCount;
protected override void MarkOutstanding()
{
#if DEBUG
int time = Environment.TickCount;
#endif
markingOutstanding = true;
resolveCount = 0;
base.MarkOutstanding();
markingOutstanding = false;
#if DEBUG
time = Environment.TickCount - time;
if (time > 0) {
LoggingService.Info("CSharpHighlighter took " + time + "ms for " + resolveCount + " resolves");
}
#endif
this.Document.CommitUpdate();
}
}
}

525
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/ExpressionFinder.cs

@ -1,525 +0,0 @@ @@ -1,525 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Markus Palme" email="MarkusPalme@gmx.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Text;
using ICSharpCode.SharpDevelop.Dom;
namespace VBNetBinding.Parser
{
/// <summary>
/// Description of ExpressionFinder.
/// </summary>
public class ExpressionFinder : IExpressionFinder
{
ExpressionResult CreateResult(string expression)
{
if (expression == null)
return ExpressionResult.Empty;
if (expression.Length > 8 && expression.Substring(0, 8).Equals("Imports ", StringComparison.InvariantCultureIgnoreCase))
return new ExpressionResult(expression.Substring(8).TrimStart(), ExpressionContext.Type, null);
if (expression.Length > 4 && expression.Substring(0, 4).Equals("New ", StringComparison.InvariantCultureIgnoreCase))
return new ExpressionResult(expression.Substring(4).TrimStart(), ExpressionContext.ObjectCreation, null);
if (curTokenType == Ident && lastIdentifier.Equals("as", StringComparison.InvariantCultureIgnoreCase))
return new ExpressionResult(expression, ExpressionContext.Type);
return new ExpressionResult(expression);
}
public ExpressionResult FindExpression(string inText, int offset)
{
return CreateResult(FindExpressionInternal(inText, offset));
}
public string FindExpressionInternal(string inText, int offset)
{
this.text = FilterComments(inText, ref offset);
this.offset = this.lastAccept = offset;
this.state = START;
if (this.text == null)
{
return null;
}
//Console.WriteLine("---------------");
while (state != ERROR)
{
ReadNextToken();
//Console.WriteLine("cur state {0} got token {1}/{3} going to {2}", GetStateName(state), GetTokenName(curTokenType), GetStateName(stateTable[state, curTokenType]), curTokenType);
state = stateTable[state, curTokenType];
if (state == ACCEPT || state == ACCEPT2 || state == DOT)
{
lastAccept = this.offset;
}
if (state == ACCEPTNOMORE)
{
return this.text.Substring(this.offset + 1, offset - this.offset);
}
}
return this.text.Substring(this.lastAccept + 1, offset - this.lastAccept);
}
internal int LastExpressionStartPosition {
get {
return ((state == ACCEPTNOMORE) ? offset : lastAccept) + 1;
}
}
public ExpressionResult FindFullExpression(string inText, int offset)
{
string expressionBeforeOffset = FindExpressionInternal(inText, offset);
if (expressionBeforeOffset == null || expressionBeforeOffset.Length == 0)
return CreateResult(null);
StringBuilder b = new StringBuilder(expressionBeforeOffset);
// append characters after expression
for (int i = offset + 1; i < inText.Length; ++i) {
char c = inText[i];
if (Char.IsLetterOrDigit(c)) {
if (Char.IsWhiteSpace(inText, i - 1))
break;
b.Append(c);
} else if (c == ' ') {
b.Append(c);
} else if (c == '(') {
int otherBracket = SearchBracketForward(inText, i + 1, '(', ')');
if (otherBracket < 0)
break;
b.Append(inText, i, otherBracket - i + 1);
break;
} else {
break;
}
}
return CreateResult(b.ToString());
}
// Like VBNetFormattingStrategy.SearchBracketForward, but operates on a string.
private int SearchBracketForward(string text, int offset, char openBracket, char closingBracket)
{
bool inString = false;
bool inComment = false;
int brackets = 1;
for (int i = offset; i < text.Length; ++i) {
char ch = text[i];
if (ch == '\n') {
inString = false;
inComment = false;
}
if (inComment) continue;
if (ch == '"') inString = !inString;
if (inString) continue;
if (ch == '\'') {
inComment = true;
} else if (ch == openBracket) {
++brackets;
} else if (ch == closingBracket) {
--brackets;
if (brackets == 0) return i;
}
}
return -1;
}
/// <summary>
/// Removed the last part of the expression.
/// </summary>
/// <example>
/// "obj.Field" => "obj"
/// "obj.Method(args,...)" => "obj.Method"
/// </example>
public string RemoveLastPart(string expression)
{
text = expression;
offset = text.Length - 1;
ReadNextToken();
if (curTokenType == Ident && Peek() == '.')
GetNext();
return text.Substring(0, offset + 1);
}
#region Comment Filter and 'inside string watcher'
int initialOffset;
public string FilterComments(string text, ref int offset)
{
if (text.Length <= offset)
return null;
this.initialOffset = offset;
StringBuilder outText = new StringBuilder();
int curOffset = 0;
while (curOffset <= initialOffset)
{
char ch = text[curOffset];
switch (ch)
{
case '@':
if (curOffset + 1 < text.Length && text[curOffset + 1] == '"')
{
outText.Append(text[curOffset++]); // @
outText.Append(text[curOffset++]); // "
if (!ReadVerbatimString(outText, text, ref curOffset))
{
return null;
}
}
else
{
outText.Append(ch);
++curOffset;
}
break;
case '"':
outText.Append(ch);
curOffset++;
if (!ReadString(outText, text, ref curOffset))
{
return null;
}
break;
case '\'':
offset -= 1;
curOffset += 1;
if (!ReadToEOL(text, ref curOffset, ref offset))
{
return null;
}
break;
default:
outText.Append(ch);
++curOffset;
break;
}
}
return outText.ToString();
}
bool ReadToEOL(string text, ref int curOffset, ref int offset)
{
while (curOffset <= initialOffset)
{
char ch = text[curOffset++];
--offset;
if (ch == '\n')
{
return true;
}
}
return false;
}
bool ReadString(StringBuilder outText, string text, ref int curOffset)
{
while (curOffset <= initialOffset)
{
char ch = text[curOffset++];
outText.Append(ch);
if (ch == '"')
{
return true;
}
}
return false;
}
bool ReadVerbatimString(StringBuilder outText, string text, ref int curOffset)
{
while (curOffset <= initialOffset)
{
char ch = text[curOffset++];
outText.Append(ch);
if (ch == '"')
{
if (curOffset < text.Length && text[curOffset] == '"')
{
outText.Append(text[curOffset++]);
}
else
{
return true;
}
}
}
return false;
}
bool ReadMultiLineComment(string text, ref int curOffset, ref int offset)
{
while (curOffset <= initialOffset)
{
char ch = text[curOffset++];
--offset;
if (ch == '*')
{
if (curOffset < text.Length && text[curOffset] == '/')
{
++curOffset;
--offset;
return true;
}
}
}
return false;
}
#endregion
#region mini backward lexer
string text;
int offset;
char GetNext()
{
if (offset >= 0)
{
return text[offset--];
}
return '\0';
}
char Peek()
{
if (offset >= 0)
{
return text[offset];
}
return '\0';
}
void UnGet()
{
++offset;
}
// tokens for our lexer
static int Err = 0;
static int Dot = 1;
static int StrLit = 2;
static int Ident = 3;
static int New = 4;
// static int Bracket = 5;
static int Parent = 6;
static int Curly = 7;
static int Using = 8;
int curTokenType;
readonly static string[] tokenStateName = new string[] {
"Err", "Dot", "StrLit", "Ident", "New", "Bracket", "Paren", "Curly", "Using"
};
string GetTokenName(int state)
{
return tokenStateName[state];
}
string lastIdentifier;
void ReadNextToken()
{
char ch = GetNext();
curTokenType = Err;
if (ch == '\0' || ch == '\n' || ch == '\r')
{
return;
}
while (Char.IsWhiteSpace(ch))
{
ch = GetNext();
if (ch == '\n' || ch == '\r')
{
return;
}
}
switch (ch)
{
case '}':
if (ReadBracket('{', '}'))
{
curTokenType = Curly;
}
break;
case ')':
if (ReadBracket('(', ')'))
{
curTokenType = Parent;
}
break;
case ']':
if (ReadBracket('[', ']'))
{
curTokenType = Ident;
}
break;
case '.':
curTokenType = Dot;
break;
case '\'':
case '"':
if (ReadStringLiteral(ch))
{
curTokenType = StrLit;
}
break;
default:
if (IsIdentifierPart(ch))
{
string ident = ReadIdentifier(ch);
if (ident != null)
{
switch (ident.ToLowerInvariant())
{
case "new":
curTokenType = New;
break;
case "imports":
curTokenType = Using;
break;
default:
lastIdentifier = ident;
curTokenType = Ident;
break;
}
}
}
break;
}
}
bool ReadStringLiteral(char litStart)
{
while (true)
{
char ch = GetNext();
if (ch == '\0')
{
return false;
}
if (ch == litStart)
{
if (Peek() == '@' && litStart == '"')
{
GetNext();
}
return true;
}
}
}
bool ReadBracket(char openBracket, char closingBracket)
{
int curlyBraceLevel = 0;
int squareBracketLevel = 0;
int parenthesisLevel = 0;
switch (openBracket)
{
case '(':
parenthesisLevel++;
break;
case '[':
squareBracketLevel++;
break;
case '{':
curlyBraceLevel++;
break;
}
while (parenthesisLevel != 0 || squareBracketLevel != 0 || curlyBraceLevel != 0)
{
char ch = GetNext();
if (ch == '\0')
{
return false;
}
switch (ch)
{
case '(':
parenthesisLevel--;
break;
case '[':
squareBracketLevel--;
break;
case '{':
curlyBraceLevel--;
break;
case ')':
parenthesisLevel++;
break;
case ']':
squareBracketLevel++;
break;
case '}':
curlyBraceLevel++;
break;
}
}
return true;
}
string ReadIdentifier(char ch)
{
string identifier = ch.ToString();
while (IsIdentifierPart(Peek()))
{
identifier = GetNext() + identifier;
}
return identifier;
}
bool IsIdentifierPart(char ch)
{
return Char.IsLetterOrDigit(ch) || ch == '_';
}
#endregion
#region finite state machine
readonly static int ERROR = 0;
readonly static int START = 1;
readonly static int DOT = 2;
readonly static int MORE = 3;
readonly static int CURLY = 4;
readonly static int CURLY2 = 5;
readonly static int CURLY3 = 6;
readonly static int ACCEPT = 7;
readonly static int ACCEPTNOMORE = 8;
readonly static int ACCEPT2 = 9;
readonly static string[] stateName = new string[] {
"ERROR",
"START",
"DOT",
"MORE",
"CURLY",
"CURLY2",
"CURLY3",
"ACCEPT",
"ACCEPTNOMORE",
"ACCEPT2"
};
string GetStateName(int state)
{
return stateName[state];
}
int state = 0;
int lastAccept = 0;
static int[,] stateTable = new int[,] {
// Err, Dot, Str, ID, New, Brk, Par, Cur, Using
/*ERROR*/ { ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR},
/*START*/ { ERROR, ERROR, ACCEPT, ACCEPT, ERROR, MORE, ACCEPT2, CURLY, ACCEPTNOMORE},
/*DOT*/ { ERROR, ERROR, ACCEPT, ACCEPT, ERROR, MORE, ACCEPT2, CURLY, ERROR},
/*MORE*/ { ERROR, ERROR, ACCEPT, ACCEPT, ERROR, MORE, ACCEPT2, CURLY, ERROR},
/*CURLY*/ { ERROR, ERROR, ERROR, ERROR, ERROR, CURLY2, ERROR, ERROR, ERROR},
/*CURLY2*/ { ERROR, ERROR, ERROR, CURLY3, ERROR, ERROR, ERROR, ERROR, ERROR},
/*CURLY3*/ { ERROR, ERROR, ERROR, ERROR, ACCEPTNOMORE, ERROR, ERROR, ERROR, ERROR},
/*ACCEPT*/ { ERROR, DOT, ERROR, ERROR, ACCEPT, ERROR, ERROR, ERROR, ACCEPTNOMORE},
/*ACCEPTNOMORE*/ { ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR},
/*ACCEPT2*/ { ERROR, DOT, ERROR, ACCEPT, ACCEPT, ERROR, ERROR, ERROR, ERROR},
};
#endregion
}
}

4
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs

@ -9,6 +9,7 @@ using System; @@ -9,6 +9,7 @@ using System;
using System.IO;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.VBNet;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Project;
@ -36,7 +37,7 @@ namespace VBNetBinding.Parser @@ -36,7 +37,7 @@ namespace VBNetBinding.Parser
public IExpressionFinder CreateExpressionFinder(string fileName)
{
return new ExpressionFinder();
return new VBExpressionFinder();
}
public bool CanParse(string fileName)
@ -139,3 +140,4 @@ namespace VBNetBinding.Parser @@ -139,3 +140,4 @@ namespace VBNetBinding.Parser
///////// IParser Interface END
}
}

1
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj

@ -51,7 +51,6 @@ @@ -51,7 +51,6 @@
<Compile Include="Src\OptionPanels\BuildOptions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Parser\ExpressionFinder.cs" />
<Compile Include="Src\Parser\Parser.cs" />
<Compile Include="Src\Project\VBNetProject.cs" />
<None Include="VBNetBinding.addin">

1
src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.csproj

@ -60,6 +60,7 @@ @@ -60,6 +60,7 @@
<ProjectReference Include="..\..\..\..\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj">
<Project>{E73BB233-D88B-44A7-A98F-D71EE158381D}</Project>
<Name>Aga.Controls</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>

6
src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj

@ -13,25 +13,27 @@ @@ -13,25 +13,27 @@
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.FormsDesigner</RootNamespace>
<DebugType>Full</DebugType>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<PlatformTarget>AnyCPU</PlatformTarget>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\FormsDesigner\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<BaseAddress>108003328</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DebugType>None</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG</DefineConstants>
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -90,6 +90,7 @@ @@ -90,6 +90,7 @@
<ProjectReference Include="..\..\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -121,11 +121,13 @@ @@ -121,11 +121,13 @@
<ProjectReference Include="..\..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</ProjectReference>
<Page Include="Controls\PropertyEditor\PropertyEditor.xaml">
<DependentUpon>PropertyEditor.cs</DependentUpon>

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -121,6 +121,7 @@ @@ -121,6 +121,7 @@
<ProjectReference Include="..\..\..\..\..\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj">
<Project>{E73BB233-D88B-44A7-A98F-D71EE158381D}</Project>
<Name>Aga.Controls</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

226
src/Libraries/ICSharpCode.TextEditor/Project/Resources/CSharp-Mode.xshd

@ -3,12 +3,17 @@ @@ -3,12 +3,17 @@
<SyntaxDefinition name = "C#" extensions = ".cs">
<Environment>
<Custom name="TypeReference" bold="false" italic="false" color="#04ABAB" />
<Custom name="UnknownEntity" bold="false" italic="false" color="#AB0404" />
</Environment>
<Properties>
<Property name="LineComment" value="//"/>
</Properties>
<Digits name = "Digits" bold = "false" italic = "false" color = "DarkBlue"/>
<RuleSets>
<RuleSet ignorecase="false">
<Delimiters>&amp;&lt;&gt;~!%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
@ -20,19 +25,19 @@ @@ -20,19 +25,19 @@
<Span name = "DocLineComment" rule = "DocCommentSet" bold = "false" italic = "false" color = "Green" stopateol = "true" noescapesequences="true">
<Begin bold = "false" italic = "false" color = "Gray">///@!/@</Begin>
</Span>
<Span name = "LineComment" rule = "CommentMarkerSet" bold = "false" italic = "false" color = "Green" stopateol = "true">
<Begin>//@!/@</Begin>
</Span>
<Span name = "LineComment2" rule = "CommentMarkerSet" bold = "false" italic = "false" color = "Green" stopateol = "true">
<Begin>////</Begin>
</Span>
<Span name = "LineComment" rule = "CommentMarkerSet" bold = "false" italic = "false" color = "Green" stopateol = "true">
<Begin>//@!/@</Begin>
</Span>
<Span name = "LineComment2" rule = "CommentMarkerSet" bold = "false" italic = "false" color = "Green" stopateol = "true">
<Begin>////</Begin>
</Span>
<Span name = "BlockComment" rule = "CommentMarkerSet" bold = "false" italic = "false" color = "Green" stopateol = "false">
<Begin>/*</Begin>
<End>*/</End>
</Span>
<Span name = "String" bold = "false" italic = "false" color = "Blue" stopateol = "true" escapecharacter="\">
<Begin>"</Begin>
<End>"</End>
@ -73,9 +78,9 @@ @@ -73,9 +78,9 @@
<Key word = "~" />
<Key word = "!" />
<Key word = "|" />
<Key word = "&amp;" />
</KeyWords>
<Key word = "&amp;" />
</KeyWords>
<KeyWords name = "AccessKeywords" bold="true" italic="false" color="Black">
<Key word = "this" />
<Key word = "base" />
@ -91,8 +96,8 @@ @@ -91,8 +96,8 @@
<Key word = "false" />
<Key word = "stackalloc" />
</KeyWords>
<KeyWords name = "SelectionStatements" bold="true" italic="false" color="Blue">
<Key word = "else" />
<Key word = "if" />
@ -100,7 +105,7 @@ @@ -100,7 +105,7 @@
<Key word = "case" />
<Key word = "default" />
</KeyWords>
<KeyWords name = "IterationStatements" bold="true" italic="false" color="Blue">
<Key word = "do" />
<Key word = "for" />
@ -108,7 +113,7 @@ @@ -108,7 +113,7 @@
<Key word = "in" />
<Key word = "while" />
</KeyWords>
<KeyWords name = "JumpStatements" bold="false" italic="false" color="Navy">
<Key word = "break" />
<Key word = "continue" />
@ -129,12 +134,12 @@ @@ -129,12 +134,12 @@
<Key word = "catch" />
<Key word = "finally" />
</KeyWords>
<KeyWords name = "CheckedUncheckedStatements" bold="true" italic="false" color="DarkGray">
<Key word = "checked" />
<Key word = "unchecked" />
</KeyWords>
<KeyWords name = "UnsafeFixedStatements" bold="false" italic="false" color="Olive">
<Key word = "fixed" />
<Key word = "unsafe" />
@ -156,88 +161,88 @@ @@ -156,88 +161,88 @@
<Key word = "uint" />
<Key word = "ushort" />
<Key word = "ulong" />
</KeyWords>
<KeyWords name = "ReferenceTypes" bold="false" italic="false" color="Red">
<Key word = "class" />
<Key word = "interface" />
<Key word = "delegate" />
<Key word = "object" />
<Key word = "string" />
</KeyWords>
<KeyWords name = "Void" bold="false" italic="false" color="Red">
<Key word = "void" />
</KeyWords>
<KeyWords name = "ConversionKeyWords" bold="true" italic="false" color="Pink">
<Key word = "explicit" />
<Key word = "implicit" />
<Key word = "operator" />
</KeyWords>
</KeyWords>
<KeyWords name = "ReferenceTypes" bold="false" italic="false" color="Red">
<Key word = "class" />
<Key word = "interface" />
<Key word = "delegate" />
<Key word = "object" />
<Key word = "string" />
</KeyWords>
<KeyWords name = "Void" bold="false" italic="false" color="Red">
<Key word = "void" />
</KeyWords>
<KeyWords name = "ConversionKeyWords" bold="true" italic="false" color="Pink">
<Key word = "explicit" />
<Key word = "implicit" />
<Key word = "operator" />
</KeyWords>
<KeyWords name = "MethodParameters" bold="true" italic="false" color="DeepPink">
<Key word = "params" />
<Key word = "ref" />
<Key word = "out" />
</KeyWords>
<KeyWords name = "Modifiers" bold="false" italic="false" color="Brown">
<Key word = "abstract" />
<Key word = "const" />
<Key word = "event" />
<Key word = "extern" />
<Key word = "override" />
<Key word = "readonly" />
<Key word = "sealed" />
<Key word = "static" />
<Key word = "virtual" />
<Key word = "params" />
<Key word = "ref" />
<Key word = "out" />
</KeyWords>
<KeyWords name = "Modifiers" bold="false" italic="false" color="Brown">
<Key word = "abstract" />
<Key word = "const" />
<Key word = "event" />
<Key word = "extern" />
<Key word = "override" />
<Key word = "readonly" />
<Key word = "sealed" />
<Key word = "static" />
<Key word = "virtual" />
<Key word = "volatile" />
</KeyWords>
<KeyWords name = "AccessModifiers" bold="true" italic="false" color="Blue">
</KeyWords>
<KeyWords name = "AccessModifiers" bold="true" italic="false" color="Blue">
<Key word = "public" />
<Key word = "protected" />
<Key word = "private" />
<Key word = "internal" />
</KeyWords>
</KeyWords>
<KeyWords name = "NameSpaces" bold="true" italic="false" color="Green">
<Key word = "namespace" />
<Key word = "using" />
<Key word = "namespace" />
<Key word = "using" />
</KeyWords>
<KeyWords name = "LockKeyWord" bold="false" italic="false" color="DarkViolet">
<Key word = "lock" />
</KeyWords>
<Key word = "lock" />
</KeyWords>
<KeyWords name = "GetSet" bold="false" italic="false" color="SaddleBrown">
<Key word = "get" />
<Key word = "set" />
<Key word = "add" />
<Key word = "remove" />
<Key word = "get" />
<Key word = "set" />
<Key word = "add" />
<Key word = "remove" />
</KeyWords>
<KeyWords name = "Literals" bold="true" italic="false" color="Black">
<Key word = "null" />
<Key word = "value" />
<Key word = "null" />
<Key word = "value" />
</KeyWords>
</RuleSet>
<RuleSet name = "CommentMarkerSet" ignorecase = "false">
<Delimiters>&lt;&gt;~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
<Delimiters>&lt;&gt;~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
<KeyWords name = "ErrorWords" bold="true" italic="false" color="Red">
<Key word = "TODO" />
<Key word = "FIXME" />
</KeyWords>
</KeyWords>
<KeyWords name = "WarningWords" bold="true" italic="false" color="#EEE0E000">
<Key word = "HACK" />
<Key word = "UNDONE" />
</KeyWords>
</KeyWords>
</RuleSet>
<RuleSet name = "DocCommentSet" ignorecase = "false">
<Delimiters>&lt;&gt;~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
<Delimiters>&lt;&gt;~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
<Span name = "XmlTag" rule = "XmlDocSet" bold = "false" italic = "false" color = "Gray" stopateol = "true">
<Begin>&lt;</Begin>
@ -245,13 +250,13 @@ @@ -245,13 +250,13 @@
</Span>
<KeyWords name = "ErrorWords" bold="true" italic="false" color="Red">
<Key word = "TODO" />
<Key word = "FIXME" />
<Key word = "TODO" />
<Key word = "FIXME" />
</KeyWords>
<KeyWords name = "WarningWords" bold="true" italic="false" color="#EEE0E000">
<Key word = "HACK" />
<Key word = "UNDONE" />
<Key word = "HACK" />
<Key word = "UNDONE" />
</KeyWords>
</RuleSet>
@ -275,45 +280,46 @@ @@ -275,45 +280,46 @@
</RuleSet>
<RuleSet name = "XmlDocSet" ignorecase = "false">
<Delimiters>&lt;&gt;~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
<Delimiters>&lt;&gt;~!@%^*()-+=|\#/{}[]:;"' , .?</Delimiters>
<Span name = "String" bold = "true" italic = "false" color = "Silver" stopateol = "true">
<Begin>"</Begin>
<End>"</End>
</Span>
<KeyWords name = "Punctuation" bold = "true" italic = "false" color = "Gray">
<Key word = "/" />
<Key word = "|" />
<Key word = "=" />
</KeyWords>
<KeyWords name = "SpecialComment" bold="true" italic="false" color="Gray">
<Key word = "c" />
<Key word = "code" />
<Key word = "example" />
<Key word = "exception" />
<Key word = "list" />
<Key word = "para" />
<Key word = "param" />
<Key word = "paramref" />
<Key word = "permission" />
<Key word = "remarks" />
<Key word = "returns" />
<Key word = "see" />
<Key word = "seealso" />
<Key word = "summary" />
<Key word = "value" />
<Key word = "type" />
<Key word = "name" />
<Key word = "cref" />
<Key word = "item" />
<Key word = "term" />
<Key word = "description" />
<Key word = "listheader" />
</KeyWords>
</KeyWords>
<KeyWords name = "SpecialComment" bold="true" italic="false" color="Gray">
<Key word = "c" />
<Key word = "code" />
<Key word = "example" />
<Key word = "exception" />
<Key word = "list" />
<Key word = "para" />
<Key word = "param" />
<Key word = "paramref" />
<Key word = "permission" />
<Key word = "remarks" />
<Key word = "returns" />
<Key word = "see" />
<Key word = "seealso" />
<Key word = "summary" />
<Key word = "value" />
<Key word = "type" />
<Key word = "name" />
<Key word = "cref" />
<Key word = "item" />
<Key word = "term" />
<Key word = "description" />
<Key word = "listheader" />
</KeyWords>
</RuleSet>
</RuleSets>
</SyntaxDefinition>

39
src/Main/Base/Project/Src/Services/RefactoringService/NamespaceRefactoringService.cs

@ -67,7 +67,16 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -67,7 +67,16 @@ namespace ICSharpCode.SharpDevelop.Refactoring
}
// put empty line after last System namespace
if (sort && newUsings.Count > 1 && newUsings[0].Usings.Count > 0) {
if (sort) {
PutEmptyLineAfterLastSystemNamespace(newUsings);
}
cu.ProjectContent.Language.CodeGenerator.ReplaceUsings(new TextEditorDocument(document), cu.Usings, newUsings);
}
static void PutEmptyLineAfterLastSystemNamespace(List<IUsing> newUsings)
{
if (newUsings.Count > 1 && newUsings[0].Usings.Count > 0) {
bool inSystem = IsSystemNamespace(newUsings[0].Usings[0]);
int inSystemCount = 1;
for (int i = 1; inSystem && i < newUsings.Count; i++) {
@ -81,8 +90,36 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -81,8 +90,36 @@ namespace ICSharpCode.SharpDevelop.Refactoring
}
}
}
}
public static void AddUsingDeclaration(ICompilationUnit cu, IDocument document, string newNamespace, bool sortExistingUsings)
{
IUsing newUsingDecl = new DefaultUsing(cu.ProjectContent);
newUsingDecl.Usings.Add(newNamespace);
List<IUsing> newUsings = new List<IUsing>(cu.Usings);
if (sortExistingUsings) {
newUsings.Sort(CompareUsings);
}
bool inserted = false;
for (int i = 0; i < newUsings.Count; i++) {
if (newUsings[i].Usings.Count >= 1
&& cu.ProjectContent.Language.NameComparer.Compare(newNamespace, newUsings[i].Usings[0]) <= 0)
{
newUsings.Insert(i, newUsingDecl);
inserted = true;
break;
}
}
if (!inserted) {
newUsings.Add(newUsingDecl);
}
if (sortExistingUsings) {
PutEmptyLineAfterLastSystemNamespace(newUsings);
}
cu.ProjectContent.Language.CodeGenerator.ReplaceUsings(new TextEditorDocument(document), cu.Usings, newUsings);
}
}
}

54
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs

@ -94,19 +94,24 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -94,19 +94,24 @@ namespace ICSharpCode.SharpDevelop.Refactoring
} else if (rr is LocalResolveResult) {
item = MakeItem((LocalResolveResult)rr, caretLine + 1 == ((LocalResolveResult)rr).Field.Region.BeginLine);
insertIndex = 0; // Insert local variable menu item at the topmost position.
} else if (rr is UnknownIdentifierResolveResult) {
item = MakeItemForResolveError((UnknownIdentifierResolveResult)rr, expressionResult.Context, textArea);
insertIndex = 0; // Insert menu item at the topmost position.
}
if (item != null) {
resultItems.Insert(insertIndex, item);
}
// Include menu for current class and method
ICompilationUnit cu = null;
IMember callingMember = null;
if (rr != null) {
callingMember = rr.CallingMember;
cu = callingMember.DeclaringType.CompilationUnit;
} else {
ParseInformation parseInfo = ParserService.GetParseInformation(textEditorControl.FileName);
if (parseInfo != null) {
ICompilationUnit cu = parseInfo.MostRecentCompilationUnit;
cu = parseInfo.MostRecentCompilationUnit;
if (cu != null) {
IClass callingClass = cu.GetInnermostClass(caretLine + 1, textArea.Caret.Column + 1);
callingMember = GetCallingMember(callingClass, caretLine + 1, textArea.Caret.Column + 1);
@ -129,6 +134,48 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -129,6 +134,48 @@ namespace ICSharpCode.SharpDevelop.Refactoring
}
}
ToolStripMenuItem MakeItemForResolveError(UnknownIdentifierResolveResult rr, ExpressionContext context, TextArea textArea)
{
if (context != null && context.IsTypeContext) {
return MakeItemForUnknownClass(rr.CallingClass, rr.Identifier, textArea);
}
return null;
}
ToolStripMenuItem MakeItemForUnknownClass(IClass callingClass, string unknownClassName, TextArea textArea)
{
if (callingClass == null)
return null;
IProjectContent pc = callingClass.ProjectContent;
if (!pc.Language.RefactoringProvider.IsEnabledForFile(callingClass.CompilationUnit.FileName))
return null;
ToolStripMenuItem item = MakeItemInternal(unknownClassName, ClassBrowserIconService.GotoArrowIndex, callingClass.CompilationUnit, DomRegion.Empty);
List<IClass> searchResults = new List<IClass>();
SearchAllClassesWithName(searchResults, pc, unknownClassName, pc.Language);
foreach (IProjectContent rpc in pc.ReferencedContents) {
SearchAllClassesWithName(searchResults, rpc, unknownClassName, pc.Language);
}
foreach (IClass c in searchResults) {
string newNamespace = c.Namespace;
ToolStripMenuItem subItem = new ToolStripMenuItem("using " + newNamespace, ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.NamespaceIndex]);
item.DropDownItems.Add(subItem);
subItem.Click += delegate {
NamespaceRefactoringService.AddUsingDeclaration(callingClass.CompilationUnit, textArea.Document, newNamespace, true);
textArea.MotherTextEditorControl.Refresh();
};
}
return item;
}
void SearchAllClassesWithName(List<IClass> searchResults, IProjectContent pc, string name, LanguageProperties language)
{
foreach (string ns in pc.NamespaceNames) {
IClass c = pc.GetClass(ns + "." + name, 0, language, false);
if (c != null)
searchResults.Add(c);
}
}
IMember GetCallingMember(IClass callingClass, int caretLine, int caretColumn)
{
if (callingClass == null) {
@ -194,7 +241,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -194,7 +241,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
//item.DropDown.Items.Add(titleItem);
//item.DropDown.Items.Add(new ToolStripSeparator());
if (cu.FileName != null && !region.IsEmpty) {
if (cu != null && cu.FileName != null && !region.IsEmpty) {
ToolStripMenuItem gotoDefinitionItem = new ToolStripMenuItem(StringParser.Parse("${res:ICSharpCode.NAntAddIn.GotoDefinitionMenuLabel}"),
ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GotoArrowIndex]);
gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter;
@ -232,3 +279,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -232,3 +279,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring
}
}
}

5
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

@ -205,6 +205,10 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -205,6 +205,10 @@ namespace ICSharpCode.SharpDevelop.Refactoring
if (expressionFinder == null) {
expressionFinder = ParserService.GetExpressionFinder(fileName);
if (expressionFinder == null) {
// ignore file if we cannot get an expression finder
return;
}
}
ExpressionResult expr = expressionFinder.FindFullExpression(fileContent, match.ResolvePosition);
if (expr.Expression != null) {
@ -523,3 +527,4 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -523,3 +527,4 @@ namespace ICSharpCode.SharpDevelop.Refactoring
#endregion
}
}

11
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -62,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
public IndentStyle IndentStyle {
get {
return (IndentStyle)properties.Get("IndentStyle", IndentStyle.Smart);
return properties.Get("IndentStyle", IndentStyle.Smart);
}
set {
properties.Set("IndentStyle", value);
@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public DocumentSelectionMode DocumentSelectionMode {
get {
return (DocumentSelectionMode)properties.Get("DocumentSelectionMode", DocumentSelectionMode.Normal);
return properties.Get("DocumentSelectionMode", DocumentSelectionMode.Normal);
}
set {
properties.Set("DocumentSelectionMode", value);
@ -132,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -132,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
return properties.Get("ShowTabs", false);
}
set {
properties.Get("ShowTabs", value);
properties.Set("ShowTabs", value);
}
}
public bool ShowEOLMarker {
@ -250,7 +250,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -250,7 +250,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
public LineViewerStyle LineViewerStyle {
get {
return (LineViewerStyle)properties.Get("LineViewerStyle", LineViewerStyle.None);
return properties.Get("LineViewerStyle", LineViewerStyle.None);
}
set {
properties.Set("LineViewerStyle", value);
@ -258,7 +258,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -258,7 +258,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
public string LineTerminator {
get {
LineTerminatorStyle lineTerminatorStyle = (LineTerminatorStyle)PropertyService.Get("SharpDevelop.LineTerminatorStyle", LineTerminatorStyle.Windows);
LineTerminatorStyle lineTerminatorStyle = PropertyService.Get("SharpDevelop.LineTerminatorStyle", LineTerminatorStyle.Windows);
switch (lineTerminatorStyle) {
case LineTerminatorStyle.Windows:
return "\r\n";
@ -332,3 +332,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -332,3 +332,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
}

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

@ -26,7 +26,7 @@ class Main<T> : BaseType @@ -26,7 +26,7 @@ class Main<T> : BaseType
void Method() {
simple += 1;
int a = 0;
((CastTo)castTarget).MethodOnCastExpression(parameter);
((CastTo)castTarget).MethodOnCastExpression(par.a, par.b);
int b = 0;
return ((CastTo)castTarget).PropertyOnCastExpression;
}
@ -61,7 +61,9 @@ class Main { @@ -61,7 +61,9 @@ class Main {
if (pos < 0) Assert.Fail("location not found in program");
ExpressionResult er = ef.FindFullExpression(program, pos);
Assert.AreEqual(expectedExpression, er.Expression);
Assert.AreEqual(expectedContext.ToString(), er.Context.ToString());
if (expectedContext != null) {
Assert.AreEqual(expectedContext.ToString(), er.Context.ToString());
}
}
void FindExpr(string program, string location, string expectedExpression, ExpressionContext expectedContext)
@ -110,24 +112,21 @@ class Main { @@ -110,24 +112,21 @@ class Main {
}
[Test]
[Ignore("Context inside methods not yet implemented")]
public void MethodOnCast()
{
FindFull(document, "thodOnCastExpression(para", "((CastTo)castTarget).MethodOnCastExpression(parameter)", ExpressionContext.Default);
FindFull(document, "thodOnCastExpression(pa", "((CastTo)castTarget).MethodOnCastExpression(par.a, par.b)", null);
}
[Test]
[Ignore("Context inside methods not yet implemented")]
public void PropertyOnCast()
{
FindFull(document, "pertyOnCastExpression", "((CastTo)castTarget).PropertyOnCastExpression", ExpressionContext.Default);
FindFull(document, "pertyOnCastExpression", "((CastTo)castTarget).PropertyOnCastExpression", null);
}
[Test]
[Ignore("Context inside methods not yet implemented")]
public void PropertyOnCastInForeachLoop()
{
FindFull(program2, "pertyOnCastExpression", "((CastTo)castTarget).PropertyOnCastExpression", ExpressionContext.Default);
FindFull(program2, "pertyOnCastExpression", "((CastTo)castTarget).PropertyOnCastExpression", null);
}
[Test]
@ -204,3 +203,4 @@ class Main { @@ -204,3 +203,4 @@ class Main {
}
}
}

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

@ -434,9 +434,43 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp @@ -434,9 +434,43 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
}
public ExpressionResult FindFullExpression(string text, int offset)
{
return FindFullExpression(text, offset, null);
}
/// <summary>
/// Like FindFullExpression, but text is a code snippet inside a type declaration.
/// </summary>
public ExpressionResult FindFullExpressionInTypeDeclaration(string text, int offset)
{
Frame root = new Frame(null);
root.childType = FrameType.TypeDecl;
Frame typeDecl = new Frame(root);
return FindFullExpression(text, offset, typeDecl);
}
/// <summary>
/// Like FindFullExpression, but text is a code snippet inside a method body.
/// </summary>
public ExpressionResult FindFullExpressionInMethod(string text, int offset)
{
Frame root = new Frame(null);
root.childType = FrameType.TypeDecl;
Frame typeDecl = new Frame(root);
typeDecl.childType = FrameType.Statements;
Frame methodBody = new Frame(typeDecl);
return FindFullExpression(text, offset, methodBody);
}
ExpressionResult FindFullExpression(string text, int offset, Frame initialFrame)
{
Init(text, offset);
if (initialFrame != null) {
frame = initialFrame;
}
const int SEARCHING_OFFSET = 0;
const int SEARCHING_END = 1;
int state = SEARCHING_OFFSET;
@ -486,9 +520,11 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp @@ -486,9 +520,11 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
} else if (resultFrame.bracketType == '<' && token.kind == Tokens.GreaterThan) {
// expression was a type argument
resultContext = ExpressionContext.Type;
return new ExpressionResult(text.Substring(resultStartOffset, resultEndOffset - resultStartOffset), resultContext);
}
if (frame == resultFrame || resultFrame.type == FrameType.Popped) {
return new ExpressionResult(text.Substring(resultStartOffset, resultEndOffset - resultStartOffset), resultContext);
}
return new ExpressionResult(text.Substring(resultStartOffset, resultEndOffset - resultStartOffset), resultContext);
} else {
resultEndOffset = LocationToOffset(token.EndLocation);
}
@ -689,3 +725,4 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp @@ -689,3 +725,4 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
#endregion
}
}

9
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs

@ -62,6 +62,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -62,6 +62,10 @@ namespace ICSharpCode.SharpDevelop.Dom
return false;
}
}
public virtual bool IsTypeContext {
get { return false; }
}
#endregion
#region C# specific contexts (public static fields) * MOVE TO ANOTHER CLASS *
@ -277,6 +281,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -277,6 +281,10 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public override bool IsTypeContext {
get { return true; }
}
public override string ToString()
{
if (baseClass != null)
@ -461,3 +469,4 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -461,3 +469,4 @@ namespace ICSharpCode.SharpDevelop.Dom
#endregion
}
}

3
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -417,6 +417,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -417,6 +417,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
ResolveResult result = ResolveIdentifier(((IdentifierExpression)expr).Identifier, expr.StartLocation, context);
if (result != null)
return result;
else
return new UnknownIdentifierResolveResult(callingClass, callingMember, ((IdentifierExpression)expr).Identifier);
} else if (expr is TypeReferenceExpression) {
type = TypeVisitor.CreateReturnType(((TypeReferenceExpression)expr).TypeReference, this);
if (type != null) {
@ -1185,3 +1187,4 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -1185,3 +1187,4 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
}
}

8
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/IProjectContent.cs

@ -30,10 +30,17 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -30,10 +30,17 @@ namespace ICSharpCode.SharpDevelop.Dom
get;
}
/// <summary>
/// Gets the list of namespaces defined in this project content. Does not include namespaces from
/// referenced project contents.
/// </summary>
ICollection<string> NamespaceNames {
get;
}
/// <summary>
/// Gets the list of referenced project contents.
/// </summary>
ICollection<IProjectContent> ReferencedContents {
get;
}
@ -167,3 +174,4 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -167,3 +174,4 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
}

3
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/RefactoringProvider.cs

@ -40,7 +40,6 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring @@ -40,7 +40,6 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
throw new NotSupportedException();
}
public virtual bool SupportsCreateNewFileLikeExisting {
get {
return false;
@ -72,3 +71,5 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring @@ -72,3 +71,5 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
}
}
}

26
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ResolveResult.cs

@ -32,6 +32,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -32,6 +32,10 @@ namespace ICSharpCode.SharpDevelop.Dom
this.resolvedType = resolvedType;
}
public virtual bool IsValid {
get { return true; }
}
/// <summary>
/// Gets the class that contained the expression used to get this ResolveResult.
/// Can be null when the class is unknown.
@ -567,4 +571,26 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -567,4 +571,26 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
#endregion
#region UnknownIdentifierResolveResult
public class UnknownIdentifierResolveResult : ResolveResult
{
string identifier;
public UnknownIdentifierResolveResult(IClass callingClass, IMember callingMember, string identifier)
: base(callingClass, callingMember, null)
{
this.identifier = identifier;
}
public string Identifier {
get { return identifier; }
}
public override bool IsValid {
get { return false; }
}
}
#endregion
}

Loading…
Cancel
Save