Author: pjohanson
Date: 2007-02-09 19:17:49 -0500 (Fri, 09 Feb 2007)
New Revision: 72564
Added:
trunk/monodevelop/Extras/BooBinding/Gui/BooTextEditorExtension.boo
Modified:
trunk/monodevelop/Extras/BooBinding/BooBinding.addin.xml
trunk/monodevelop/Extras/BooBinding/ChangeLog
trunk/monodevelop/Extras/BooBinding/Makefile.am
trunk/monodevelop/Extras/BooBinding/Parser/BooParser.boo
trunk/monodevelop/Extras/BooBinding/Parser/Resolver.boo
Log:
2007-02-09 Peter Johanson <[EMAIL PROTECTED]>
* BooBinding.addin.xml:
* Gui/BooTextEditorExtension.boo:
* Makefile.am:
Add new BooTextEditorExtension to start supporting minimal completion
again.
* Parser/BooParser.boo:
* Parser/Resolver.boo:
Beginnings of an implementation of IsAsResolve, needs finishing at
some point.
Modified: trunk/monodevelop/Extras/BooBinding/BooBinding.addin.xml
===================================================================
--- trunk/monodevelop/Extras/BooBinding/BooBinding.addin.xml 2007-02-09
23:20:10 UTC (rev 72563)
+++ trunk/monodevelop/Extras/BooBinding/BooBinding.addin.xml 2007-02-10
00:17:49 UTC (rev 72564)
@@ -71,6 +71,10 @@
class = "BooBinding.BooLanguageBinding" />
</Extension>
+ <Extension path = "/MonoDevelop/Workbench/TextEditorExtensions">
+ <Class class = "BooBinding.Gui.BooTextEditorExtension" />
+ </Extension>
+
<Extension path = "/Workspace/Parser">
<Class id = "BooParser"
class = "BooBinding.Parser.BooParser"/>
Modified: trunk/monodevelop/Extras/BooBinding/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/BooBinding/ChangeLog 2007-02-09 23:20:10 UTC
(rev 72563)
+++ trunk/monodevelop/Extras/BooBinding/ChangeLog 2007-02-10 00:17:49 UTC
(rev 72564)
@@ -1,3 +1,18 @@
+2007-02-09 Peter Johanson <[EMAIL PROTECTED]>
+
+ * BooBinding.addin.xml:
+ * Gui/BooTextEditorExtension.boo:
+ * Makefile.am:
+
+ Add new BooTextEditorExtension to start supporting minimal completion
+ again.
+
+ * Parser/BooParser.boo:
+ * Parser/Resolver.boo:
+
+ Beginnings of an implementation of IsAsResolve, needs finishing at
+ some point.
+
2007-01-29 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* Gui/ShellTextView.boo: Temporarily disabled code completion in the
Added: trunk/monodevelop/Extras/BooBinding/Gui/BooTextEditorExtension.boo
===================================================================
--- trunk/monodevelop/Extras/BooBinding/Gui/BooTextEditorExtension.boo
2007-02-09 23:20:10 UTC (rev 72563)
+++ trunk/monodevelop/Extras/BooBinding/Gui/BooTextEditorExtension.boo
2007-02-10 00:17:49 UTC (rev 72564)
@@ -0,0 +1,91 @@
+#region license
+// Copyright (c) 2007, Peter Johanson ([EMAIL PROTECTED])
+// All rights reserved.
+//
+// BooBinding is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// BooBinding is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with BooBinding; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#endregion
+
+namespace BooBinding.Gui
+
+import System
+
+import MonoDevelop.Projects.Parser
+import MonoDevelop.Ide.Gui.Content
+import MonoDevelop.Projects.Gui.Completion
+
+import BooBinding.Parser
+
+public class BooTextEditorExtension (TextEditorExtension):
+ override def HandleCodeCompletion (ctx as ICodeCompletionContext,
typed_char as System.Char) as ICompletionDataProvider:
+ return null if not typed_char in (char('.'), char(' '))
+
+ expr_finder = ExpressionFinder ()
+
+ caret_line = ctx.TriggerLine + 1;
+ caret_col = ctx.TriggerLineOffset + 1;
+
+ i = ctx.TriggerOffset
+ if find_previous_token ("=", i):
+ p_ctx = GetParserContext ()
+ expr = expr_finder.FindExpression (Editor.GetText (0,
i), i -2).Expression
+ data_provider = CodeCompletionDataProvider (p_ctx,
GetAmbience ())
+
+ resolver = Resolver (p_ctx)
+
+ /*
+ return_type = resolver.internal_resolve (expr,
caret_line, caret_col, FileName, Editor.Text)
+ return null if not return_type
+
+ data_provider.DefaultCompletionString = return_type.Name
+ data_provider.AddResolveResults (resolver.IsAsResolve
(expr, caret_line, caret_col, FileName, Editor.Text))
+
+ klass = p_ctx.GetClass (return_type.FullyQualifiedName,
return_type.GenericArguments)
+ data_provider.AddResolveResults (klass) if klass
+ */
+
+ return data_provider
+
+ expr = expr_finder.FindExpression (Editor.GetText (0,
ctx.TriggerOffset), ctx.TriggerOffset - 2).Expression;
+ return null if not expr
+
+ p_ctx = GetParserContext ()
+ completion_prov = CodeCompletionDataProvider (p_ctx,
GetAmbience ())
+
+ if typed_char == char(' '):
+ if expr in ("is", "as"):
+ expr = expr_finder.FindExpression
(Editor.GetText (0, ctx.TriggerOffset), ctx.TriggerOffset - 5).Expression
+ res = Resolver (p_ctx)
+ completion_prov.AddResolveResults
(res.IsAsResolve (expr, caret_line, caret_col, FileName, Editor.Text, false))
+ elif expr == "import" or expr.EndsWith (" import") or
expr.EndsWith ("\timport") or expr.EndsWith ("\nimport") or expr.EndsWith
("\rimport"):
+ namespaces = p_ctx.GetNamespaceList ("", true,
true)
+ completion_prov.AddResolveResults
(ResolveResult(namespaces))
+ else:
+ resolve_result = p_ctx.Resolve (expr, caret_line,
caret_col, FileName, Editor.Text)
+ completion_prov.AddResolveResults (resolve_result)
+
+ return null if completion_prov.IsEmpty
+
+ return completion_prov
+
+ private def find_previous_token (token as string, ref i as int):
+ s = Editor.GetText (i-1, i)
+ while s.Length > 0 and s[0] in (char(' '), char('\t')):
+ i--
+ s = Editor.GetText (i-1, i)
+
+ return false if s.Length == 0
+
+ i -= token.Length
+ return Editor.GetText (i, i + token.Length) == token
Modified: trunk/monodevelop/Extras/BooBinding/Makefile.am
===================================================================
--- trunk/monodevelop/Extras/BooBinding/Makefile.am 2007-02-09 23:20:10 UTC
(rev 72563)
+++ trunk/monodevelop/Extras/BooBinding/Makefile.am 2007-02-10 00:17:49 UTC
(rev 72564)
@@ -24,6 +24,7 @@
Gui/ShellTextView.boo \
Gui/IShellModel.boo \
Gui/BooShellModel.boo \
+Gui/BooTextEditorExtension.boo \
Gui/OptionPanels/CodeCompilationPanel.boo \
Gui/OptionPanels/GeneralShellPanel.boo \
Gui/OptionPanels/GeneralBooShellPanel.boo \
Modified: trunk/monodevelop/Extras/BooBinding/Parser/BooParser.boo
===================================================================
--- trunk/monodevelop/Extras/BooBinding/Parser/BooParser.boo 2007-02-09
23:20:10 UTC (rev 72563)
+++ trunk/monodevelop/Extras/BooBinding/Parser/BooParser.boo 2007-02-10
00:17:49 UTC (rev 72564)
@@ -149,8 +149,8 @@
//ShowException(e)
return null
- def IsAsResolve (parserContext as IParserContext, expression as string
, caretLineNumber as int , caretColumn as int , fileName as string ,
fileContent as string ) as LanguageItemCollection:
- return Resolver (parserContext).IsAsResolve (expression,
caretLineNumber, caretColumn, fileName, fileContent)
+ def IsAsResolve (parserContext as IParserContext, expression as string
, caretLineNumber as int , caretColumn as int , fileName as string ,
fileContent as string, include_ifaces as bool) as LanguageItemCollection:
+ return Resolver (parserContext).IsAsResolve (expression,
caretLineNumber, caretColumn, fileName, fileContent, include_ifaces)
def Resolve(parserContext as IParserContext, expression as string,
caretLineNumber as int, caretColumn as int, fileName as string, fileContent as
string) as ResolveResult:
Log ("Resolve ${expression}
(${caretLineNumber}/${caretColumn})")
Modified: trunk/monodevelop/Extras/BooBinding/Parser/Resolver.boo
===================================================================
--- trunk/monodevelop/Extras/BooBinding/Parser/Resolver.boo 2007-02-09
23:20:10 UTC (rev 72563)
+++ trunk/monodevelop/Extras/BooBinding/Parser/Resolver.boo 2007-02-10
00:17:49 UTC (rev 72564)
@@ -243,9 +243,23 @@
#region IsAsResolve
- def IsAsResolve(expression as string, caretLine as int, caretColumn as
int, fileName as string, fileContent as string) as LanguageItemCollection:
- return null
+ # XXX: Finish implementing!
+ def IsAsResolve(expression as string, caretLine as int, caretColumn as
int, fileName as string, fileContent as string, include_ifaces as bool) as
LanguageItemCollection:
+ _caretLine = caretLine
+ _caretColumn = caretColumn
+ result = LanguageItemCollection ()
+ parse_info = _parserContext.GetParseInformation (fileName)
+ cu = parse_info.MostRecentCompilationUnit as
DefaultCompilationUnit
+ _compilationUnit = cu
+ return null if not _compilationUnit
+
+ expr = Boo.Lang.Parser.BooParser.ParseExpression("expression",
expression)
+ return null if not expr
+
+ visitor = ExpressionTypeVisitor(Resolver : self)
+ visitor.Visit(expr)
+
def MonodocResolver(expression as string, caretLine as int, caretColumn
as int, fileName as string, fileContent as string) as string:
return null
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches