[Monodevelop-patches-list] r1496 - in trunk/MonoDevelop/src: AddIns/BackendBindings/CSharpBinding AddIns/BackendBindings/CSharpBinding/Parser AddIns/DisplayBindings/SourceEditor AddIns/DisplayBindings/SourceEditor/CodeCompletion Main/Base Main/Base/Internal/Parser Main/Base/Services/ParserService

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sat Apr 24 17:26:48 EDT 2004


Author: tberman
Date: 2004-04-24 17:26:48 -0400 (Sat, 24 Apr 2004)
New Revision: 1496

Modified:
   trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/ChangeLog
   trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionDataProvider.cs
   trunk/MonoDevelop/src/Main/Base/ChangeLog
   trunk/MonoDevelop/src/Main/Base/Internal/Parser/IParser.cs
   trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
   trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs
Log:
add IsAsResolver. cute piece of functionality. prolly my last cute piece of
functionality for a while. crunch time begins officialy today.

(the french people are somewhat evil in retrospect ;) )


Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/ChangeLog	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/ChangeLog	2004-04-24 21:26:48 UTC (rev 1496)
@@ -1,3 +1,9 @@
+2004-04-24  Todd Berman  <tberman at sevenl.net>
+
+	* Parser/Parser.cs: new IsAsResolver passthrough.
+	* Parser/Resolver.cs: new IsAsResolver to manage some (limited)
+	completion there.
+
 2004-04-23  John Luke  <jluke at cfl.rr.com>
 
 	* CsharpBindingCompilerManager.cs: add /codepage:utf8

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs	2004-04-24 21:26:48 UTC (rev 1496)
@@ -93,6 +93,11 @@
 		{
 			return new Resolver().CtrlSpace(parserService, caretLine, caretColumn, fileName);
 		}
+
+		public ArrayList IsAsResolve (IParserService parserService, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
+		{
+			return new Resolver ().IsAsResolve (parserService, expression, caretLineNumber, caretColumn, fileName, fileContent);
+		}
 		
 		public ResolveResult Resolve(IParserService parserService, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
 		{

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs	2004-04-24 21:26:48 UTC (rev 1496)
@@ -795,10 +795,64 @@
 				}
 			}
 		}
+
+		public ArrayList IsAsResolve (IParserService parserService, string expression, int caretLine, int caretColumn, string fileName, string fileContent)
+		{
+			ArrayList result = new ArrayList ();
+			this.parserService = parserService;
+			this.caretLine = caretLine;
+			this.caretColumn = caretColumn;
+			
+			IParseInformation parseInfo = parserService.GetParseInformation (fileName);
+			ICSharpCode.SharpRefactory.Parser.AST.CompilationUnit fcu = parseInfo.MostRecentCompilationUnit.Tag as ICSharpCode.SharpRefactory.Parser.AST.CompilationUnit;
+			if (fcu == null)
+				return null;
+			ICSharpCode.SharpRefactory.Parser.Parser p = new ICSharpCode.SharpRefactory.Parser.Parser ();
+			Lexer l = new Lexer (new StringReader (expression));
+			Expression expr = p.ParseExpression(l);
+			if (expr == null)
+				return null;
+
+			lookupTableVisitor = new LookupTableVisitor ();
+			lookupTableVisitor.Visit (fcu, null);
+
+			TypeVisitor typeVisitor = new TypeVisitor (this);
+
+			CSharpVisitor csharpVisitor = new CSharpVisitor ();
+			cu = (ICompilationUnit)csharpVisitor.Visit (fcu, null);
+			if (cu != null) {
+				callingClass = GetInnermostClass ();
+			}
+
+			IReturnType type = expr.AcceptVisitor (typeVisitor, null) as IReturnType;
+			if (type == null || type.PointerNestingLevel != 0) {
+				fcu = parserService.ParseFile (fileName, fileContent).MostRecentCompilationUnit.Tag as ICSharpCode.SharpRefactory.Parser.AST.CompilationUnit;
+				lookupTableVisitor.Visit (fcu, null);
+				cu = (ICompilationUnit)csharpVisitor.Visit (fcu, null);
+
+				if (cu != null) {
+					callingClass = GetInnermostClass ();
+				}
+				type = expr.AcceptVisitor (typeVisitor, null) as IReturnType;
+				if (type == null)
+					return null;
+			}
+			if (type.ArrayDimensions != null && type.ArrayDimensions.Length > 0)
+				type = new ReturnType ("System.Array");
+
+			IClass returnClass = SearchType (type.FullyQualifiedName, cu);
+			if (returnClass == null)
+				return null;
+
+			foreach (IClass iclass in returnClass.ClassInheritanceTree) {
+				if (!result.Contains (iclass))
+					result.Add (iclass);
+			}
+			return result;
+		}
 		
 		public ArrayList CtrlSpace(IParserService parserService, int caretLine, int caretColumn, string fileName)
 		{
-			Console.WriteLine ("Inside CtrlSpace");
 			ArrayList result = new ArrayList();
 			this.parserService = parserService;
 			IParseInformation parseInfo = parserService.GetParseInformation(fileName);

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-04-24 21:26:48 UTC (rev 1496)
@@ -1,3 +1,8 @@
+2004-04-24  Todd Berman  <tberman at sevenl.net>
+
+	* CodeCompletion/CodeCompletionDataProvider.cs: hook into is/as resolve
+	method.
+
 2004-04-23  Todd Berman  <tberman at sevenl.net>
 
 	* Gui/SourceEditorBuffer.cs: add a check for a 0 length iter.Char

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionDataProvider.cs	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion/CodeCompletionDataProvider.cs	2004-04-24 21:26:48 UTC (rev 1496)
@@ -73,8 +73,13 @@
 			IExpressionFinder expressionFinder = parserService.GetExpressionFinder(fileName);
 			string expression    = expressionFinder == null ? TextUtilities.GetExpressionBeforeOffset(textArea, insertIter.Offset) : expressionFinder.FindExpression(textArea.Buffer.GetText(textArea.Buffer.StartIter, insertIter, true), insertIter.Offset - 2);
 			if (expression == null) return null;
-			//Console.WriteLine ("Expr: |{0}|", expression);
+			Console.WriteLine ("Expr: |{0}|", expression);
 			//FIXME: This chartyped check is a fucking *HACK*
+			if (expression == "is" || expression == "as") {
+				string expr = expressionFinder == null ? TextUtilities.GetExpressionBeforeOffset (textArea, insertIter.Offset - 3) : expressionFinder.FindExpression (textArea.Buffer.GetText (textArea.Buffer.StartIter, insertIter, true), insertIter.Offset - 5);
+				AddResolveResults (parserService.IsAsResolve (expr, caretLineNumber, caretColumn, fileName, textArea.Buffer.Text));
+				return (ICompletionData[])completionData.ToArray (typeof (ICompletionData));
+			}
 			if (ctrlspace && charTyped != '.') {
 				AddResolveResults (parserService.CtrlSpace (parserService, caretLineNumber, caretColumn, fileName));
 				return (ICompletionData[])completionData.ToArray (typeof (ICompletionData));

Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog	2004-04-24 21:26:48 UTC (rev 1496)
@@ -1,3 +1,9 @@
+2004-04-24  Todd Berman  <tberman at sevenl.net>
+
+	* Services/ParserService/DefaultParserService.cs:
+	* Services/ParserService/IParserService.cs:
+	* Internal/Parser/IParser.cs: add stubbing for IsAsResolver
+
 2004-04-22  Todd Berman  <tberman at sevenl.net>
 
 	* Gui/Components/SdMenu.cs: check for children, if none, hide menu.

Modified: trunk/MonoDevelop/src/Main/Base/Internal/Parser/IParser.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Parser/IParser.cs	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Parser/IParser.cs	2004-04-24 21:26:48 UTC (rev 1496)
@@ -136,8 +136,9 @@
 		                      int caretColumn, 
 		                      string fileName,
 		                      string fileContent);
+
+		ArrayList IsAsResolve (IParserService parserService, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
 		
-		
 		ArrayList CtrlSpace(IParserService parserService, int caretLine, int caretColumn, string fileName);
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs	2004-04-24 21:26:48 UTC (rev 1496)
@@ -745,6 +745,19 @@
 			}
 			return null;
 		}
+
+		public ArrayList IsAsResolve (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
+		{
+			try {
+				IParser parser = GetParser (fileName);
+				if (parser != null) {
+					return parser.IsAsResolve (this, expression, caretLineNumber, caretColumn, fileName, fileContent);
+				}
+				return null;
+			} catch {
+				return null;
+			}
+		}
 		
 		public ResolveResult Resolve(string expression,
 		                             int caretLineNumber,

Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs	2004-04-24 00:14:21 UTC (rev 1495)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/IParserService.cs	2004-04-24 21:26:48 UTC (rev 1496)
@@ -68,6 +68,7 @@
 		                      int caretColumn,
 		                      string fileName,
 		                      string fileContent);
+		ArrayList IsAsResolve (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
 		ArrayList CtrlSpace(IParserService parserService, int caretLine, int caretColumn, string fileName);
 		void AddReferenceToCompletionLookup(IProject project, ProjectReference reference);
 




More information about the Monodevelop-patches-list mailing list