Author: lluis
Date: 2007-09-07 15:21:08 -0400 (Fri, 07 Sep 2007)
New Revision: 85499
Added:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
Log:
* MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs,
MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs,
MonoDevelop.Ide.mdp, Makefile.am: Split TextEditorExtension in two.
All code related to code completion has been moved to the new
subclass CompletionTextEditorExtension.
* MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs:
Fix warning.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog 2007-09-07
19:12:29 UTC (rev 85498)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog 2007-09-07
19:21:08 UTC (rev 85499)
@@ -1,5 +1,15 @@
2007-09-07 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+ * MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs,
+ MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs,
MonoDevelop.Ide.mdp,
+ Makefile.am: Split TextEditorExtension in two. All code related to
code
+ completion has been moved to the new subclass
+ CompletionTextEditorExtension.
+ * MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs:
Fix
+ warning.
+
+2007-09-07 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
* MonoDevelop.Ide.Gui.Dialogs/ReplaceInFilesDialog.cs: Set the correct
title
when not in replace mode. Fixes bug #82698.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am 2007-09-07
19:12:29 UTC (rev 85498)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am 2007-09-07
19:21:08 UTC (rev 85499)
@@ -106,6 +106,7 @@
MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs \
MonoDevelop.Ide.Gui.BrowserDisplayBinding/HTMLInterfaces.cs \
MonoDevelop.Ide.Gui.BrowserDisplayBinding/HtmlViewPane.cs \
+ MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs \
MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs \
MonoDevelop.Ide.Gui.Content/IClipboardHandler.cs \
MonoDevelop.Ide.Gui.Content/ICodeStyleOperations.cs \
Added:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs
2007-09-07 19:12:29 UTC (rev 85498)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs
2007-09-07 19:21:08 UTC (rev 85499)
@@ -0,0 +1,212 @@
+// CompletionTextEditorExtension.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+
+using System;
+using MonoDevelop.Projects;
+using MonoDevelop.Projects.Gui.Completion;
+using MonoDevelop.Projects.Parser;
+using MonoDevelop.Projects.Ambience;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Ide.Commands;
+
+namespace MonoDevelop.Ide.Gui.Content
+{
+ public class CompletionTextEditorExtension: TextEditorExtension
+ {
+ CodeCompletionContext currentCompletionContext;
+ ICompletionWidget completionWidget;
+ bool autoHideCompletionWindow = true;
+
+ // When a key is pressed, and before the key is processed by
the editor, this method will be invoked.
+ // Return true if the key press should be processed by the
editor.
+ public override bool KeyPress (Gdk.Key key, Gdk.ModifierType
modifier)
+ {
+ bool res;
+
+ if (currentCompletionContext != null) {
+ autoHideCompletionWindow = false;
+ if (CompletionListWindow.ProcessKeyEvent (key,
modifier)) {
+ autoHideCompletionWindow = true;
+ return true;
+ }
+ autoHideCompletionWindow = false;
+ }
+
+ if (ParameterInformationWindowManager.IsWindowVisible) {
+ if
(ParameterInformationWindowManager.ProcessKeyEvent (key, modifier))
+ return true;
+ autoHideCompletionWindow = false;
+ }
+
+ res = base.KeyPress (key, modifier);
+
+ // Handle code completion
+
+ if (completionWidget != null &&
currentCompletionContext == null) {
+ currentCompletionContext =
completionWidget.CreateCodeCompletionContext (Editor.CursorPosition);
+ ICompletionDataProvider cp =
HandleCodeCompletion (currentCompletionContext, (char)(uint)key);
+
+ if (cp != null)
+ CompletionListWindow.ShowWindow
((char)(uint)key, cp, completionWidget, currentCompletionContext,
OnCompletionWindowClosed);
+ else
+ currentCompletionContext = null;
+ }
+
+ // Handle parameter completion
+
+ if (ParameterInformationWindowManager.IsWindowVisible)
+
ParameterInformationWindowManager.PostProcessKeyEvent (key, modifier);
+
+ if (completionWidget != null) {
+ ICodeCompletionContext ctx =
completionWidget.CreateCodeCompletionContext (Editor.CursorPosition);
+ IParameterDataProvider paramProvider =
HandleParameterCompletion (ctx, (char)(uint)key);
+ if (paramProvider != null)
+
ParameterInformationWindowManager.ShowWindow (ctx, paramProvider);
+ }
+
+ autoHideCompletionWindow = true;
+
+ return res;
+ }
+
+ void OnCompletionWindowClosed ()
+ {
+ currentCompletionContext = null;
+ }
+
+ void OnCompletionContextChanged (object o, EventArgs a)
+ {
+ if (autoHideCompletionWindow) {
+ if (currentCompletionContext != null)
+ CompletionListWindow.HideWindow ();
+ ParameterInformationWindowManager.HideWindow ();
+ }
+ }
+
+ [CommandUpdateHandler (TextEditorCommands.ShowCompletionWindow)]
+ internal void OnUpdateCompletionCommand (CommandInfo info)
+ {
+ info.Bypass = !CanRunCompletionCommand ();
+ }
+
+ [CommandHandler (TextEditorCommands.ShowCompletionWindow)]
+ public virtual void RunCompletionCommand ()
+ {
+ ICompletionDataProvider cp = null;
+ int cpos, wlen;
+ if (!GetCompletionCommandOffset (out cpos, out wlen)) {
+ cpos = Editor.CursorPosition;
+ wlen = 0;
+ }
+ currentCompletionContext =
completionWidget.CreateCodeCompletionContext (cpos);
+ currentCompletionContext.TriggerWordLength = wlen;
+ cp = CodeCompletionCommand (currentCompletionContext);
+
+ if (cp != null)
+ CompletionListWindow.ShowWindow ((char)0, cp,
completionWidget, currentCompletionContext, OnCompletionWindowClosed);
+ else
+ currentCompletionContext = null;
+ }
+
+ public virtual bool CanRunCompletionCommand ()
+ {
+ return (completionWidget != null &&
currentCompletionContext == null);
+ }
+
+ public virtual ICompletionDataProvider HandleCodeCompletion
(ICodeCompletionContext completionContext, char completionChar)
+ {
+ return null;
+ }
+
+ public virtual IParameterDataProvider HandleParameterCompletion
(ICodeCompletionContext completionContext, char completionChar)
+ {
+ return null;
+ }
+
+ // return -1 if completion can't be shown
+ public virtual bool GetCompletionCommandOffset (out int cpos,
out int wlen)
+ {
+ cpos = wlen = 0;
+ int pos = Editor.CursorPosition - 1;
+ while (pos >= 0) {
+ char c = Editor.GetCharAt (pos);
+ if (!char.IsLetterOrDigit (c) && c != '_')
+ break;
+ pos--;
+ }
+ if (pos == -1)
+ return false;
+
+ pos++;
+ cpos = pos;
+ int len = Editor.TextLength;
+
+ while (pos < len) {
+ char c = Editor.GetCharAt (pos);
+ if (!char.IsLetterOrDigit (c) && c != '_')
+ break;
+ pos++;
+ }
+ wlen = pos - cpos;
+ return true;
+ }
+
+ public virtual ICompletionDataProvider CodeCompletionCommand
(ICodeCompletionContext completionContext)
+ {
+ // This default implementation of CodeCompletionCommand
calls HandleCodeCompletion providing
+ // the char at the cursor position. If it returns a
provider, just return it.
+
+ int pos = completionContext.TriggerOffset;
+ string txt = Editor.GetText (pos - 1, pos);
+ if (txt.Length > 0) {
+ ICompletionDataProvider cp =
HandleCodeCompletion (completionContext, txt[0]);
+ if (cp != null)
+ return cp;
+ }
+
+ // If there is a parser context, try resolving by
calling CtrlSpace.
+ IParserContext ctx = GetParserContext();
+ if (ctx != null) {
+ CodeCompletionDataProvider completionProvider =
new CodeCompletionDataProvider (ctx, GetAmbience ());
+ completionProvider.AddResolveResults
(ctx.CtrlSpace (completionContext.TriggerLine + 1,
completionContext.TriggerLineOffset + 1, FileName));
+ if (!completionProvider.IsEmpty)
+ return completionProvider;
+ }
+ return null;
+ }
+
+ public override void Initialize ()
+ {
+ base.Initialize ();
+
+ completionWidget = Document.GetContent
<ICompletionWidget> ();
+ if (completionWidget != null)
+ completionWidget.CompletionContextChanged +=
OnCompletionContextChanged;
+ }
+ }
+}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
2007-09-07 19:12:29 UTC (rev 85498)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
2007-09-07 19:21:08 UTC (rev 85499)
@@ -1,4 +1,31 @@
+// TextEditorExtension.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
using System;
using MonoDevelop.Projects;
using MonoDevelop.Projects.Gui.Completion;
@@ -13,16 +40,10 @@
{
internal ITextEditorExtension Next;
internal Document document;
- CodeCompletionContext currentCompletionContext;
- ICompletionWidget completionWidget;
- bool autoHideCompletionWindow = true;
internal void Initialize (Document document)
{
this.document = document;
- completionWidget = document.GetContent
<ICompletionWidget> ();
- if (completionWidget != null)
- completionWidget.CompletionContextChanged +=
OnCompletionContextChanged;
Initialize ();
}
@@ -82,70 +103,12 @@
{
CheckInitialized ();
- bool res;
-
- if (currentCompletionContext != null) {
- autoHideCompletionWindow = false;
- if (CompletionListWindow.ProcessKeyEvent (key,
modifier)) {
- autoHideCompletionWindow = true;
- return true;
- }
- autoHideCompletionWindow = false;
- }
-
- if (ParameterInformationWindowManager.IsWindowVisible) {
- if
(ParameterInformationWindowManager.ProcessKeyEvent (key, modifier))
- return true;
- autoHideCompletionWindow = false;
- }
-
if (Next == null)
- res = true;
+ return true;
else
- res = Next.KeyPress (key, modifier);
-
- // Handle code completion
-
- if (completionWidget != null &&
currentCompletionContext == null) {
- currentCompletionContext =
completionWidget.CreateCodeCompletionContext (Editor.CursorPosition);
- ICompletionDataProvider cp =
HandleCodeCompletion (currentCompletionContext, (char)(uint)key);
-
- if (cp != null)
- CompletionListWindow.ShowWindow
((char)(uint)key, cp, completionWidget, currentCompletionContext,
OnCompletionWindowClosed);
- else
- currentCompletionContext = null;
- }
-
- // Handle parameter completion
-
- if (ParameterInformationWindowManager.IsWindowVisible)
-
ParameterInformationWindowManager.PostProcessKeyEvent (key, modifier);
-
- if (completionWidget != null) {
- ICodeCompletionContext ctx =
completionWidget.CreateCodeCompletionContext (Editor.CursorPosition);
- IParameterDataProvider paramProvider =
HandleParameterCompletion (ctx, (char)(uint)key);
- if (paramProvider != null)
-
ParameterInformationWindowManager.ShowWindow (ctx, paramProvider);
- }
-
- autoHideCompletionWindow = true;
-
- return res;
+ return Next.KeyPress (key, modifier);
}
- void OnCompletionWindowClosed ()
- {
- currentCompletionContext = null;
- }
-
- void OnCompletionContextChanged (object o, EventArgs a)
- {
- if (autoHideCompletionWindow) {
- CompletionListWindow.HideWindow ();
- ParameterInformationWindowManager.HideWindow ();
- }
- }
-
public virtual void CursorPositionChanged ()
{
CheckInitialized ();
@@ -154,98 +117,6 @@
Next.CursorPositionChanged ();
}
- [CommandUpdateHandler (TextEditorCommands.ShowCompletionWindow)]
- internal void OnUpdateCompletionCommand (CommandInfo info)
- {
- info.Bypass = !CanRunCompletionCommand ();
- }
-
- [CommandHandler (TextEditorCommands.ShowCompletionWindow)]
- public virtual void RunCompletionCommand ()
- {
- ICompletionDataProvider cp = null;
- int cpos, wlen;
- if (!GetCompletionCommandOffset (out cpos, out wlen)) {
- cpos = Editor.CursorPosition;
- wlen = 0;
- }
- currentCompletionContext =
completionWidget.CreateCodeCompletionContext (cpos);
- currentCompletionContext.TriggerWordLength = wlen;
- cp = CodeCompletionCommand (currentCompletionContext);
-
- if (cp != null)
- CompletionListWindow.ShowWindow ((char)0, cp,
completionWidget, currentCompletionContext, OnCompletionWindowClosed);
- else
- currentCompletionContext = null;
- }
-
- public virtual bool CanRunCompletionCommand ()
- {
- return (completionWidget != null &&
currentCompletionContext == null);
- }
-
- public virtual ICompletionDataProvider HandleCodeCompletion
(ICodeCompletionContext completionContext, char completionChar)
- {
- return null;
- }
-
- public virtual IParameterDataProvider HandleParameterCompletion
(ICodeCompletionContext completionContext, char completionChar)
- {
- return null;
- }
-
- // return -1 if completion can't be shown
- public virtual bool GetCompletionCommandOffset (out int cpos,
out int wlen)
- {
- cpos = wlen = 0;
- int pos = Editor.CursorPosition - 1;
- while (pos >= 0) {
- char c = Editor.GetCharAt (pos);
- if (!char.IsLetterOrDigit (c) && c != '_')
- break;
- pos--;
- }
- if (pos == -1)
- return false;
-
- pos++;
- cpos = pos;
- int len = Editor.TextLength;
-
- while (pos < len) {
- char c = Editor.GetCharAt (pos);
- if (!char.IsLetterOrDigit (c) && c != '_')
- break;
- pos++;
- }
- wlen = pos - cpos;
- return true;
- }
-
- public virtual ICompletionDataProvider CodeCompletionCommand
(ICodeCompletionContext completionContext)
- {
- // This default implementation of CodeCompletionCommand
calls HandleCodeCompletion providing
- // the char at the cursor position. If it returns a
provider, just return it.
-
- int pos = completionContext.TriggerOffset;
- string txt = Editor.GetText (pos - 1, pos);
- if (txt.Length > 0) {
- ICompletionDataProvider cp =
HandleCodeCompletion (completionContext, txt[0]);
- if (cp != null)
- return cp;
- }
-
- // If there is a parser context, try resolving by
calling CtrlSpace.
- IParserContext ctx = GetParserContext();
- if (ctx != null) {
- CodeCompletionDataProvider completionProvider =
new CodeCompletionDataProvider (ctx, GetAmbience ());
- completionProvider.AddResolveResults
(ctx.CtrlSpace (completionContext.TriggerLine + 1,
completionContext.TriggerLineOffset + 1, FileName));
- if (!completionProvider.IsEmpty)
- return completionProvider;
- }
- return null;
- }
-
public virtual void Initialize ()
{
CheckInitialized ();
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
2007-09-07 19:12:29 UTC (rev 85498)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/CodeTranslationFileDescriptionTemplate.cs
2007-09-07 19:21:08 UTC (rev 85499)
@@ -91,7 +91,7 @@
using (StringReader sr = new StringReader
(tempSubstitutedContent)) {
try {
ccu = parserProvider.Parse (sr);
- } catch (NotImplementedException nie) {
+ } catch (NotImplementedException) {
throw new InvalidOperationException
("Invalid Code Translation template: the CodeDomProvider of the source language
'"
+
language + "' has not implemented the Parse method.");
}
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2007-09-07 19:12:29 UTC (rev 85498)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2007-09-07 19:21:08 UTC (rev 85499)
@@ -333,6 +333,7 @@
<File name="./MonoDevelop.Ide.Templates/FileTemplateCondition.cs"
subtype="Code" buildaction="Compile" />
<File
name="./MonoDevelop.Ide.Templates/PartialTypeFileTemplateCondition.cs"
subtype="Code" buildaction="Compile" />
<File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
+ <File
name="./MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs"
subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="False" refto="gecko-sharp,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=ccf7d78a55e9f021" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches