public override void Complete(ICSharpCode.AvalonEdit.Editing.TextArea textArea, ICSharpCode.AvalonEdit.Document.ISegment completionSegment, EventArgs insertionRequestEventArgs) { var insertion = Action == null ? this.Text : Action.Invoke(); textArea.Document.Replace(completionSegment, insertion); if (insertion.EndsWith("(")) _parent.ShowCompletions(_control); }
public void RawlyIndentLine(int tabsToInsert, ICSharpCode.AvalonEdit.Document.TextDocument document, DocumentLine line) { if (!_doBeginUpdateManually) document.BeginUpdate(); /* * 1) Remove old indentation * 2) Insert new one */ // 1) int prevInd = 0; int curOff = line.Offset; if (curOff < document.TextLength) { char curChar = '\0'; while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t')) { prevInd++; curOff++; } document.Remove(line.Offset, prevInd); } // 2) string indentString = ""; for (int i = 0; i < tabsToInsert; i++) indentString += dEditor.Editor.Options.IndentationString; document.Insert(line.Offset, indentString); if (!_doBeginUpdateManually) document.EndUpdate(); }
public override object VisitVariableDeclaration(ICSharpCode.NRefactory.Ast.VariableDeclaration variableDeclaration, object data) { if (!(variableDeclaration.Parent is LocalVariableDeclaration)) { this.ReplaceCurrentNode(new ExpressionStatement(new AssignmentExpression(new IdentifierExpression(variableDeclaration.Name), AssignmentOperatorType.Assign, variableDeclaration.Initializer))); } return base.VisitVariableDeclaration(variableDeclaration, data); }
public override void CreateDataSection (ICSharpCode.Reports.Core.BaseSection section) { if (section == null) { throw new ArgumentNullException("section"); } Size detailSize = Size.Empty; Size itemSize = Size.Empty; Point rowLoction = Point.Empty; if (base.ReportModel.ReportSettings.GroupColumnsCollection.Count > 0) { var groupheader = base.CreateGroupHeader(new Point (GlobalValues.ControlMargins.Left,GlobalValues.ControlMargins.Top)); base.ReportModel.DetailSection.Items.Add(groupheader); // Detail itemSize = CreateDetail(); detailSize = new Size(Container.Size.Width,itemSize.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); // GroupFooter var groupFooter = base.CreateFooter(new Point(GlobalValues.ControlMargins.Left,80)); base.ReportModel.DetailSection.Items.Add(groupFooter); section.Size = new Size(section.Size.Width,125); rowLoction = new Point (Container.Location.X,45); } else { itemSize = CreateDetail(); detailSize = new Size(Container.Size.Width,itemSize.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); section.Size = new Size(section.Size.Width,Container.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); rowLoction = new Point(Container.Location.X,GlobalValues.ControlMargins.Top); } base.ConfigureDetails (rowLoction,detailSize); section.Items.Add(Container as BaseReportItem); }
//readonly dnlibLoader loader = new dnlibLoader(); public string GetTypeNameForAttribute(ICSharpCode.NRefactory.CSharp.Attribute attribute) { var mr = attribute.Type.Annotations .OfType<IMemberRef>() .FirstOrDefault(); return mr == null ? string.Empty : mr.FullName; }
private static void DecompressAndWriteFile(string destination, ICSharpCode.SharpZipLib.Zip.ZipInputStream source) { FileStream wstream = null; try { // create a stream to write the file to wstream = System.IO.File.Create(destination); const int block = 2048; // number of bytes to decompress for each read from the source byte[] data = new byte[block]; // location to decompress the file to // now decompress and write each block of data for the zip file entry while (true) { int size = source.Read(data, 0, data.Length); if (size > 0) wstream.Write(data, 0, size); else break; // no more data } } catch (Exception) { throw; } finally { if (wstream != null) wstream.Close(); } }
public NRefactoryCodeAction (string id, string title, ICSharpCode.NRefactory.CSharp.Refactoring.CodeAction act) { this.IdString = id; this.Title = title; this.act = act; this.DocumentRegion = new Mono.TextEditor.DocumentRegion (act.Start, act.End); }
protected override void Run(ICSharpCode.TextEditor.TextEditorControl textEditor, ICSharpCode.SharpDevelop.Dom.Refactoring.RefactoringProvider provider) { if (textEditor.ActiveTextAreaControl.SelectionManager.HasSomethingSelected) { MethodExtractorBase extractor = GetCurrentExtractor(textEditor); if (extractor != null) { if (extractor.Extract()) { ExtractMethodForm form = new ExtractMethodForm(extractor.ExtractedMethod, new Func<IOutputAstVisitor>(extractor.GetOutputVisitor)); if (form.ShowDialog() == DialogResult.OK) { extractor.ExtractedMethod.Name = form.Text; try { textEditor.Document.UndoStack.StartUndoGroup(); extractor.InsertAfterCurrentMethod(); extractor.InsertCall(); textEditor.Document.FormattingStrategy.IndentLines(textEditor.ActiveTextAreaControl.TextArea, 0, textEditor.Document.TotalNumberOfLines - 1); } finally { textEditor.Document.UndoStack.EndUndoGroup(); } textEditor.ActiveTextAreaControl.SelectionManager.ClearSelection(); } } } } }
void RetrieveRegions(ICompilationUnit cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker) { for (int i = 0; i < tracker.CurrentSpecials.Count; ++i) { ICSharpCode.NRefactory.PreprocessingDirective directive = tracker.CurrentSpecials[i] as ICSharpCode.NRefactory.PreprocessingDirective; if (directive != null) { if (directive.Cmd == "#region") { int deep = 1; for (int j = i + 1; j < tracker.CurrentSpecials.Count; ++j) { ICSharpCode.NRefactory.PreprocessingDirective nextDirective = tracker.CurrentSpecials[j] as ICSharpCode.NRefactory.PreprocessingDirective; if (nextDirective != null) { switch (nextDirective.Cmd) { case "#region": ++deep; break; case "#endregion": --deep; if (deep == 0) { cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim(), new DomRegion(directive.StartPosition, nextDirective.EndPosition))); goto end; } break; } } } end: ; } } } }
public bool IsValid(object owner, ICSharpCode.Core.Condition condition) { if (!condition.Properties.Contains(NodeTypeKey)) return false; string nodeTypeString = condition.Properties[NodeTypeKey]; XmlEditor editor = owner as XmlEditor; if (editor == null) return false; XmlViewSingleContent view = LogicalTreeHelper.FindLogicalNode(editor, "xmlView") as XmlViewSingleContent; if (view == null || view.ActiveViewer == null) return false; XmlNode targetNode = view.ActiveViewer.GetCaretNode(); if (targetNode == null) return false; if (nodeTypeString.Equals("LeafElement")) { if (targetNode.NodeType == XmlNodeType.Element && targetNode.ChildNodes.Count == 1 && targetNode.FirstChild.NodeType == XmlNodeType.Text) return true; return false; } else return targetNode.NodeType.ToString().Equals(nodeTypeString); }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if ((line.LineNumber == LineNumber) && IsEnabled) { ChangeLinePart(line.Offset, line.EndOffset, element => element.TextRunProperties.SetBackgroundBrush(Brushes.Yellow)); } }
public void Inject(ICSharpCode.ILSpy.TreeNodes.ILSpyTreeNode node, string name, IMetadataTokenProvider member) { //Name and namespace var typeName = node is ModuleTreeNode ? (name.Substring(name.Contains(".") ? name.LastIndexOf('.') + 1 : 0)) : name; var typeNamespace = node is ModuleTreeNode ? (name.Substring(0, name.Contains(".") ? name.LastIndexOf('.') : 0)) : string.Empty; //Checks that the typename isn't empty if (string.IsNullOrEmpty(typeName)) { MessageBox.Show("Please, specify the name of the type", "Type name required", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Creates a new class definition var c = new TypeDefinition( typeNamespace, typeName, TypeAttributes.Class | TypeAttributes.Interface | TypeAttributes.Public | TypeAttributes.AutoClass | TypeAttributes.AnsiClass | TypeAttributes.Abstract ) { IsAnsiClass = true, }; //Adds to the node Helpers.Tree.AddTreeNode(node, c, null, null); }
public override void IndentLine(ICSharpCode.AvalonEdit.Document.TextDocument document, ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (CodeEditorOptions.Instance.UseSmartIndentation) base.IndentLine(document, line); else new DefaultIndentationStrategy().IndentLine(document, line); }
public ToolTipData (ICSharpCode.NRefactory.CSharp.SyntaxTree unit, ICSharpCode.NRefactory.Semantics.ResolveResult result, ICSharpCode.NRefactory.CSharp.AstNode node, CSharpAstResolver file) { this.Unit = unit; this.Result = result; this.Node = node; this.Resolver = file; }
protected override string GetFieldString(ICSharpCode.NRefactory.TypeSystem.IField field, OutputSettings settings) { if (field == null) return ""; var result = new StringBuilder (); bool isEnum = field.DeclaringTypeDefinition != null && field.DeclaringTypeDefinition.Kind == TypeKind.Enum; AppendModifiers (result, settings, field); if (!settings.CompletionListFomat && settings.IncludeReturnType && !isEnum) { result.Append (GetTypeReferenceString (field.ReturnType, settings)); result.Append (settings.Markup (" ")); } if (!settings.IncludeReturnType && settings.UseFullName) { result.Append (GetTypeReferenceString (field.DeclaringTypeDefinition, settings)); result.Append (settings.Markup (".")); } result.Append (settings.EmitName (field, FilterName (Format (field.Name)))); if (settings.CompletionListFomat && settings.IncludeReturnType && !isEnum) { result.Append (settings.Markup (" : ")); result.Append (GetTypeReferenceString (field.ReturnType, settings)); } return result.ToString (); }
public static void DrawString (Graphics graphics,string text, ICSharpCode.Reports.Core.Exporter.TextStyleDecorator decorator) { if (graphics == null) { throw new ArgumentNullException("graphics"); } if (decorator == null) { throw new ArgumentNullException("decorator"); } StringFormat stringFormat = BuildStringFormat(decorator.StringTrimming,decorator.ContentAlignment); string formattedString = text; if (! String.IsNullOrEmpty(decorator.FormatString)) { formattedString = StandardFormatter.FormatOutput(text,decorator.FormatString,decorator.DataType,"yyy"); } graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.DrawString (formattedString,decorator.Font, new SolidBrush(decorator.ForeColor), new Rectangle(decorator.Location.X, decorator.Location.Y, decorator.Size.Width, decorator.Size.Height), stringFormat); }
public void DrawBorder (iTextSharp.text.pdf.PdfContentByte contentByte, iTextSharp.text.Rectangle rectangle, ICSharpCode.Reports.Core.Exporter.IBaseStyleDecorator style) { if ( contentByte == null) { throw new ArgumentNullException("contentByte"); } contentByte.SetColorStroke(style.PdfFrameColor); contentByte.SetLineWidth(UnitConverter.FromPixel(baseline.Thickness).Point); contentByte.MoveTo(rectangle.Left ,rectangle.Top ); contentByte.LineTo(rectangle.Left, rectangle.Top - rectangle.Height); contentByte.LineTo(rectangle.Left + rectangle.Width, rectangle.Top - rectangle.Height); contentByte.LineTo(rectangle.Left + rectangle.Width, rectangle.Top); contentByte.LineTo(rectangle.Left, rectangle.Top); contentByte.FillStroke(); contentByte.ResetRGBColorFill(); }
public override object VisitLocalVariableDeclaration (ICSharpCode.NRefactory.Ast.LocalVariableDeclaration localVariableDeclaration, object data) { object result = base.VisitLocalVariableDeclaration (localVariableDeclaration, data); if (localVariableDeclaration.Variables.Count == 0) RemoveCurrentNode (); return result; }
public void FillTree (ICSharpCode.TreeView.SharpTreeView tree,Module module) { var root = CreateTreeItem(module); tree.Root = root; foreach (var ns in module.Namespaces) { var namespaceNode = CreateTreeItem(ns); tree.Root.Children.Add(namespaceNode); foreach (var type in ns.Types) { var typeNode = CreateTreeItem(type); namespaceNode.Children.Add(typeNode); foreach (var method in type.Methods) { var methodName = CreateTreeItem(method); namespaceNode.Children.Add(methodName); } foreach (var field in type.Fields) { var fieldNode = CreateTreeItem(field); namespaceNode.Children.Add(fieldNode); } } } }
public override object VisitIdentifierExpression(ICSharpCode.NRefactory.Ast.IdentifierExpression identifierExpression, object data) { if (Compare(identifierExpression)) { identifiers.Add(identifierExpression); } return base.VisitIdentifierExpression(identifierExpression, data); }
/// <summary> /// Class constructor /// </summary> /// <param name="document"></param> /// <param name="offset"></param> /// <returns></returns> public BracketSearchResult SearchBracket(ICSharpCode.AvalonEdit.Document.ITextSource document, int offset) { if (offset > 0) { char c = document.GetCharAt(offset - 1); int index = openingBrackets.IndexOf(c); int otherOffset = -1; if (index > -1) otherOffset = SearchBracketForward(document, offset, openingBrackets[index], closingBrackets[index]); index = closingBrackets.IndexOf(c); if (index > -1) otherOffset = SearchBracketBackward(document, offset -1, openingBrackets[index], closingBrackets[index]); // if we found the other bracket if (otherOffset > -1 ) return new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1, Math.Max(offset - 1, otherOffset), 1); if (otherOffset == -2) // in string return null; // if we are on a bracket, but did not find a match if (index >= 0 || openingBrackets.IndexOf(c) >= 0) return new BracketSearchResult(offset - 1, 1, 0, 0); } return null; }
public object Visit (ICSharpCode.NRefactory.Comment comment, object data) { MonoDevelop.Projects.Dom.Comment newComment = new MonoDevelop.Projects.Dom.Comment (); newComment.CommentStartsLine = comment.CommentStartsLine; newComment.Text = comment.CommentText; int commentTagLength = comment.CommentType == ICSharpCode.NRefactory.CommentType.Documentation ? 3 : 2; int commentEndOffset = comment.CommentType == ICSharpCode.NRefactory.CommentType.Block ? 0 : 1; newComment.Region = new DomRegion (comment.StartPosition.Line, comment.StartPosition.Column - commentTagLength, comment.EndPosition.Line, comment.EndPosition.Column - commentEndOffset); switch (comment.CommentType) { case ICSharpCode.NRefactory.CommentType.Block: newComment.CommentType = MonoDevelop.Projects.Dom.CommentType.MultiLine; break; case ICSharpCode.NRefactory.CommentType.Documentation: newComment.CommentType = MonoDevelop.Projects.Dom.CommentType.SingleLine; newComment.IsDocumentation = true; break; default: newComment.CommentType = MonoDevelop.Projects.Dom.CommentType.SingleLine; break; } result.Add (newComment); return null; }
public override void DecompileMethod(ilspy::Mono.Cecil.MethodDefinition method, ICSharpCode.Decompiler.ITextOutput output, DecompilationOptions options) { var cmethod = GetCompiledMethod(method); if ((cmethod != null) && (cmethod.DexMethod != null)) { try { var f = new MethodBodyDisassemblyFormatter(cmethod.DexMethod, MapFile); var formatOptions = FormatOptions.EmbedSourceCode | FormatOptions.ShowJumpTargets; if(ShowFullNames) formatOptions |= FormatOptions.FullTypeNames; if(DebugOperandTypes) formatOptions |= FormatOptions.DebugOperandTypes; var s = f.Format(formatOptions); output.Write(s); } catch (Exception) { output.Write("\n\n// Formatting error. Using Fallback.\n\n"); FallbackFormatting(output, cmethod); } } else { output.Write("Method not found in dex"); output.WriteLine(); } }
public ScreenRectToPdfRectConverter(ICSharpCode.Reports.Core.Exporter.ExportRenderer.PdfUnitConverter converter) { if (converter == null) { throw new ArgumentNullException("converter"); } this.converter = converter; }
public static void SetSyntax(ICSharpCode.TextEditor.TextEditorControl editor, string fileName) { string syntax = "XML"; if (fileName.LastIndexOf('.') > 0) { string extension = fileName.Substring(fileName.LastIndexOf('.') + 1).ToUpper(); switch (extension) { case "BAS": case "VBS": case "VB": syntax = "VBNET"; break; case "CS": syntax = "C#"; break; case "CMD": case "BAT": syntax = "BAT"; break; case "C": case "RC": case "IDL": case "H": case "CPP": syntax = "C#"; break; default: break; } } editor.SetHighlighting(syntax); }
public bool GoToEntity(ICSharpCode.NRefactory.TypeSystem.IEntity entity) { var pad = SD.Workbench.GetPad(typeof(ClassBrowserPad)); pad.BringPadToFront(); var content = (ClassBrowserPad)pad.PadContent; return content.GoToEntity(entity); }
public string GetTypeNameForAttribute(ICSharpCode.NRefactory.CSharp.Attribute attribute) { return attribute.Type.Annotations .OfType<Mono.Cecil.MemberReference>() .First() .FullName; }
protected override bool Refactor(ICSharpCode.SharpDevelop.Editor.ITextEditor editor, System.Xml.Linq.XDocument document) { RemoveRecursive(document.Root, "Margin"); RemoveRecursive(document.Root, "MinWidth"); RemoveRecursive(document.Root, "MinHeight"); return true; }
public ComplexPropertiesMapping(TypeBase type, MappingBase mapping, ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType.EntityType table) { Type = type; Mapping = mapping; Table = table; TPC = true; }
public override IEnumerable<IEditorScript> GetScripts(ICSharpCode.AvalonEdit.Document.ITextSource text, int offset) { var item = GetCurrentItem(text, offset); if (item != null) { var generator = new ScriptMenuGenerator() { Conn = _conn, ConnData = _connData, Items = new[] { item } }; return generator.GetScripts().Concat(Enumerable.Repeat(new EditorScriptExecute() { Name = "Transform: Criteria to Where Clause", Execute = () => { var doc = text as IDocument; if (doc != null) { var segment = GetCurrentQuerySegment(text, offset); var elem = XElement.Load(text.CreateReader(segment.Offset, segment.Length)); AmlTransforms.CriteriaToWhereClause(elem); doc.Replace(segment.Offset, segment.Length, elem.ToString()); } return Task.FromResult(true); } }, 1)); } return Enumerable.Empty<IEditorScript>(); }
public Type CompileAndLoad() { CompilerResults results = null; using (CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary <string, string>() { { "CompilerVersion", "v3.5" }, })) { CompilerParameters options = new CompilerParameters(); foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { if (!asm.GetName().Name.Contains(Name)) { options.ReferencedAssemblies.Add(asm.Location); } } options.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location); // disabled due to a bug in 2.0.0.3956; //options.GenerateInMemory = true; options.GenerateExecutable = false; options.TempFiles = new TempFileCollection(TempFolder, false); options.IncludeDebugInformation = false; options.OutputAssembly = string.Format("{0}\\CodeAssembly{1:N}.dll", TempFolder, Guid.NewGuid()); options.CompilerOptions = "/optimize"; CsharpStringBuilder = new StringBuilder(); CsharpStringBuilder.Append(prefix); // Line numbers are used to identify actions that genorated compile errors. int currentLine = CsharpStringBuilder.ToString().Count(c => c == '\n') + 1; // genorate CanRun Methods foreach (var met in CsharpCodeDict) { if (met.Value.CodeType == CsharpCodeType.BoolExpression) { CsharpStringBuilder.AppendFormat("public bool {0} (object context){{return {1};}}\n", met.Key, met.Value.Code); } else if (met.Value.CodeType == CsharpCodeType.Statements) { CsharpStringBuilder.AppendFormat("public void {0} (object context){{{1}}}\n", met.Key, met.Value.Code); } met.Value.CodeLineNumber = currentLine++; } CsharpStringBuilder.Append(postfix); results = provider.CompileAssemblyFromSource( options, CsharpStringBuilder.ToString()); } if (results.Errors.HasErrors) { if (results.Errors.Count > 0) { foreach (CompilerError error in results.Errors) { ICSharpCode icsc = CsharpCodeDict.Values.FirstOrDefault(c => c.CodeLineNumber == error.Line); if (icsc != null) { Professionbuddy.Err("{0}\nCompile Error : {1}\n", ((IPBComposite)icsc).Title, error.ErrorText); icsc.CompileError = error.ErrorText; } else { Professionbuddy.Err("Unable to link action that produced Error: {0}", error.ErrorText); } } MainForm.Instance.RefreshActionTree(typeof(ICSharpCode)); } return(null); } else { CodeWasModified = false; return(results.CompiledAssembly.GetType("CodeDriver")); } }