Browse Source

Merge branch '4.0'.

Conflicts - resolved:
	src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs
	src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs
pull/15/head
mkonicek 15 years ago
parent
commit
81b7a20c1d
  1. 6
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs
  2. 9
      src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs
  3. 42
      src/AddIns/Analysis/Profiler/Hook/Profiler.Rewriting.cpp
  4. 2
      src/AddIns/Analysis/Profiler/Hook/Profiler.cpp
  5. 15
      src/AddIns/Analysis/Profiler/Hook/constants.cpp
  6. 6
      src/AddIns/Analysis/Profiler/Hook/global.h
  7. 68
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs
  8. 5
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  9. 18
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs
  10. 2
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs
  11. 55
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

6
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs

@ -240,7 +240,7 @@ namespace ICSharpCode.CodeCoverage
CodeCoverageSequencePoint sequencePoint = methodNode.Method.SequencePoints[0]; CodeCoverageSequencePoint sequencePoint = methodNode.Method.SequencePoints[0];
if (sequencePoint.HasDocument()) { if (sequencePoint.HasDocument()) {
if (classNode == null) { if (classNode == null) {
OpenFile(sequencePoint.Document, sequencePoint.Line - 1, sequencePoint.Column - 1); OpenFile(sequencePoint.Document, sequencePoint.Line, sequencePoint.Column);
} else { } else {
OpenFile(sequencePoint.Document, 1, 1); OpenFile(sequencePoint.Document, 1, 1);
} }
@ -310,8 +310,8 @@ namespace ICSharpCode.CodeCoverage
textEditor.Load(fileName); textEditor.Load(fileName);
} }
textEditor.ScrollToEnd(); textEditor.ScrollToEnd();
textEditor.TextArea.Caret.Line = line - 1; textEditor.TextArea.Caret.Location = new ICSharpCode.AvalonEdit.Document.TextLocation(line, column);
textEditor.ScrollToLine(line - 1); textEditor.ScrollToLine(line);
CodeCoverageService.ShowCodeCoverage(new AvalonEditTextEditorAdapter(textEditor), fileName); CodeCoverageService.ShowCodeCoverage(new AvalonEditTextEditorAdapter(textEditor), fileName);
} }

9
src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Views/ProfilerView.xaml.cs

@ -106,9 +106,12 @@ namespace ICSharpCode.Profiler.AddIn.Views
Dispatcher.Invoke( Dispatcher.Invoke(
(Action)( (Action)(
() => { () => {
WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); var tasks = errors.Select(error => new Task(null, error.ErrorText, error.Column, error.Line, (error.IsWarning) ? TaskType.Warning : TaskType.Error)).ToList();
TaskService.ClearExceptCommentTasks(); if (tasks.Count > 0) {
TaskService.AddRange(errors.Select(error => new Task(null, error.ErrorText, error.Column, error.Line, (error.IsWarning) ? TaskType.Warning : TaskType.Error))); WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
TaskService.ClearExceptCommentTasks();
TaskService.AddRange(tasks);
}
} }
) )
); );

42
src/AddIns/Analysis/Profiler/Hook/Profiler.Rewriting.cpp

@ -194,10 +194,6 @@ int CProfiler::SetInjectionCode(IMetaDataImport *metaData, byte *buffer, int *si
buffer[(*size)++] = 0x14; //ldnull buffer[(*size)++] = 0x14; //ldnull
break; break;
case 2: // Windows Forms case 2: // Windows Forms
buffer[(*size)++] = 0x14; //ldnull
buffer[(*size)++] = 0x14; //ldnull
break;
/*
hr = metaData->FindTypeDefByName(L"System.Windows.Forms.Control", nullptr, &controlType); hr = metaData->FindTypeDefByName(L"System.Windows.Forms.Control", nullptr, &controlType);
if (!SUCCEEDED(hr) || controlType == 0) { if (!SUCCEEDED(hr) || controlType == 0) {
@ -234,7 +230,7 @@ int CProfiler::SetInjectionCode(IMetaDataImport *metaData, byte *buffer, int *si
buffer[(*size)++] = 0x6F; //callvirt buffer[(*size)++] = 0x6F; //callvirt
*(mdMethodDef*)(&buffer[*size]) = getTextToken; *(mdMethodDef*)(&buffer[*size]) = getTextToken;
*size += sizeof(getTextToken); *size += sizeof(getTextToken);
break;*/ break;
case 3: // WPF case 3: // WPF
buffer[(*size)++] = 0x14; //ldnull buffer[(*size)++] = 0x14; //ldnull
buffer[(*size)++] = 0x14; //ldnull buffer[(*size)++] = 0x14; //ldnull
@ -318,6 +314,42 @@ STDMETHODIMP CProfiler::ModuleLoadFinished(ModuleID moduleID, HRESULT /*hrStatus
IMetaDataEmit *pIMetaDataEmit = nullptr; IMetaDataEmit *pIMetaDataEmit = nullptr;
IMetaDataAssemblyImport *asmMetaData = nullptr; IMetaDataAssemblyImport *asmMetaData = nullptr;
WCHAR moduleName[NAME_BUFFER_SIZE];
WCHAR assemblyName[NAME_BUFFER_SIZE];
AssemblyID assemblyID;
ULONG actualLen = 0;
hr = pICorProfilerInfo->GetModuleInfo(moduleID, nullptr, NAME_BUFFER_SIZE, &actualLen, moduleName, &assemblyID);
if (!SUCCEEDED(hr))
goto CLEANUP;
hr = pICorProfilerInfo->GetAssemblyInfo(assemblyID, NAME_BUFFER_SIZE, &actualLen, assemblyName, nullptr, nullptr);
if (!SUCCEEDED(hr))
goto CLEANUP;
DebugWriteLine(L"\n----------------- Module Load finished -----------------\n");
DebugWriteLine(L"Module Name: '%s'\n", moduleName);
DebugWriteLine(L"Assembly Name: '%s'\n", assemblyName);
DebugWriteLine(L"--------------------------------------------------------\n");
bool found = false;
for (int i = 0; i < ASSEMBLY_INJECTION_NAME_LIST_LENGTH; i++) {
if (wcscmp(assemblyInjectionNameList[i], assemblyName) == 0) {
found = true;
break;
}
}
if (!found) {
DebugWriteLine(L"Assembly Name '%s' not found in list!\n", assemblyName);
goto CLEANUP;
}
hr = pICorProfilerInfo->GetModuleMetaData(moduleID, ofRead | ofWrite, IID_IMetaDataEmit, (LPUNKNOWN *) &pIMetaDataEmit); hr = pICorProfilerInfo->GetModuleMetaData(moduleID, ofRead | ofWrite, IID_IMetaDataEmit, (LPUNKNOWN *) &pIMetaDataEmit);
if (!SUCCEEDED(hr) || pIMetaDataEmit == nullptr) if (!SUCCEEDED(hr) || pIMetaDataEmit == nullptr)

2
src/AddIns/Analysis/Profiler/Hook/Profiler.cpp

@ -378,7 +378,7 @@ HRESULT CProfiler::SetEventMask() {
COR_PRF_MONITOR_FUNCTION_UNLOADS | COR_PRF_MONITOR_CLR_EXCEPTIONS | COR_PRF_MONITOR_FUNCTION_UNLOADS | COR_PRF_MONITOR_CLR_EXCEPTIONS |
COR_PRF_MONITOR_EXCEPTIONS; COR_PRF_MONITOR_EXCEPTIONS;
if (sharedMemoryHeader->trackEvents) if (sharedMemoryHeader->trackEvents)
eventMask = eventMask | COR_PRF_MONITOR_MODULE_LOADS/* | COR_PRF_MONITOR_JIT_COMPILATION*/; eventMask = eventMask | COR_PRF_MONITOR_MODULE_LOADS | COR_PRF_MONITOR_JIT_COMPILATION;
return pICorProfilerInfo->SetEventMask(eventMask); return pICorProfilerInfo->SetEventMask(eventMask);
} }

15
src/AddIns/Analysis/Profiler/Hook/constants.cpp

@ -3,17 +3,22 @@
#include "global.h" #include "global.h"
WCHAR *assemblyInjectionNameList[ASSEMBLY_INJECTION_NAME_LIST_LENGTH] = {
L"mscorlib",
L"System.Windows.Forms",
L"PresentationCore"
};
WCHAR *consoleGroupList[CONSOLE_GROUP_LENGTH] = { WCHAR *consoleGroupList[CONSOLE_GROUP_LENGTH] = {
L"System.Console.Write", L"System.Console.Write",
L"System.Console.WriteLine" L"System.Console.WriteLine"
}; };
WCHAR *winFormsGroupList[WINFORMS_GROUP_LENGTH] = { WCHAR *winFormsGroupList[WINFORMS_GROUP_LENGTH] = {
L"-------------------------------------------------", L"System.Windows.Forms.Control.OnClick",
// L"System.Windows.Forms.Control.OnClick", L"System.Windows.Forms.Control.OnDoubleClick",
// L"System.Windows.Forms.Control.OnDoubleClick", L"System.Windows.Forms.Control.OnMouseWheel",
// L"System.Windows.Forms.Control.OnMouseWheel", L"System.Windows.Forms.Control.OnKeyDown"
// L"System.Windows.Forms.Control.OnKeyDown"
}; };
WCHAR *wpfGroupList[WPF_GROUP_LENGTH] = { WCHAR *wpfGroupList[WPF_GROUP_LENGTH] = {

6
src/AddIns/Analysis/Profiler/Hook/global.h

@ -10,8 +10,11 @@
#include "LightweightStack.h" #include "LightweightStack.h"
#include "LightweightList.h" #include "LightweightList.h"
#define NAME_BUFFER_SIZE 1024
#define ASSEMBLY_INJECTION_NAME_LIST_LENGTH 3
#define CONSOLE_GROUP_LENGTH 2 #define CONSOLE_GROUP_LENGTH 2
#define WINFORMS_GROUP_LENGTH 1 #define WINFORMS_GROUP_LENGTH 4
#define WPF_GROUP_LENGTH 1 #define WPF_GROUP_LENGTH 1
extern fastAllocator stackAllocator; extern fastAllocator stackAllocator;
@ -21,6 +24,7 @@ extern HANDLE listMutex;
extern LightweightList *allThreadLocalDatas; extern LightweightList *allThreadLocalDatas;
extern DWORD tls_index; extern DWORD tls_index;
extern WCHAR *assemblyInjectionNameList[ASSEMBLY_INJECTION_NAME_LIST_LENGTH];
extern WCHAR *consoleGroupList[CONSOLE_GROUP_LENGTH]; extern WCHAR *consoleGroupList[CONSOLE_GROUP_LENGTH];
extern WCHAR *winFormsGroupList[WINFORMS_GROUP_LENGTH]; extern WCHAR *winFormsGroupList[WINFORMS_GROUP_LENGTH];
extern WCHAR *wpfGroupList[WPF_GROUP_LENGTH]; extern WCHAR *wpfGroupList[WPF_GROUP_LENGTH];

68
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs

@ -22,15 +22,22 @@ namespace ICSharpCode.AvalonEdit.AddIn
public class CaretReferencesRenderer public class CaretReferencesRenderer
{ {
/// <summary> /// <summary>
/// Delays the highlighting after the caret position changes, so that Find references does not get called too often. /// Delays the Resolve check so that it does not get called too often when user holds an arrow.
/// </summary>
DispatcherTimer delayMoveTimer;
const int delayMoveMs = 100;
/// <summary>
/// Delays the Find references (and highlight) after the caret stays at one point for a while.
/// </summary> /// </summary>
DispatcherTimer delayTimer; DispatcherTimer delayTimer;
const int delayMilliseconds = 800; const int delayMs = 800;
/// <summary> /// <summary>
/// Delays the Resolve check so that it does not get called too often when user holds an arrow. /// Maximum time for Find references. After this time it gets cancelled and no highlight is displayed.
/// Useful for very large files.
/// </summary> /// </summary>
DispatcherTimer delayMoveTimer; const int findReferencesTimeoutMs = 200;
const int delayMoveMilliseconds = 100;
CodeEditorView editorView; CodeEditorView editorView;
ITextEditor Editor { get { return editorView.Adapter; } } ITextEditor Editor { get { return editorView.Adapter; } }
@ -53,10 +60,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
this.editorView = editorView; this.editorView = editorView;
this.highlightRenderer = new ExpressionHighlightRenderer(this.editorView.TextArea.TextView); this.highlightRenderer = new ExpressionHighlightRenderer(this.editorView.TextArea.TextView);
this.delayTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(delayMilliseconds) }; this.delayTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(delayMs) };
this.delayTimer.Stop(); this.delayTimer.Stop();
this.delayTimer.Tick += TimerTick; this.delayTimer.Tick += TimerTick;
this.delayMoveTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(delayMoveMilliseconds) }; this.delayMoveTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(delayMoveMs) };
this.delayMoveTimer.Stop(); this.delayMoveTimer.Stop();
this.delayMoveTimer.Tick += TimerMoveTick; this.delayMoveTimer.Tick += TimerMoveTick;
this.editorView.TextArea.Caret.PositionChanged += CaretPositionChanged; this.editorView.TextArea.Caret.PositionChanged += CaretPositionChanged;
@ -67,13 +74,23 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.highlightRenderer.ClearHighlight(); this.highlightRenderer.ClearHighlight();
} }
/// <summary>
/// In the current document, highlights all references to the expression
/// which is currently under the caret (local variable, class, property).
/// This gets called on every caret position change, so quite often.
/// </summary>
void CaretPositionChanged(object sender, EventArgs e)
{
Restart(this.delayMoveTimer);
}
void TimerTick(object sender, EventArgs e) void TimerTick(object sender, EventArgs e)
{ {
this.delayTimer.Stop(); this.delayTimer.Stop();
if (!IsEnabled) if (!IsEnabled)
return; return;
var referencesToBeHighlighted = GetReferencesInCurrentFile(this.lastResolveResult); var referencesToBeHighlighted = FindReferencesInCurrentFile(this.lastResolveResult);
this.highlightRenderer.SetHighlight(referencesToBeHighlighted); this.highlightRenderer.SetHighlight(referencesToBeHighlighted);
} }
@ -85,9 +102,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (!IsEnabled) if (!IsEnabled)
return; return;
var resolveResult = GetExpressionUnderCaret(); var resolveResult = GetExpressionAtCaret();
if (resolveResult == null) { if (resolveResult == null) {
this.lastResolveResult = resolveResult; this.lastResolveResult = null;
this.highlightRenderer.ClearHighlight(); this.highlightRenderer.ClearHighlight();
return; return;
} }
@ -97,25 +114,16 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.lastResolveResult = resolveResult; this.lastResolveResult = resolveResult;
this.highlightRenderer.ClearHighlight(); this.highlightRenderer.ClearHighlight();
this.delayTimer.Start(); this.delayTimer.Start();
} else {
// highlight stays the same, both timers are stopped (will start again when caret moves)
} }
} }
/// <summary>
/// In the current document, highlights all references to the expression
/// which is currently under the caret (local variable, class, property).
/// This gets called on every caret position change, so quite often.
/// </summary>
void CaretPositionChanged(object sender, EventArgs e)
{
this.delayMoveTimer.Stop();
this.delayMoveTimer.Start();
}
/// <summary> /// <summary>
/// Resolves the current expression under caret. /// Resolves the current expression under caret.
/// This gets called on every caret position change, so quite often. /// This gets called on every caret position change, so quite often.
/// </summary> /// </summary>
ResolveResult GetExpressionUnderCaret() ResolveResult GetExpressionAtCaret()
{ {
if (string.IsNullOrEmpty(Editor.FileName) || ParserService.LoadSolutionProjectsThreadRunning) if (string.IsNullOrEmpty(Editor.FileName) || ParserService.LoadSolutionProjectsThreadRunning)
return null; return null;
@ -127,14 +135,14 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// <summary> /// <summary>
/// Finds references to resolved expression in the current file. /// Finds references to resolved expression in the current file.
/// </summary> /// </summary>
List<Reference> GetReferencesInCurrentFile(ResolveResult resolveResult) List<Reference> FindReferencesInCurrentFile(ResolveResult resolveResult)
{ {
var cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenSource = new CancellationTokenSource();
using (new Timer( using (new Timer(
delegate { delegate {
LoggingService.Debug("Aborting GetReferencesInCurrentFile due to timeout"); LoggingService.Debug("Aborting FindReferencesInCurrentFile due to timeout");
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
}, null, 200, Timeout.Infinite)) }, null, findReferencesTimeoutMs, Timeout.Infinite))
{ {
var progressMonitor = new DummyProgressMonitor(); var progressMonitor = new DummyProgressMonitor();
progressMonitor.CancellationToken = cancellationTokenSource.Token; progressMonitor.CancellationToken = cancellationTokenSource.Token;
@ -147,6 +155,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// <summary> /// <summary>
/// Returns true if the 2 ResolveResults refer to the same symbol. /// Returns true if the 2 ResolveResults refer to the same symbol.
/// So that when caret moves but stays inside the same symbol, symbol stays highlighted.
/// </summary> /// </summary>
bool SameResolveResult(ResolveResult resolveResult, ResolveResult resolveResult2) bool SameResolveResult(ResolveResult resolveResult, ResolveResult resolveResult2)
{ {
@ -159,5 +168,14 @@ namespace ICSharpCode.AvalonEdit.AddIn
// TODO determine if 2 ResolveResults refer to the same symbol // TODO determine if 2 ResolveResults refer to the same symbol
return false; return false;
} }
/// <summary>
/// Restarts a timer.
/// </summary>
void Restart(DispatcherTimer timer)
{
timer.Stop();
timer.Start();
}
} }
} }

5
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -1102,6 +1102,11 @@ namespace ICSharpCode.AvalonEdit
TextView textView = textArea.TextView; TextView textView = textArea.TextView;
TextDocument document = textView.Document; TextDocument document = textView.Document;
if (scrollViewer != null && document != null) { if (scrollViewer != null && document != null) {
if (line < 1)
line = 1;
if (line > document.LineCount)
line = document.LineCount;
IScrollInfo scrollInfo = textView; IScrollInfo scrollInfo = textView;
if (!scrollInfo.CanHorizontallyScroll) { if (!scrollInfo.CanHorizontallyScroll) {
// Word wrap is enabled. Ensure that we have up-to-date info about line height so that we scroll // Word wrap is enabled. Ensure that we have up-to-date info about line height so that we scroll

18
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs

@ -18,6 +18,9 @@ namespace ICSharpCode.SharpDevelop.Refactoring
{ {
private static ContextActionsService instance = new ContextActionsService(); private static ContextActionsService instance = new ContextActionsService();
/// <summary>
/// Key for storing the names of disabled providers in PropertyService.
/// </summary>
const string PropertyServiceKey = "DisabledContextActionProviders"; const string PropertyServiceKey = "DisabledContextActionProviders";
public static ContextActionsService Instance { public static ContextActionsService Instance {
@ -71,6 +74,10 @@ namespace ICSharpCode.SharpDevelop.Refactoring
throw new ArgumentNullException("providers"); throw new ArgumentNullException("providers");
this.editor = editor; this.editor = editor;
this.providers = providers; this.providers = providers;
// DO NOT USE Wait on the main thread!
// causes deadlocks!
// parseTask.Wait();
// Reparse so that we have up-to-date DOM.
ParserService.ParseCurrentViewContent(); ParserService.ParseCurrentViewContent();
this.EditorContext = new EditorContext(editor); this.EditorContext = new EditorContext(editor);
} }
@ -106,23 +113,14 @@ namespace ICSharpCode.SharpDevelop.Refactoring
{ {
if (ParserService.LoadSolutionProjectsThreadRunning) if (ParserService.LoadSolutionProjectsThreadRunning)
yield break; yield break;
// DO NOT USE Wait on the main thread!
// causes deadlocks!
//parseTask.Wait();
var sw = new Stopwatch(); sw.Start();
var editorContext = new EditorContext(this.editor);
long elapsedEditorContextMs = sw.ElapsedMilliseconds;
// could run providers in parallel // could run providers in parallel
foreach (var provider in providers) { foreach (var provider in providers) {
foreach (var action in provider.GetAvailableActions(editorContext)) { foreach (var action in provider.GetAvailableActions(this.EditorContext)) {
providerForAction[action] = provider; providerForAction[action] = provider;
yield return action; yield return action;
} }
} }
// ICSharpCode.Core.LoggingService.Debug(string.Format("Context actions elapsed {0}ms ({1}ms in EditorContext)",
// sw.ElapsedMilliseconds, elapsedEditorContextMs));
} }
} }
} }

2
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs

@ -247,7 +247,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
ExpressionResult GetExpressionAt(ITextEditor editor, int caretLine, int caretColumn) ExpressionResult GetExpressionAt(ITextEditor editor, int caretLine, int caretColumn)
{ {
ExpressionResult expr = ParserService.FindFullExpression(caretLine, caretColumn, editor.Document, editor.FileName); ExpressionResult expr = ParserService.FindFullExpression(caretLine, caretColumn, editor.Document, editor.FileName);
// if no expression, look one character back (works better with method calls - Foo()(*caret*)) // if no expression, look one character back (works better with method calls, e.g. Foo()(*caret*))
if (string.IsNullOrWhiteSpace(expr.Expression) && caretColumn > 1) if (string.IsNullOrWhiteSpace(expr.Expression) && caretColumn > 1)
expr = ParserService.FindFullExpression(caretLine, caretColumn - 1, editor.Document, editor.FileName); expr = ParserService.FindFullExpression(caretLine, caretColumn - 1, editor.Document, editor.FileName);
return expr; return expr;

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

@ -815,7 +815,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return GetNamespaces(language).ContainsKey(name); return GetNamespaces(language).ContainsKey(name);
} }
bool MatchesRequest(ref SearchTypeRequest request, ref SearchTypeResult result) bool MatchesRequest(SearchTypeRequest request, ref SearchTypeResult result)
{ {
if (result.NamespaceResult != null) if (result.NamespaceResult != null)
return request.TypeParameterCount == 0; return request.TypeParameterCount == 0;
@ -852,7 +852,7 @@ namespace ICSharpCode.SharpDevelop.Dom
foreach (IClass innerClass in baseClass.InnerClasses) { foreach (IClass innerClass in baseClass.InnerClasses) {
if (language.NameComparer.Equals(innerClass.Name, name)) { if (language.NameComparer.Equals(innerClass.Name, name)) {
result = new SearchTypeResult(innerClass); result = new SearchTypeResult(innerClass);
if (MatchesRequest(ref request, ref result)) { if (MatchesRequest(request, ref result)) {
return result; return result;
} }
} }
@ -873,50 +873,55 @@ namespace ICSharpCode.SharpDevelop.Dom
IClass c = GetClass(fullname, request.TypeParameterCount); IClass c = GetClass(fullname, request.TypeParameterCount);
if (c != null) { if (c != null) {
result = new SearchTypeResult(c); result = new SearchTypeResult(c);
if (MatchesRequest(ref request, ref result)) { if (MatchesRequest(request, ref result)) {
return result; return result;
} }
} }
if (NamespaceExists(fullname)) { if (NamespaceExists(fullname)) {
result = new SearchTypeResult(fullname, null); result = new SearchTypeResult(fullname, null);
if (MatchesRequest(ref request, ref result)) { if (MatchesRequest(request, ref result)) {
return result; return result;
} }
} }
// prefer aliases over imported types
foreach (IUsing u in usingScope.Usings) { foreach (IUsing u in usingScope.Usings) {
foreach (IReturnType r in u.SearchType(name, request.TypeParameterCount)) { if (u.HasAliases) {
result = new SearchTypeResult(r, u); if (SearchTypeInUsing(u, request, ref result))
if (MatchesRequest(ref request, ref result)) {
return result; return result;
}
} }
string nsResult = u.SearchNamespace(name); }
if (nsResult != null) { foreach (IUsing u in usingScope.Usings) {
result = new SearchTypeResult(nsResult, null); if (!u.HasAliases) {
if (MatchesRequest(ref request, ref result)) { if (SearchTypeInUsing(u, request, ref result))
return result; return result;
}
} }
} }
} }
if (defaultImports != null) { if (defaultImports != null) {
foreach (IReturnType r in defaultImports.SearchType(name, request.TypeParameterCount)) { if (SearchTypeInUsing(defaultImports, request, ref result));
result = new SearchTypeResult(r, defaultImports); return result;
if (MatchesRequest(ref request, ref result)) { }
return result; return result;
} }
bool SearchTypeInUsing(IUsing u, SearchTypeRequest request, ref SearchTypeResult result)
{
foreach (IReturnType r in u.SearchType(request.Name, request.TypeParameterCount)) {
result = new SearchTypeResult(r, u);
if (MatchesRequest(request, ref result)) {
return true;
} }
string nsResult = defaultImports.SearchNamespace(name); }
if (nsResult != null) { string nsResult = u.SearchNamespace(request.Name);
result = new SearchTypeResult(nsResult, null); if (nsResult != null) {
if (MatchesRequest(ref request, ref result)) { result = new SearchTypeResult(nsResult, null);
return result; if (MatchesRequest(request, ref result)) {
} return true;
} }
} }
return result; return false;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save