コード例 #1
0
        private void targetPicker_TargetSelected(object sender, TargetSelectedEventArgs ea)
        {
            CodeRush.UndoStack.BeginUpdate("Generalize");
            //Debug.Assert(String.IsNullOrEmpty(_fullBlockText), "fooey");
            SourcePoint targetPoint = ea.Location.EndInsertionPoint;

            CodeRush.Documents.ActiveTextDocument.ExpandText(targetPoint, "\r\n" + _activeBlock.Text);
            _activeBlock.Delete();
            //CodeRush.Documents.ActiveTextDocument.ExpandText(
            //    ea.Location.InsertionPoint,_fullBlockText);
            CodeRush.UndoStack.EndUpdate();
        }
コード例 #2
0
        public void OnStructureElementSelected(object sender, TargetSelectedEventArgs e)
        {
            var element = View3DManager.Model.Items.FirstOrDefault(item => item.IfcEntity.Equals(e.IfcEntity));

            if (element != null)
            {
                View3DManager.HighlightItem(element);
            }
            else
            {
                View3DManager.ClearItemsHighlight();
            }
        }
コード例 #3
0
 private void targetPicker1_TargetSelected(object sender, TargetSelectedEventArgs ea)
 {
     _InsertionPoint = ea.Location.SourcePoint;
       GenerateIDisposableImplementationCode();
 }
コード例 #4
0
        private void targetPicker1_TargetSelected(object sender, TargetSelectedEventArgs ea)
        {
            ElementBuilder elementBuilder = new ElementBuilder();
            bool missingDefaultConstructor = _TypeElement.HasDefaultConstructor();
            if (missingDefaultConstructor)
            {
                Method defaultConstructor = elementBuilder.BuildConstructor(null);
                defaultConstructor.Visibility = MemberVisibility.Public;
                defaultConstructor.Name = _TypeElement.Name;
                elementBuilder.AddNode(null, defaultConstructor);
            }
            Method constructor = elementBuilder.BuildConstructor(null);
            constructor.Visibility = MemberVisibility.Public;
            constructor.Name = _TypeElement.Name;
            elementBuilder.AddNode(null, constructor);

            foreach (Expression initializer in _InitializerExpression.Initializers)
            {
                MemberInitializerExpression memberInitializerExpression = initializer as MemberInitializerExpression;
                if (memberInitializerExpression == null)
                    continue;

                string parameterName = FormatAsParameter(memberInitializerExpression.Name);
                IElement initializerType = memberInitializerExpression.GetInitializerType();
                if (initializerType != null)
                {
                    Param param = new Param(initializerType.Name, parameterName);
                    constructor.Parameters.Add(param);

                    Assignment assignment = new Assignment();
                    ElementReferenceExpression leftSide = new ElementReferenceExpression(memberInitializerExpression.Name);
                    if (CodeRush.Language.IdentifiersMatch(memberInitializerExpression.Name, parameterName))
                    {
                        // Old way of building a "this.Xxxx" expression:
                        //string selfQualifier = CodeRush.Language.GenerateElement(new ThisReferenceExpression());
                        //leftSide = new ElementReferenceExpression(selfQualifier +  CodeRush.Language.MemberAccessOperator + memberInitializerExpression.Name);

                        // Recommended way of building a "this.Xxxx" expression:
                        leftSide = new QualifiedElementReference(memberInitializerExpression.Name);
                        leftSide.Qualifier = new ThisReferenceExpression();
                    }
                    assignment.LeftSide = leftSide;
                    assignment.Expression = new ElementReferenceExpression(parameterName);
                    constructor.AddNode(assignment);
                }
            }
            string newConstructorCode = elementBuilder.GenerateCode();
            // Use FileChange for multi-file changes...
            FileChange newConstructor = new FileChange();
            newConstructor.Path = _TypeElement.FirstFile.Name;
            newConstructor.Range = new SourceRange(ea.Location.SourcePoint, ea.Location.SourcePoint);
            newConstructor.Text = newConstructorCode;
            _Changes.Add(newConstructor);

            DevExpress.DXCore.TextBuffers.ICompoundAction action = CodeRush.TextBuffers.NewMultiFileCompoundAction("Create Constructor from Initializer");
            try
            {
                CodeRush.File.ApplyChanges(_Changes, true, false);
            }
            finally
            {
                action.Close();
                _Changes.Clear();
            }
        }
コード例 #5
0
 private void targetPicker_TargetSelected(object sender, TargetSelectedEventArgs ea)
 {
     CodeRush.UndoStack.BeginUpdate("Generalize");
     //Debug.Assert(String.IsNullOrEmpty(_fullBlockText), "fooey");
     SourcePoint targetPoint = ea.Location.EndInsertionPoint;
     CodeRush.Documents.ActiveTextDocument.ExpandText(targetPoint, "\r\n" + _activeBlock.Text);
     _activeBlock.Delete();
     //CodeRush.Documents.ActiveTextDocument.ExpandText(
     //    ea.Location.InsertionPoint,_fullBlockText);
     CodeRush.UndoStack.EndUpdate();
 }