Browse Source

Fixed finding generic code-completion members by their Reflection name - fixes problems with Code analysis line numbers not showing for generic classes.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2326 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
bcb87bd3a2
  1. 22
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs
  2. 4
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/IProjectContent.cs

22
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

@ -841,13 +841,26 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -841,13 +841,26 @@ namespace ICSharpCode.SharpDevelop.Dom
return fallbackResult;
}
IClass GetClassByDotNetName(string className, bool lookInReferences)
{
className = className.Replace('+', '.');
if (className.Length > 2 && className[className.Length - 2] == '`') {
int typeParameterCount = className[className.Length - 1] - '0';
if (typeParameterCount < 0) typeParameterCount = 0;
className = className.Substring(0, className.Length - 2);
return GetClass(className, typeParameterCount, LanguageProperties.CSharp, lookInReferences);
} else {
return GetClass(className, 0, LanguageProperties.CSharp, lookInReferences);
}
}
/// <summary>
/// Gets the position of a member in this project content (not a referenced one).
/// </summary>
/// <param name="fullMemberName">Fully qualified member name (always case sensitive).</param>
/// <param name="fullMemberName">The full member name in Reflection syntax (always case sensitive, ` for generics)</param>
public IDecoration GetElement(string fullMemberName)
{
IClass curClass = GetClass(fullMemberName, 0, LanguageProperties.CSharp, false);
IClass curClass = GetClassByDotNetName(fullMemberName, false);
if (curClass != null) {
return curClass;
}
@ -865,7 +878,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -865,7 +878,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (pos2 > 0) {
string className = memberName.Substring(0, pos2);
memberName = memberName.Substring(pos2 + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
curClass = GetClassByDotNetName(className, false);
if (curClass != null) {
IMethod firstMethod = null;
foreach (IMethod m in curClass.Methods) {
@ -885,6 +898,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -885,6 +898,7 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
}
return firstMethod;
}
}
} else {
@ -892,7 +906,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -892,7 +906,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (pos > 0) {
string className = fullMemberName.Substring(0, pos);
string memberName = fullMemberName.Substring(pos + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
curClass = GetClassByDotNetName(className, false);
if (curClass != null) {
// get first method with that name, but prefer method without parameters
IMethod firstMethod = null;

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

@ -91,6 +91,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -91,6 +91,10 @@ namespace ICSharpCode.SharpDevelop.Dom
string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn);
SearchTypeResult SearchType(SearchTypeRequest request);
/// <summary>
/// Gets the definition position of the class/member.
/// </summary>
/// <param name="fullMemberName">The full member name in Reflection syntax (always case sensitive, ` for generics)</param>
FilePosition GetPosition(string fullMemberName);
}

Loading…
Cancel
Save