private void ConvertProperty(TextDocument textDocument, Property property) { if (textDocument == null || property == null) return; Property propertyClone = (Property)property.Clone(); string newPropertyCode = ChangeProperty(propertyClone); SourceRange propertyRange = property.Range.Clone(); textDocument.DeleteText(propertyRange); SourceRange newPropertyRange = textDocument.InsertText(propertyRange.Start, newPropertyCode); textDocument.Format(newPropertyRange); }
private void ConvertProperty(TextDocument textDocument, Property property, bool baseClassVersion, LanguageElement classExpression) { if (textDocument == null || property == null) return; Property propertyClone = (Property)property.Clone(); string newPropertyCode = ChangeProperty(propertyClone, baseClassVersion, classExpression); SourceRange propertyRange = property.Range.Clone(); textDocument.DeleteText(propertyRange); SourceRange newPropertyRange = textDocument.InsertText(propertyRange.Start, newPropertyCode); textDocument.Format(newPropertyRange); }
public virtual Differences VisitProperty(Property property1, Property property2){ Differences differences = this.GetMemberDifferences(property1, property2); if (differences == null){Debug.Assert(false); differences = new Differences(property1, property2);} if (differences.NumberOfDifferences > 0 || differences.NumberOfSimilarities > 0) return differences; if (property1 == null || property2 == null){ if (property1 != property2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } Property changes = (Property)property2.Clone(); Property deletions = (Property)property2.Clone(); Property insertions = (Property)property2.Clone(); AttributeList attrChanges, attrDeletions, attrInsertions; Differences diff = this.VisitAttributeList(property1.Attributes, property2.Attributes, out attrChanges, out attrDeletions, out attrInsertions); if (diff == null){Debug.Assert(false); return differences;} changes.Attributes = attrChanges; deletions.Attributes = attrDeletions; insertions.Attributes = attrInsertions; differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (property1.Flags == property2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++; diff = this.VisitMethod(property1.Getter, property2.Getter); if (diff == null){Debug.Assert(false); return differences;} changes.Getter = diff.Changes as Method; deletions.Getter = diff.Deletions as Method; insertions.Getter = diff.Insertions as Method; Debug.Assert(diff.Changes == changes.Getter && diff.Deletions == deletions.Getter && diff.Insertions == insertions.Getter); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; TypeNodeList typeChanges, typeDeletions, typeInsertions; diff = this.VisitTypeNodeList(property1.ImplementedTypes, property2.ImplementedTypes, out typeChanges, out typeDeletions, out typeInsertions); if (diff == null){Debug.Assert(false); return differences;} changes.ImplementedTypes = typeChanges; deletions.ImplementedTypes = typeDeletions; insertions.ImplementedTypes = typeInsertions; differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; diff = this.VisitIdentifier(property1.Name, property2.Name); if (diff == null){Debug.Assert(false); return differences;} changes.Name = diff.Changes as Identifier; deletions.Name = diff.Deletions as Identifier; insertions.Name = diff.Insertions as Identifier; Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; MethodList methChanges, methDeletions, methInsertions; diff = this.VisitMethodList(property1.OtherMethods, property2.OtherMethods, out methChanges, out methDeletions, out methInsertions); if (diff == null){Debug.Assert(false); return differences;} changes.OtherMethods = methChanges; deletions.OtherMethods = methDeletions; insertions.OtherMethods = methInsertions; differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (property1.OverridesBaseClassMember == property2.OverridesBaseClassMember) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++; ParameterList parChanges, parDeletions, parInsertions; diff = this.VisitParameterList(property1.Parameters, property2.Parameters, out parChanges, out parDeletions, out parInsertions); if (diff == null){Debug.Assert(false); return differences;} changes.Parameters = parChanges; deletions.Parameters = parDeletions; insertions.Parameters = parInsertions; differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; diff = this.VisitMethod(property1.Setter, property2.Setter); if (diff == null){Debug.Assert(false); return differences;} changes.Setter = diff.Changes as Method; deletions.Setter = diff.Deletions as Method; insertions.Setter = diff.Insertions as Method; Debug.Assert(diff.Changes == changes.Setter && diff.Deletions == deletions.Setter && diff.Insertions == insertions.Setter); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public void Clone_MakeClone_ReturnsNewObjectWithSameValue() { var context = new Context("context"); var prop = new Property<MyDummyClass1>("propertyname", context, CultureInfo.InvariantCulture); var dummyObject = new MyDummyClass1("my dummy object"); prop.Value = dummyObject; var newProp = (Property<MyDummyClass1>)prop.Clone(); Assert.AreNotSame(prop, newProp); Assert.AreEqual("my dummy object", newProp.Value.MyString); }