Permalink
Browse files

Started type system conversion.

Refactorings + code completion is broken - rest is in place.
  • Loading branch information...
mkrueger committed Jun 16, 2011
1 parent 59ba940 commit 184813b585fbff7570daa2a0a2cd76aa72ad0618
Showing with 2,247 additions and 6,639 deletions.
  1. +50 −49 main/src/addins/CSharpBinding/AspNet/ASPNetReferenceFinder.cs
  2. +60 −52 main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs
  3. +3 −2 main/src/addins/CSharpBinding/CSharpBinding.addin.xml
  4. +34 −38 main/src/addins/CSharpBinding/CSharpBinding.csproj
  5. +1 −1 main/src/addins/CSharpBinding/ChangeLog
  6. +3 −27 main/src/addins/CSharpBinding/Makefile.am
  7. +473 −0 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs
  8. +49 −665 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs
  9. +1 −11 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CompletionTextLinkMode.cs
  10. +2 −4 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
  11. +136 −151 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MemberCompletionData.cs
  12. +1 −3 .../src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/NRefactoryIndexerParameterDataProvider.cs
  13. +5 −6 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/NRefactoryParameterDataProvider.cs
  14. +1 −3 ...src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/NRefactoryTemplateParameterDataProvider.cs
  15. +3 −7 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/NewOverrideCompletionData.cs
  16. +0 −1 main/src/addins/CSharpBinding/MonoDevelop.CSharp.ContextAction/Actions/MoveTypeToFile.cs
  17. +5 −19 main/src/addins/CSharpBinding/MonoDevelop.CSharp.ContextAction/ContextActionExtensions.cs
  18. +12 −18 main/src/addins/CSharpBinding/MonoDevelop.CSharp.ContextAction/MDRefactoringContext.cs
  19. +3 −4 main/src/addins/CSharpBinding/MonoDevelop.CSharp.ContextAction/MDRefactoringContextAction.cs
  20. +2 −4 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs
  21. +17 −20 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
  22. +82 −82 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs
  23. +62 −33 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/CSharpSyntaxMode.cs
  24. +55 −54 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
  25. +1 −1 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/CSharpInspector.cs
  26. +5 −8 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/CallGraph.cs
  27. +4 −10 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/CodeAnalysis.cs
  28. +2 −2 ...ns/CSharpBinding/MonoDevelop.CSharp.Inspection/Inspectors/ConditionalToNullCoalescingInspector.cs
  29. +22 −23 ...addins/CSharpBinding/MonoDevelop.CSharp.Inspection/Inspectors/NotImplementedExceptionInspector.cs
  30. +2 −2 ...src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/Inspectors/StringIsNullOrEmptyInspector.cs
  31. +12 −13 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/Inspectors/UnusedUsingInspector.cs
  32. +2 −2 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/Inspectors/UseVarKeywordInspector.cs
  33. +0 −1 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/NamingInspection/CSharpNamingPolicy.cs
  34. +0 −1 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/NamingInspection/NamingInspector.cs
  35. +19 −18 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/NamingInspection/NamingRule.cs
  36. +0 −1 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Inspection/NamingInspection/NamingStyle.cs
  37. +0 −1,159 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/McsParser.cs
  38. +9 −3 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs
  39. +5 −5 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CompilerOptionsPanelWidget.cs
  40. +2 −2 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs
  41. +2 −2 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpNRefactoryASTProvider.cs
  42. +23 −23 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpRefactorer.cs
  43. +2 −2 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpReferenceFinder.cs
  44. +10 −10 ...src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CreateMethod/CreateMethodCodeGenerator.cs
  45. +5 −5 ...src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/DeclareLocal/DeclareLocalCodeGenerator.cs
  46. +1 −1 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodDialog.cs
  47. +6 −6 ...src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs
  48. +7 −7 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/VariableLookupVisitor.cs
  49. +16 −13 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindMemberAstVisitor.cs
  50. +0 −3 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/HelperMethods.cs
  51. +0 −142 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryDocumentMetaInformation.cs
  52. +0 −1,014 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryResolver.cs
  53. +0 −1,361 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NewCSharpExpressionFinder.cs
  54. +0 −856 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/ResolveVisitor.cs
  55. +330 −288 main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/TextEditorResolverProvider.cs
  56. +414 −382 main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs
  57. +16 −19 main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpLanguageBinding.cs
  58. +270 −0 main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs
@@ -28,16 +28,15 @@
using MonoDevelop.Core;
using MonoDevelop.Ide;
using MonoDevelop.Projects.CodeGeneration;
using MonoDevelop.Projects.Dom;
using MonoDevelop.Projects.Dom.Parser;
using MonoDevelop.CSharp.Resolver;
using MonoDevelop.Ide.FindInFiles;
using MonoDevelop.AspNet;
using MonoDevelop.CSharp.Completion;
using MonoDevelop.AspNet.Parser;
using MonoDevelop.AspNet.Gui;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.TypeSystem;
namespace MonoDevelop.CSharp.Refactoring
@@ -49,54 +48,56 @@ public ASPNetReferenceFinder ()
IncludeDocumentation = true;
}
IEnumerable<MemberReference> SearchMember (INode member, ProjectDom dom, FilePath fileName, Mono.TextEditor.TextEditorData editor, Mono.TextEditor.Document buildDocument, List<LocalDocumentInfo.OffsetInfo> offsetInfos, ParsedDocument parsedDocument)
{
var resolver = new NRefactoryResolver (dom, parsedDocument.CompilationUnit, ICSharpCode.OldNRefactory.SupportedLanguage.CSharp, editor, fileName);
FindMemberAstVisitor visitor = new FindMemberAstVisitor (buildDocument, member);
visitor.IncludeXmlDocumentation = IncludeDocumentation;
visitor.RunVisitor (resolver);
foreach (var result in visitor.FoundReferences) {
var offsetInfo = offsetInfos.FirstOrDefault (info => info.ToOffset <= result.Position && result.Position < info.ToOffset + info.Length);
if (offsetInfo == null)
continue;
var offset = offsetInfo.FromOffset + result.Position - offsetInfo.ToOffset;
var loc = editor.OffsetToLocation (offset);
yield return new MemberReference (null, fileName, offset, loc.Line, loc.Column, result.Name, null);
}
IEnumerable<DomRegion> SearchMember (IEntity member, ITypeResolveContext dom, FilePath fileName, Mono.TextEditor.TextEditorData editor, Mono.TextEditor.Document buildDocument, List<LocalDocumentInfo.OffsetInfo> offsetInfos, ParsedDocument parsedDocument)
{ // TODO: Type system conversion.
yield break;
// var resolver = new NRefactoryResolver (dom, parsedDocument.CompilationUnit, ICSharpCode.OldNRefactory.SupportedLanguage.CSharp, editor, fileName);
//
// var visitor = new FindMemberAstVisitor (buildDocument, member);
// visitor.IncludeXmlDocumentation = IncludeDocumentation;
// visitor.RunVisitor (resolver);
//
// foreach (var result in visitor.FoundReferences) {
// var offsetInfo = offsetInfos.FirstOrDefault (info => info.ToOffset <= result.Position && result.Position < info.ToOffset + info.Length);
// if (offsetInfo == null)
// continue;
// var offset = offsetInfo.FromOffset + result.Position - offsetInfo.ToOffset;
// var loc = editor.OffsetToLocation (offset);
// yield return new DomRegion (fileName, loc.Line, loc.Column, loc.Line, loc.Column + result.Name.Lenhth);
// }
}
public override IEnumerable<MemberReference> FindReferences (ProjectDom dom, FilePath fileName, IEnumerable<INode> searchedMembers)
{
var editor = TextFileProvider.Instance.GetTextEditorData (fileName);
AspNetAppProject project = dom.Project as AspNetAppProject;
if (project == null)
yield break;
var unit = AspNetParserService.GetCompileUnit (project, fileName, true);
if (unit == null)
yield break;
var refman = new DocumentReferenceManager (project);
var parsedAspDocument = (AspNetParsedDocument)new AspNetParser ().Parse (dom, fileName, editor.Text);
refman.Doc = parsedAspDocument;
var usings = refman.GetUsings ();
var documentInfo = new DocumentInfo (dom, unit, usings, refman.GetDoms ());
var builder = new AspLanguageBuilder ();
var buildDocument = new Mono.TextEditor.Document ();
var offsetInfos = new List<LocalDocumentInfo.OffsetInfo> ();
buildDocument.Text = builder.BuildDocumentString (documentInfo, editor, offsetInfos, true);
var parsedDocument = AspLanguageBuilder.Parse (dom, fileName, buildDocument.Text);
foreach (var member in searchedMembers) {
foreach (var reference in SearchMember (member, dom, fileName, editor, buildDocument, offsetInfos, parsedDocument)) {
yield return reference;
}
}
public override IEnumerable<DomRegion> FindReferences (ITypeResolveContext dom, FilePath fileName, IEnumerable<IEntity> searchedMembers)
{ // TODO: Type system conversion.
yield break;
// var editor = TextFileProvider.Instance.GetTextEditorData (fileName);
// AspNetAppProject project = dom.Project as AspNetAppProject;
// if (project == null)
// yield break;
//
// var unit = AspNetParserService.GetCompileUnit (project, fileName, true);
// if (unit == null)
// yield break;
// var refman = new DocumentReferenceManager (project);
//
// var parsedAspDocument = (AspNetParsedDocument)new AspNetParser ().Parse (dom, fileName, editor.Text);
// refman.Doc = parsedAspDocument;
//
// var usings = refman.GetUsings ();
// var documentInfo = new DocumentInfo (dom, unit, usings, refman.GetDoms ());
//
// var builder = new AspLanguageBuilder ();
//
//
// var buildDocument = new Mono.TextEditor.Document ();
// var offsetInfos = new List<LocalDocumentInfo.OffsetInfo> ();
// buildDocument.Text = builder.BuildDocumentString (documentInfo, editor, offsetInfos, true);
// var parsedDocument = AspLanguageBuilder.Parse (dom, fileName, buildDocument.Text);
// foreach (var member in searchedMembers) {
// foreach (var reference in SearchMember (member, dom, fileName, editor, buildDocument, offsetInfos, parsedDocument)) {
// yield return reference;
// }
// }
}
}
}
@@ -29,13 +29,13 @@
using MonoDevelop.AspNet.Parser.Dom;
using MonoDevelop.AspNet.Gui;
using System.Text;
using MonoDevelop.Projects.Dom;
using MonoDevelop.Projects.Dom.Parser;
using System.Collections.Generic;
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.Gui;
using Mono.TextEditor;
using ICSharpCode.OldNRefactory;
using MonoDevelop.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
namespace MonoDevelop.CSharp.Completion
{
@@ -46,13 +46,15 @@ public bool SupportsLanguage (string language)
return language == "C#";
}
public static ParsedDocument Parse (ProjectDom dom, string fileName, string text)
public static ParsedDocument Parse (ITypeResolveContext dom, string fileName, string text)
{
var result = new MonoDevelop.CSharp.Parser.McsParser ().Parse (null, fileName, text);
foreach (DomType type in result.CompilationUnit.Types) {
type.SourceProjectDom = dom;
}
return result;
// TODO: type system conversion.
return new ParsedDocument (fileName);
// var result = new MonoDevelop.CSharp.Parser.McsParser ().Parse (null, fileName, text);
// foreach (DomType type in result.CompilationUnit.Types) {
// type.GetProjectContent () = dom;
// }
// return result;
}
static void WriteUsings (IEnumerable<string> usings, StringBuilder builder)
@@ -114,66 +116,72 @@ static void WriteClassDeclaration (DocumentInfo info, StringBuilder builder)
}
public ICompletionDataList HandlePopupCompletion (MonoDevelop.Ide.Gui.Document realDocument, DocumentInfo info, LocalDocumentInfo localInfo)
{
CodeCompletionContext codeCompletionContext;
using (var completion = CreateCompletion (realDocument, info, localInfo, out codeCompletionContext)) {
return completion.CodeCompletionCommand (codeCompletionContext);
}
{// TODO: Type system conversion
// CodeCompletionContext codeCompletionContext;
// using (var completion = CreateCompletion (realDocument, info, localInfo, out codeCompletionContext)) {
// return completion.CodeCompletionCommand (codeCompletionContext);
// }
return null;
}
public ICompletionDataList HandleCompletion (MonoDevelop.Ide.Gui.Document realDocument, CodeCompletionContext completionContext, DocumentInfo info, LocalDocumentInfo localInfo, char currentChar, ref int triggerWordLength)
{
CodeCompletionContext ccc;
using (var completion = CreateCompletion (realDocument, info, localInfo, out ccc)) {
return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength);
}
{// TODO: Type system conversion
// CodeCompletionContext ccc;
// using (var completion = CreateCompletion (realDocument, info, localInfo, out ccc)) {
// return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength);
// }
return null;
}
public IParameterDataProvider HandleParameterCompletion (MonoDevelop.Ide.Gui.Document realDocument, CodeCompletionContext completionContext, DocumentInfo info, LocalDocumentInfo localInfo, char completionChar)
{
CodeCompletionContext ccc;
using (var completion = CreateCompletion (realDocument, info, localInfo, out ccc)) {
return completion.HandleParameterCompletion (completionContext, completionChar);
}
{// TODO: Type system conversion
return null;
// CodeCompletionContext ccc;
// using (var completion = CreateCompletion (realDocument, info, localInfo, out ccc)) {
// return completion.HandleParameterCompletion (completionContext, completionChar);
// }
}
public bool GetParameterCompletionCommandOffset (MonoDevelop.Ide.Gui.Document realDocument, DocumentInfo info, LocalDocumentInfo localInfo, out int cpos)
{
CodeCompletionContext codeCompletionContext;
using (var completion = CreateCompletion (realDocument, info, localInfo, out codeCompletionContext)) {
return completion.GetParameterCompletionCommandOffset (out cpos);
}
// TODO: Type system conversion
cpos = 0;
return false;
// CodeCompletionContext codeCompletionContext;
// using (var completion = CreateCompletion (realDocument, info, localInfo, out codeCompletionContext)) {
//
// return completion.GetParameterCompletionCommandOffset (out cpos);
// }
}
public ICompletionWidget CreateCompletionWidget (MonoDevelop.Ide.Gui.Document realDocument, LocalDocumentInfo localInfo)
{
return new AspCompletionWidget (realDocument, localInfo);
}
CSharpTextEditorCompletion CreateCompletion (MonoDevelop.Ide.Gui.Document realDocument, DocumentInfo info, LocalDocumentInfo localInfo, out CodeCompletionContext codeCompletionContext)
{
var doc = new Mono.TextEditor.Document () {
Text = localInfo.LocalDocument,
};
var documentLocation = doc.OffsetToLocation (localInfo.CaretPosition);
codeCompletionContext = new CodeCompletionContext () {
TriggerOffset = localInfo.CaretPosition,
TriggerLine = documentLocation.Line,
TriggerLineOffset = documentLocation.Column - 1
};
var r = new System.IO.StringReader (localInfo.LocalDocument);
using (var parser = ICSharpCode.OldNRefactory.ParserFactory.CreateParser (SupportedLanguage.CSharp, r)) {
parser.Parse ();
return new CSharpTextEditorCompletion (localInfo.HiddenDocument) {
ParsedUnit = parser.CompilationUnit,
CompletionWidget = CreateCompletionWidget (realDocument, localInfo),
Dom = localInfo.HiddenDocument.Dom
};
}
}
// TODO: Type system conversion
// CSharpTextEditorCompletion CreateCompletion (MonoDevelop.Ide.Gui.Document realDocument, DocumentInfo info, LocalDocumentInfo localInfo, out CodeCompletionContext codeCompletionContext)
// {
// var doc = new Mono.TextEditor.Document () {
// Text = localInfo.LocalDocument,
// };
// var documentLocation = doc.OffsetToLocation (localInfo.CaretPosition);
//
// codeCompletionContext = new CodeCompletionContext () {
// TriggerOffset = localInfo.CaretPosition,
// TriggerLine = documentLocation.Line,
// TriggerLineOffset = documentLocation.Column - 1
// };
//
// var r = new System.IO.StringReader (localInfo.LocalDocument);
// using (var parser = ICSharpCode.OldNRefactory.ParserFactory.CreateParser (SupportedLanguage.CSharp, r)) {
// parser.Parse ();
// return new CSharpTextEditorCompletion (localInfo.HiddenDocument) {
// ParsedUnit = parser.CompilationUnit,
// CompletionWidget = CreateCompletionWidget (realDocument, localInfo),
// Dom = localInfo.HiddenDocument.Dom
// };
// }
// }
class AspCompletionWidget : ICompletionWidget
{
@@ -95,7 +95,8 @@
</Extension>
<Extension path = "/MonoDevelop/Ide/TextEditorExtensions">
<Class fileExtensions = ".cs" class = "MonoDevelop.CSharp.Completion.CSharpTextEditorCompletion" />
<Class fileExtensions = ".cs" class = "MonoDevelop.CSharp.PathedDocumentTextEditorExtension" />
<Class fileExtensions = ".cs" class = "MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension" />
<Class fileExtensions = ".cs" class = "MonoDevelop.CSharp.Formatting.CSharpTextEditorIndentation" />
<Class fileExtensions = ".cs" class = "MonoDevelop.CSharp.Highlighting.HighlightUsagesExtension" />
</Extension>
@@ -110,7 +111,7 @@
</Extension>
<Extension path = "/MonoDevelop/ProjectModel/Ambiences">
<Class id = "C#" class = "MonoDevelop.CSharp.CSharpAmbience" />
<Ambience mimeType="text/x-csharp" class = "MonoDevelop.CSharp.CSharpAmbience" />
</Extension>
<Extension path = "/MonoDevelop/Core/StockIcons">
Oops, something went wrong.

0 comments on commit 184813b

Please sign in to comment.