public static void Format (MonoDevelop.Ide.Gui.Document data, ProjectDom dom, DomLocation location, bool correctBlankLines, bool runAferCR = false) { PolicyContainer policyParent = dom != null && dom.Project != null ? dom.Project.Policies : PolicyService.DefaultPolicies; var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType); Format (policyParent, mimeTypeChain, data, dom, location, correctBlankLines, runAferCR); }
public static ResolveResult GetResolveResult (MonoDevelop.Ide.Gui.Document doc) { ITextEditorResolver textEditorResolver = doc.GetContent<ITextEditorResolver> (); if (textEditorResolver != null) return textEditorResolver.GetLanguageItem (doc.Editor.Caret.Offset); return null; }
protected override BuildResult OnBuild (MonoDevelop.Core.IProgressMonitor monitor, ConfigurationSelector configuration) { var restResult = RestClient.CompileScripts (); var result = new BuildResult (); foreach (var message in restResult.Messages) { var file = BaseDirectory + "/" + message.File; var msg = message.Message; var errorNum = ""; var messageStrings = message.Message.Split(':'); if (messageStrings.Length == 3) { var errorNumStrings = messageStrings[1].Split(' '); if (errorNumStrings.Length > 1) errorNum = errorNumStrings[errorNumStrings.Length - 1]; msg = messageStrings[2]; } if(message.Type == "warning") result.AddWarning(file, message.Line, message.Column, errorNum, msg); else result.AddError(file, message.Line, message.Column, errorNum, msg); } return result; }
public StyledSourceEditorOptions (MonoDevelop.Ide.Editor.ITextEditorOptions optionsCore) { if (optionsCore == null) throw new ArgumentNullException ("optionsCore"); this.optionsCore = optionsCore; DefaultSourceEditorOptions.Instance.Changed += HandleChanged; }
public Task<ICompletionDataList> HandleCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, CodeCompletionContext completionContext, UnderlyingDocumentInfo docInfo, char currentChar, CancellationToken token) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc); return completion.HandleCodeCompletionAsync (completionContext, currentChar, token); }
bool AnalyzeTargetExpression (RefactoringOptions options, MonoDevelop.CSharp.Ast.CompilationUnit unit) { var data = options.GetTextEditorData (); var target = unit.GetNodeAt (data.Caret.Line, data.Caret.Column); if (target == null) return false; if (target.Parent is MemberReferenceExpression && ((MemberReferenceExpression)target.Parent).GetChildByRole (MemberReferenceExpression.Roles.Identifier) == target) { var memberReference = (MemberReferenceExpression)target.Parent; target = memberReference.Target; var targetResult = options.GetResolver ().Resolve (new ExpressionResult (data.GetTextBetween (target.StartLocation.Line, target.StartLocation.Column, target.EndLocation.Line, target.EndLocation.Column)), resolvePosition); if (targetResult.StaticResolve) modifiers = MonoDevelop.Projects.Dom.Modifiers.Static; declaringType = options.Dom.GetType (targetResult.ResolvedType); methodName = memberReference.MemberName; } else if (target is Identifier) { declaringType = options.ResolveResult.CallingType; methodName = data.GetTextBetween (target.StartLocation.Line, target.StartLocation.Column, target.EndLocation.Line, target.EndLocation.Column); } if (declaringType != null && !HasCompatibleMethod (declaringType, methodName, invocation)) { if (declaringType.HasParts) declaringType = declaringType.Parts.FirstOrDefault (t => t.CompilationUnit.FileName == options.Document.FileName) ?? declaringType; var doc = ProjectDomService.GetParsedDocument (declaringType.SourceProjectDom, declaringType.CompilationUnit.FileName); declaringType = doc.CompilationUnit.GetTypeAt (declaringType.Location) ?? declaringType; return true; } return false; }
public override IEnumerable<MemberReference> FindReferences (MonoDevelop.Projects.Project project, IProjectContent content, IEnumerable<FilePath> files, IProgressMonitor monitor, IEnumerable<object> 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.TextDocument (); // 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 static void JumpToDeclaration (MonoDevelop.Ide.Gui.Document doc, RefactoringSymbolInfo info) { if (info.Symbol != null) RefactoringService.RoslynJumpToDeclaration (info.Symbol, doc.Project); if (info.CandidateSymbols.Length > 0) RefactoringService.RoslynJumpToDeclaration (info.CandidateSymbols[0], doc.Project); }
protected override BuildResult Compile(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData) { #if DEBUG monitor.Log.WriteLine("MonoGame Extension Compile Called"); #endif try { var proj = item as MonoGameProject; if (proj == null) { return base.Compile (monitor, item, buildData); } monitor.Log.WriteLine("Compiling for {0}", proj.MonoGamePlatform); var results = new System.Collections.Generic.List<BuildResult>(); foreach(var file in proj.Files) { if (MonoGameBuildAction.IsMonoGameBuildAction(file.BuildAction)) { buildData.Items.Add(file); var buildResult = MonoGameContentProcessor.Compile(file, monitor, buildData); results.Add(buildResult); } } return base.Compile (monitor, item, buildData).Append(results); } finally { #if DEBUG monitor.Log.WriteLine("MonoGame Extension Compile Ended"); #endif } }
protected override BuildResult Compile (MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData) { var proj = item as Project; if (proj == null) return base.Compile (monitor, item, buildData); if (!proj.GetProjectTypes().Any(x => supportedProjectTypes.ContainsKey(x))) return base.Compile (monitor, item, buildData); var files = buildData.Items.Where(x => x is ProjectFile).Cast<ProjectFile>().ToArray(); foreach (var file in files.Where(f => f.BuildAction == "MonoGameContentReference")) { var path = System.IO.Path.Combine (Path.GetDirectoryName (file.FilePath.ToString ()), "bin", supportedProjectTypes[platform]); monitor.Log.WriteLine("Processing {0}", path); if (!Directory.Exists (path)) continue; foreach (var output in Directory.GetFiles (path, "*.*", SearchOption.AllDirectories)) { var link = string.Format ("Content{0}", output.Replace (path, "")); if (proj.Files.FirstOrDefault (x => Path.GetFileName (x.FilePath.ToString ()) == Path.GetFileName (output)) == null) { monitor.Log.WriteLine ("Auto Including Content {0}", output); proj.Files.Add (new ProjectFile (output, BuildAction.BundleResource) { Link = new MonoDevelop.Core.FilePath (link), Flags = ProjectItemFlags.DontPersist | ProjectItemFlags.Hidden, Visible = false, }); } } } return base.Compile (monitor, item, buildData); }
CommonTextEditorOptions (MonoDevelop.Ide.Gui.Content.TextStylePolicy currentPolicy) { UpdateStylePolicy (currentPolicy); MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.Changed += delegate(object sender, EventArgs e) { OnChanged (e); }; }
//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded? //maybe the item's type's SourceProject is null? public IEnumerable<IAnalysisFixAction> GetFixes (MonoDevelop.Ide.Gui.Document doc, object fix) { var renameFix = (RenameMemberFix) fix; var refactoring = new RenameRefactoring (); var options = new RefactoringOptions () { Document = doc, Dom = doc.Dom, SelectedItem = renameFix.Item, }; if (!refactoring.IsValid (options)) yield break; var prop = new RenameRefactoring.RenameProperties () { NewName = renameFix.NewName, }; yield return new RenameFixAction () { Label = GettextCatalog.GetString ("Rename '{0}' to '{1}'", renameFix.Item.Name, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = false, }; yield return new RenameFixAction () { Label = GettextCatalog.GetString ("Rename '{0}' to '{1}' with preview", renameFix.Item.Name, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = true, }; }
public override IEnumerable<MonoDevelop.CodeActions.CodeAction> GetActions (MonoDevelop.Ide.Gui.Document document, object refactoringContext, TextLocation loc, CancellationToken cancellationToken) { var context = refactoringContext as MDRefactoringContext; if (context == null) return Enumerable.Empty<MonoDevelop.CodeActions.CodeAction> (); return GetActions (context); }
public ProgressDialog (MonoDevelop.Components.Window parent, bool allowCancel, bool showDetails) { MonoDevelop.Components.IdeTheme.ApplyTheme (this); this.Build (); this.Title = BrandingService.ApplicationName; HasSeparator = false; ActionArea.Hide (); DefaultHeight = 5; TransientFor = parent; btnCancel.Visible = allowCancel; expander.Visible = showDetails; buffer = detailsTextView.Buffer; detailsTextView.Editable = false; bold = new TextTag ("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add (bold); tag = new TextTag ("0"); tag.Indent = 10; buffer.TagTable.Add (tag); tags.Add (tag); }
public override bool SupportsFramework (MonoDevelop.Core.Assemblies.TargetFramework framework) { if (!framework.IsCompatibleWithFramework (MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.NET_4_0)) return false; else return base.SupportsFramework (framework); }
public ISymbol GetLanguageItem (MonoDevelop.Ide.Gui.Document document, int offset, string identifier) { if (document.ParsedDocument == null) return null; var model = document.ParsedDocument.GetAst<SemanticModel> (); if (model == null) return null; int index = identifier.IndexOf ("`", System.StringComparison.Ordinal); int arity = 0; if (index != -1) { arity = int.Parse (identifier.Substring (index + 1)); identifier = identifier.Remove (index); } foreach (var symbol in model.LookupSymbols (offset, name: identifier)) { var typeSymbol = symbol as INamedTypeSymbol; if (typeSymbol != null && (arity == 0 || arity == typeSymbol.Arity)) { return symbol; } var namespaceSymbol = symbol as INamespaceSymbol; if (namespaceSymbol != null) { return namespaceSymbol; } } return null; }
protected override void Update(MonoDevelop.Components.Commands.CommandInfo info) { var possibleTasks = provider.GetPossibleRefactoring(); validTasks = possibleTasks.Where(t=>t.IsValid()); info.Enabled = validTasks.Any(); }
public override void ModifyTags( MonoDevelop.Projects.SolutionItem policyParent, MonoDevelop.Projects.Project project, string language, string identifier, string fileName, ref Dictionary<string, string> tags) { base.ModifyTags(policyParent, project, language, identifier, fileName, ref tags); const string ModuleNameTag = "ModuleName"; if (tags != null) { var dprj = project as AbstractDProject; if (dprj != null) { if(fileName != null) foreach (var basePath in dprj.GetSourcePaths()) { var bp = System.IO.Path.GetFullPath (basePath); if (fileName.StartsWith (bp)) { tags [ModuleNameTag] = DModule.GetModuleName (bp, fileName); break; } } } if(!tags.ContainsKey(ModuleNameTag)) tags [ModuleNameTag] = DModule.GetModuleName (project == null ? string.Empty : project.BaseDirectory.ToString (), fileName ?? identifier ?? string.Empty).Replace (' ', '_'); } }
public override bool Execute (MonoDevelop.Projects.SolutionItem solutionItem, out string message) { message = ""; var project = solutionItem as Project; var outputPath = project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration); string mpackOutputFolder = outputPath.ParentDirectory; using (var scope = base.TaskScope("Deleting mpack files...")) { foreach (var f in Directory.GetFiles (mpackOutputFolder, "*" + MDToolHelper.MPACK_FILE_EXTENSION)) { File.Delete (f); } } using (var scope = base.TaskScope ("Deleting mrep files...")) { foreach (var f in Directory.GetFiles (mpackOutputFolder, "*" + MDToolHelper.MREP_FILE_EXTENSION)) { File.Delete (f); } } CommandStatus ("Done!"); return true; }
public override State PushChar (char c, MonoDevelop.Xml.StateEngine.IParseContext context, ref string rollback) { //NOTE: This is (mostly) duplicated in HtmlTagState //handle inline tags implicitly closed by block-level elements if (context.CurrentStateLength == 1 && context.PreviousState is XmlNameState) { XClosingTag ct = (XClosingTag) context.Nodes.Peek (); if (!ct.Name.HasPrefix && ct.Name.IsValid) { //Note: the node stack will always be at least 1 deep due to the XDocument var parent = context.Nodes.Peek (1) as XElement; //if it's not a matching closing tag if (!string.Equals (ct.Name.Name, parent.Name.Name, StringComparison.OrdinalIgnoreCase)) { //attempt to implicitly close the parents while (parent.ValidAndNoPrefix () && parent.IsImplicitlyClosedBy (ct)) { context.Nodes.Pop (); context.Nodes.Pop (); if (warnAutoClose) { context.LogWarning (string.Format ("Tag '{0}' implicitly closed by closing tag '{1}'.", parent.Name.Name, ct.Name.Name), parent.Region); } //parent.Region.End = element.Region.Start; //parent.Region.EndColumn = Math.Max (parent.Region.EndColumn - 1, 1); parent.Close (parent); context.Nodes.Push (ct); parent = context.Nodes.Peek (1) as XElement; } } } } return base.PushChar (c, context, ref rollback); }
public static void FormatStatmentAt (MonoDevelop.Ide.Gui.Document data, DocumentLocation location) { var offset = data.Editor.LocationToOffset (location); var policyParent = data.Project != null ? data.Project.Policies : PolicyService.DefaultPolicies; var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType); Format (policyParent, mimeTypeChain, data, offset, offset, false, true); }
void OnParseInformationChanged (object sender, MonoDevelop.Projects.Dom.ParsedDocumentEventArgs args) { if (FileName == args.FileName && args.ParsedDocument != null) { parsedDoc = (T4ParsedDocument)args.ParsedDocument; RefreshOutline (); } }
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, out CodeCompletionContext codeCompletionContext) { var completion = CreateCompletion (editor, context, docInfo, out codeCompletionContext); completion.UpdateParsedDocument (); return completion; }
void OnParseInfoChanged (object sender, MonoDevelop.Projects.Dom.TypeUpdateInformationEventArgs e) { if (e.Project is DotNetProject && e.Project.ParentSolution == solution) { projectTimestamps [(DotNetProject)e.Project] = DateTime.Now; OnChanged (); } }
public SuggestedHandlerCompletionData (MonoDevelop.Projects.Project project, CodeMemberMethod methodInfo, INamedTypeSymbol codeBehindClass, Location codeBehindClassLocation) { this.project = project; this.methodInfo = methodInfo; this.codeBehindClass = codeBehindClass; this.codeBehindClassLocation = codeBehindClassLocation; }
public static void FormatStatmentAt (TextEditor editor, DocumentContext context, MonoDevelop.Ide.Editor.DocumentLocation location, OptionSet optionSet = null) { var offset = editor.LocationToOffset (location); var policyParent = context.Project != null ? context.Project.Policies : PolicyService.DefaultPolicies; var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType); Format (policyParent, mimeTypeChain, editor, context, offset, offset, false, true, optionSet: optionSet); }
public override bool AddToProject(MonoDevelop.Projects.SolutionItem policyParent, MonoDevelop.Projects.Project project, string language, string directory, string name) { // Create .cs file string sourceFileName = m_FileTemplate.GetFileName(policyParent, project, language, directory, name); m_FileTemplate.AddFileToProject(policyParent, project, language, directory, name); ProjectDomService.Parse(project, sourceFileName, null); // XXX: Shouldn't this be part of AddFileToProject? QyotoDesignInfo info = QyotoDesignInfo.FromProject(project, true); // Create .ui file string[,] tags = { {"Name", Path.GetFileNameWithoutExtension(name)} }; string content = m_UiNode.OuterXml; content = StringParserService.Parse(content, tags); XmlDocument doc = new XmlDocument(); doc.LoadXml(content); QyotoForm form = QyotoForm.WriteXml(doc.DocumentElement, info); info.Forms.Add(form); ProjectNodeBuilder.FilesChanged(project); return true; }
public override async System.Threading.Tasks.Task<SourceCodeLocation> GetSourceCodeLocationAsync (MonoDevelop.Projects.Project project, string fixtureTypeNamespace, string fixtureTypeName, string testName, System.Threading.CancellationToken cancellationToken) { var ctx = await TypeSystemService.GetCompilationAsync (project, cancellationToken).ConfigureAwait (false); var cls = ctx?.Assembly?.GetTypeByMetadataName (string.IsNullOrEmpty (fixtureTypeNamespace) ? fixtureTypeName : fixtureTypeNamespace + "." + fixtureTypeName); if (cls == null) return null; if (cls.Name != testName) { foreach (var met in cls.GetMembers ().OfType<IMethodSymbol> ()) { if (met.Name == testName) { var loc = met.Locations.FirstOrDefault (l => l.IsInSource); return ConvertToSourceCodeLocation (loc); } } int idx = testName != null ? testName.IndexOf ('(') : -1; if (idx > 0) { testName = testName.Substring (0, idx); foreach (var met in cls.GetMembers ().OfType<IMethodSymbol> ()) { if (met.Name == testName){ var loc = met.Locations.FirstOrDefault (l => l.IsInSource); return ConvertToSourceCodeLocation (loc); } } } } var classLoc = cls.Locations.FirstOrDefault (l => l.IsInSource); return ConvertToSourceCodeLocation (classLoc); }
public GenerateNamespaceImport GetResult (IUnresolvedFile unit, IType type, MonoDevelop.Ide.Gui.Document doc) { GenerateNamespaceImport result; if (cache.TryGetValue (type.Namespace, out result)) return result; result = new GenerateNamespaceImport (); cache[type.Namespace] = result; TextEditorData data = doc.Editor; result.InsertNamespace = false; var loc = new TextLocation (data.Caret.Line, data.Caret.Column); foreach (var ns in RefactoringOptions.GetUsedNamespaces (doc, loc)) { if (type.Namespace == ns) { result.GenerateUsing = false; return result; } } result.GenerateUsing = true; string name = type.Name; foreach (string ns in RefactoringOptions.GetUsedNamespaces (doc, loc)) { if (doc.Compilation.MainAssembly.GetTypeDefinition (ns, name, type.TypeParameterCount) != null) { result.GenerateUsing = false; result.InsertNamespace = true; return result; } } return result; }
public NRefactoryIndexerParameterDataProvider (MonoDevelop.Ide.Gui.TextEditor editor, IType type, string resolvedExpression) { this.editor = editor; // this.type = type; this.resolvedExpression = resolvedExpression; indexers = new List<IProperty> (type.Properties.Where (p => p.IsIndexer && !p.Name.Contains ('.'))); }