Browse Source

ResourceToolkit:

Fixed resolving of local resource managers (was broken since r2191 because NRefactoryResolver now requires the location to be set on expressions that are parsed with parser.ParseExpression).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2264 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Christian Hornung 19 years ago
parent
commit
6aea4eba79
  1. 5
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/BclNRefactoryResourceResolver.cs
  2. 4
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/ICSharpCodeCoreNRefactoryResourceResolver.cs
  3. 4
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/INRefactoryResourceResolver.cs
  4. 35
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryAstCacheService.cs
  5. 2
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs

5
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/BclNRefactoryResourceResolver.cs

@ -31,8 +31,8 @@ namespace Hornung.ResourceToolkit.Resolver @@ -31,8 +31,8 @@ namespace Hornung.ResourceToolkit.Resolver
/// <param name="expressionResult">The ExpressionResult for the expression.</param>
/// <param name="expr">The AST representation of the full expression.</param>
/// <param name="resolveResult">SharpDevelop's ResolveResult for the expression.</param>
/// <param name="caretLine">The line where the expression is located.</param>
/// <param name="caretColumn">The column where the expression is located.</param>
/// <param name="caretLine">The 0-based line where the expression is located.</param>
/// <param name="caretColumn">The 0-based column where the expression is located.</param>
/// <param name="fileName">The name of the source file where the expression is located.</param>
/// <param name="fileContent">The content of the source file where the expression is located.</param>
/// <param name="expressionFinder">The ExpressionFinder for the file.</param>
@ -229,6 +229,7 @@ namespace Hornung.ResourceToolkit.Resolver @@ -229,6 +229,7 @@ namespace Hornung.ResourceToolkit.Resolver
/// Tries to determine the resource set which is referenced by the
/// resource manager which is assigned to the specified member.
/// </summary>
/// <param name="member">The referenced member to examine.</param>
/// <returns>
/// The ResourceSetReference, if successful, or a null reference, if the
/// specified member is not a resource manager or if the

4
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/ICSharpCodeCoreNRefactoryResourceResolver.cs

@ -27,8 +27,8 @@ namespace Hornung.ResourceToolkit.Resolver @@ -27,8 +27,8 @@ namespace Hornung.ResourceToolkit.Resolver
/// <param name="expressionResult">The ExpressionResult for the expression.</param>
/// <param name="expr">The AST representation of the full expression.</param>
/// <param name="resolveResult">SharpDevelop's ResolveResult for the expression.</param>
/// <param name="caretLine">The line where the expression is located.</param>
/// <param name="caretColumn">The column where the expression is located.</param>
/// <param name="caretLine">The 0-based line where the expression is located.</param>
/// <param name="caretColumn">The 0-based column where the expression is located.</param>
/// <param name="fileName">The name of the source file where the expression is located.</param>
/// <param name="fileContent">The content of the source file where the expression is located.</param>
/// <param name="expressionFinder">The ExpressionFinder for the file.</param>

4
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/INRefactoryResourceResolver.cs

@ -26,8 +26,8 @@ namespace Hornung.ResourceToolkit.Resolver @@ -26,8 +26,8 @@ namespace Hornung.ResourceToolkit.Resolver
/// <param name="expressionResult">The ExpressionResult for the expression.</param>
/// <param name="expr">The AST representation of the full expression.</param>
/// <param name="resolveResult">SharpDevelop's ResolveResult for the expression.</param>
/// <param name="caretLine">The line where the expression is located.</param>
/// <param name="caretColumn">The column where the expression is located.</param>
/// <param name="caretLine">The 0-based line where the expression is located.</param>
/// <param name="caretColumn">The 0-based column where the expression is located.</param>
/// <param name="fileName">The name of the source file where the expression is located.</param>
/// <param name="fileContent">The content of the source file where the expression is located.</param>
/// <param name="expressionFinder">The ExpressionFinder for the file.</param>

35
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryAstCacheService.cs

@ -123,8 +123,10 @@ namespace Hornung.ResourceToolkit.Resolver @@ -123,8 +123,10 @@ namespace Hornung.ResourceToolkit.Resolver
/// </summary>
/// <param name="fileName">The file name of the source code file that contains the expression.</param>
/// <param name="expression">The expression to parse.</param>
/// <param name="caretLine">The 1-based line number of the expression.</param>
/// <param name="caretColumn">The 1-based column number of the expression.</param>
/// <returns>The parsed expression or <c>null</c> if the expression cannot be parsed or the language of the source code file is not supported.</returns>
public static Expression ParseExpression(string fileName, string expression)
public static Expression ParseExpression(string fileName, string expression, int caretLine, int caretColumn)
{
SupportedLanguage? l = NRefactoryResourceResolver.GetFileLanguage(fileName);
if (l == null) {
@ -132,7 +134,32 @@ namespace Hornung.ResourceToolkit.Resolver @@ -132,7 +134,32 @@ namespace Hornung.ResourceToolkit.Resolver
}
using (ICSharpCode.NRefactory.IParser p = ICSharpCode.NRefactory.ParserFactory.CreateParser(l.Value, new System.IO.StringReader(expression))) {
return p.ParseExpression();
Expression expr = p.ParseExpression();
if (expr != null) {
expr.AcceptVisitor(new SetAllNodePointsAstVisitor(new Location(caretColumn, caretLine), new Location(caretColumn + 1, caretLine)), null);
}
return expr;
}
}
/// <summary>
/// An AST visitor that sets the start and end location of all visited nodes
/// to the values passed to the constructor.
/// </summary>
sealed class SetAllNodePointsAstVisitor : ICSharpCode.NRefactory.Visitors.NodeTrackingAstVisitor
{
readonly Location start, end;
public SetAllNodePointsAstVisitor(Location start, Location end)
{
this.start = start;
this.end = end;
}
protected override void BeginVisit(INode node)
{
node.StartLocation = start;
node.EndLocation = end;
}
}
@ -149,7 +176,7 @@ namespace Hornung.ResourceToolkit.Resolver @@ -149,7 +176,7 @@ namespace Hornung.ResourceToolkit.Resolver
/// <returns>A ResolveResult or <c>null</c> if the expression cannot be resolved.</returns>
public static ResolveResult ResolveLowLevel(string fileName, int caretLine, int caretColumn, CompilationUnit compilationUnit, string expression, ExpressionContext context)
{
Expression expr = ParseExpression(fileName, expression);
Expression expr = ParseExpression(fileName, expression, caretLine, caretColumn);
if (expr == null) return null;
return ResolveLowLevel(fileName, caretLine, caretColumn, compilationUnit, expression, expr, context);
}
@ -268,7 +295,7 @@ namespace Hornung.ResourceToolkit.Resolver @@ -268,7 +295,7 @@ namespace Hornung.ResourceToolkit.Resolver
{
if (!String.IsNullOrEmpty(expressionResult.Expression = expressionFinder.RemoveLastPart(expressionResult.Expression))) {
Expression nextExpression;
if ((nextExpression = ParseExpression(fileName, expressionResult.Expression)) != null) {
if ((nextExpression = ParseExpression(fileName, expressionResult.Expression, caretLine + 1, caretColumn + 1)) != null) {
return ResolveLowLevel(fileName, caretLine + 1, caretColumn + 1, null, expressionResult.Expression, nextExpression, expressionResult.Context);
}
}

2
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryResourceResolver.cs

@ -125,7 +125,7 @@ namespace Hornung.ResourceToolkit.Resolver @@ -125,7 +125,7 @@ namespace Hornung.ResourceToolkit.Resolver
if (result.Expression != null) {
Expression expr = NRefactoryAstCacheService.ParseExpression(fileName, result.Expression);
Expression expr = NRefactoryAstCacheService.ParseExpression(fileName, result.Expression, caretLine + 1, caretColumn + 1);
if (expr == null) {
return null;

Loading…
Cancel
Save