diff options
author | Mike Krüger <mkrueger@novell.com> | 2011-06-20 09:49:50 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2011-06-20 09:49:50 +0400 |
commit | 23d90143576922f28e1590194fd7a6540ff1edce (patch) | |
tree | cbc5bd9f844a91302e4661ae0b1aacec24d07ded /main/src/addins/AspNet | |
parent | 0945c05c8f03841bea33e5870dbd1470d65ba59e (diff) |
Fixed type system conversion todos in the asp.net binding.
Diffstat (limited to 'main/src/addins/AspNet')
6 files changed, 90 insertions, 97 deletions
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspNetEditorExtension.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspNetEditorExtension.cs index 6acf4a97e7..2ddd931c38 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspNetEditorExtension.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspNetEditorExtension.cs @@ -96,9 +96,9 @@ namespace MonoDevelop.AspNet.Gui documentInfo = new DocumentInfo (document.TypeResolveContext, aspDoc, usings, refman.GetDoms ()); documentInfo.ParsedDocument = documentBuilder.BuildDocument (documentInfo, Editor); documentInfo.CodeBesideClass = CreateCodeBesideClass (documentInfo, refman); -// domWrapper = new AspProjectDomWrapper (documentInfo); TODO: Type system conversion -// if (localDocumentInfo != null) -// localDocumentInfo.HiddenDocument.Dom = domWrapper; + var domWrapper = new AspProjectDomWrapper (documentInfo); + if (localDocumentInfo != null) + localDocumentInfo.HiddenDocument.HiddenContext = domWrapper; } } @@ -232,11 +232,10 @@ namespace MonoDevelop.AspNet.Gui var workbenchWindow = new MonoDevelop.Ide.Gui.HiddenWorkbenchWindow (); workbenchWindow.ViewContent = viewContent; - localDocumentInfo.HiddenDocument = new MonoDevelop.Ide.Gui.Document (workbenchWindow)/* { - ParsedFile = localDocumentInfo.ParsedLocalDocument, - Dom = null - //Dom = domWrapper TODO: Type system conversion - }*/; + localDocumentInfo.HiddenDocument = new HiddenDocument (workbenchWindow) { + HiddenParsedDocument = localDocumentInfo.ParsedLocalDocument, + HiddenContext = domWrapper + }; } @@ -253,15 +252,15 @@ namespace MonoDevelop.AspNet.Gui ICompletionWidget defaultCompletionWidget; MonoDevelop.Ide.Gui.Document defaultDocument; -// AspProjectDomWrapper domWrapper; TODO: Type system conversion. + AspProjectDomWrapper domWrapper; public override void Initialize () { base.Initialize (); defaultCompletionWidget = CompletionWidget; defaultDocument = document; -/* defaultDocument.TextEditorData.Caret.PositionChanged += delegate { + defaultDocument.Editor.Caret.PositionChanged += delegate { OnCompletionContextChanged (CompletionWidget, EventArgs.Empty); - };*/ + }; } diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspProjectDom.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspProjectDom.cs index 50ce5e81c7..fd16f32a46 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspProjectDom.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/AspProjectDom.cs @@ -30,25 +30,25 @@ using ICSharpCode.NRefactory.TypeSystem; namespace MonoDevelop.AspNet.Gui { - // Todo: type system conversion. -// /// <summary> -// /// This wraps a project dom and adds the compilation information from the ASP.NET page to the DOM to lookup members -// /// on the page. -// /// </summary> -// class AspProjectDomWrapper : ProjectDomDecorator -// { -// DocumentInfo info; -// -// //FIXME: use all the doms -// //FIXME: merge the items from the members visitor too -// public AspProjectDomWrapper (DocumentInfo info) : base (info.References[0]) -// { -// this.info = info; -// } -// -// IType constructedType = null; -// IType CheckType (IType type) -// { + /// <summary> + /// This wraps a project dom and adds the compilation information from the ASP.NET page to the DOM to lookup members + /// on the page. + /// </summary> + class AspProjectDomWrapper : TypeResolveContextDecorator + { + DocumentInfo info; + + //FIXME: use all the doms + //FIXME: merge the items from the members visitor too + public AspProjectDomWrapper (DocumentInfo info) : base (info.References[0]) + { + this.info = info; + } + + ITypeDefinition constructedType = null; + ITypeDefinition CheckType (ITypeDefinition type) + { +// TODO: Type system conversion. // if (type == null) // return null; // var cu =info.ParsedDocument.CompilationUnit; @@ -61,46 +61,24 @@ namespace MonoDevelop.AspNet.Gui // constructedType.GetProjectContent () = this; // return constructedType; // } -// return type; -// } -// -// public override IType ResolveType (IType type) -// { -// if (type == constructedType) -// return type; -// return CheckType (base.ResolveType (type)); -// } -// -// public override IType GetType (IReturnType returnType) -// { -// return CheckType (base.GetType (returnType)); -// } -// -// public override IType GetType (string typeName, IList<IReturnType> genericArguments, -// bool deepSearchReferences, bool caseSensitive) -// { -// return CheckType (base.GetType (typeName, genericArguments, deepSearchReferences, caseSensitive)); -// } -// -// public override IType GetType (string typeName, int genericArgumentsCount, -// bool deepSearchReferences, bool caseSensitive) -// { -// return CheckType (base.GetType (typeName, genericArgumentsCount, deepSearchReferences, caseSensitive)); -// } -// -// public override IEnumerable<IType> GetInheritanceTree (IType type) -// { -// foreach (IType t in BaseGetInheritanceTree (type)) { -// yield return CheckType (t); -// } -// } -// -// //WORKAROUND for gmcs code generation bug - base not properly accessible from generators. -// //Should be fixed in Mono 2.8 final. -// IEnumerable<IType> BaseGetInheritanceTree (IType type) -// { -// return base.GetInheritanceTree (type); -// } -// } + return type; + } + + public override ITypeDefinition GetTypeDefinition (string nameSpace, string name, int typeParameterCount, StringComparer nameComparer) + { + return CheckType (base.GetTypeDefinition (nameSpace, name, typeParameterCount, nameComparer)); + } + + public override IEnumerable<ITypeDefinition> GetTypes() + { + return base.GetTypes ().Select (t => CheckType (t)); + } + + public override IEnumerable<ITypeDefinition> GetTypes(string nameSpace, StringComparer nameComparer) + { + return base.GetTypes (nameSpace, nameComparer).Select (t => CheckType (t)); + } + + } } diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/ILanguageCompletionBuilder.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/ILanguageCompletionBuilder.cs index 9c701278f4..5a6604fb3f 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/ILanguageCompletionBuilder.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/ILanguageCompletionBuilder.cs @@ -46,6 +46,7 @@ using MonoDevelop.Ide.CodeCompletion; namespace MonoDevelop.AspNet.Gui { + /// <summary> /// Embedded local region completion information for each keystroke /// </summary> @@ -55,7 +56,7 @@ namespace MonoDevelop.AspNet.Gui public ParsedDocument ParsedLocalDocument { get; set; } public int CaretPosition { get; set; } public int OriginalCaretPosition { get; set; } - public MonoDevelop.Ide.Gui.Document HiddenDocument { get; set; } + public HiddenDocument HiddenDocument { get; set; } public List<OffsetInfo> OffsetInfos = new List<OffsetInfo> (); @@ -220,4 +221,25 @@ namespace MonoDevelop.AspNet.Gui return null; } } + + public class HiddenDocument : MonoDevelop.Ide.Gui.Document + { + internal ICSharpCode.NRefactory.TypeSystem.ITypeResolveContext HiddenContext; + public override ICSharpCode.NRefactory.TypeSystem.ITypeResolveContext TypeResolveContext { + get { + return HiddenContext; + } + } + + internal ParsedDocument HiddenParsedDocument; + public override ParsedDocument ParsedDocument { + get { + return HiddenParsedDocument; + } + } + + public HiddenDocument (MonoDevelop.Ide.Gui.IWorkbenchWindow window) : base(window) + { + } + } } diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs index f1407ebe2d..c796e100cf 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs @@ -444,12 +444,10 @@ namespace MonoDevelop.AspNet.Parser } public override string Description { - get { // TODO: Type system conversion. - return "todo"; - // if (base.Description == null && cls != null) - // base.Description = DocumentationService.GetCodeCompletionDescription ( - // cls, AmbienceService.DefaultAmbience); - // return base.Description; + get { + if (base.Description == null && cls != null) + base.Description = AmbienceService.GetDocumentation (cls.GetDefinition ()); + return base.Description; } set { base.Description = value; } } diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs index 7dd4634110..b4fcf8578b 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs @@ -110,8 +110,7 @@ namespace MonoDevelop.AspNet updatedParseDb = true; monitor.Log.Write (GettextCatalog.GetString ("Waiting for project type database to finish updating...")); var dom = TypeSystemService.GetContext (aspProject); - // TODO: Type system conversion - // dom.ForceUpdate (true); + TypeSystemService.ForceUpdate (dom); monitor.Log.WriteLine (GettextCatalog.GetString (" complete.")); } diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/WebTypeManager.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/WebTypeManager.cs index 72d48f91ad..19763ed529 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/WebTypeManager.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/WebTypeManager.cs @@ -160,7 +160,7 @@ namespace MonoDevelop.AspNet var dom = ResolveAssembly (info.Assembly); if (dom == null) continue; - foreach (IType t in ListControlClasses (baseType, dom, info.Namespace)) + foreach (var t in ListControlClasses (baseType, dom, info.Namespace)) yield return new MonoDevelop.AspNet.Parser.AspTagCompletionData (info.TagPrefix + ":", t); } else if (info.IsUserControl) { @@ -212,7 +212,7 @@ namespace MonoDevelop.AspNet if (!string.IsNullOrEmpty (tpxInfo.Namespace) && !string.IsNullOrEmpty (tpxInfo.Assembly) && !string.IsNullOrEmpty (tpxInfo.TagPrefix)) { var dom = ResolveAssembly (tpxInfo.Assembly); if (dom != null) - foreach (IType type in ListControlClasses (baseType, dom, tpxInfo.Namespace)) + foreach (var type in ListControlClasses (baseType, dom, tpxInfo.Namespace)) yield return new MonoDevelop.AspNet.Parser.AspTagCompletionData (tpxInfo.TagPrefix, type); } } @@ -310,21 +310,18 @@ namespace MonoDevelop.AspNet } public static IEnumerable<IType> ListControlClasses (IType baseType, ITypeResolveContext database, string namespac) - { // TODO: Type system conversion. - yield break; -// if (database == null) -// yield break; -// -// //return classes if they derive from system.web.ui.control -// foreach (IType type in database.GetSubclasses (baseType, false, new string [] {namespac})) -// if (!type.IsAbstract && type.IsPublic) -// yield return type; -// -// if (!baseType.IsAbstract && baseType.IsPublic && baseType.Namespace == namespac) { -// IType t = database.GetType (baseType.FullName); -// if (t != null) -// yield return baseType; -// } + { + if (database == null) + yield break; + var baseTypeDefinition = baseType.GetDefinition (); + //return classes if they derive from system.web.ui.control + foreach (var type in baseTypeDefinition.GetSubTypeDefinitions (database).Where (t => t.Namespace == namespac)) + if (!type.IsAbstract && type.IsPublic) + yield return type; + + if (!baseTypeDefinition.IsAbstract && baseTypeDefinition.IsPublic && baseTypeDefinition.Namespace == namespac) { + yield return baseType.Resolve (database); + } } #endregion |