public void AddClassFilter(IReferenceType referenceType)
        {
            Contract.Requires <ArgumentNullException>(referenceType != null, "referenceType");
            Contract.Requires <VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(referenceType.GetVirtualMachine()));

            throw new NotImplementedException();
        }
        private bool IsAssignableFrom(IType targetType, IType sourceType)
        {
            Contract.Requires <ArgumentNullException>(targetType != null, "targetType");
            Contract.Requires <ArgumentNullException>(sourceType != null, "sourceType");

            if (targetType.Equals(sourceType))
            {
                return(true);
            }

            // primitive types must match exactly or fails
            if (targetType is IPrimitiveType || sourceType is IPrimitiveType)
            {
                return(false);
            }

            IReferenceType sourceReferenceType = sourceType as IReferenceType;

            if (sourceType == null)
            {
                throw new NotSupportedException();
            }

            HashSet <IReferenceType> types = new HashSet <IReferenceType>()
            {
                sourceReferenceType
            };

            GetInheritedTypes(sourceReferenceType, types);
            return(types.Contains(targetType));
        }
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(NMF.Models.IModelElement item)
 {
     if ((this._parent.Interface == null))
     {
         IInterface interfaceCasted = item.As <IInterface>();
         if ((interfaceCasted != null))
         {
             this._parent.Interface = interfaceCasted;
             return;
         }
     }
     if ((this._parent.DeclaringType == null))
     {
         IReferenceType declaringTypeCasted = item.As <IReferenceType>();
         if ((declaringTypeCasted != null))
         {
             this._parent.DeclaringType = declaringTypeCasted;
             return;
         }
     }
     if ((this._parent.Refines == null))
     {
         IReference refinesCasted = item.As <IReference>();
         if ((refinesCasted != null))
         {
             this._parent.Refines = refinesCasted;
             return;
         }
     }
 }
        public void AddClassFilter(IReferenceType referenceType)
        {
            Contract.Requires<ArgumentNullException>(referenceType != null, "referenceType");
            Contract.Requires<VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(referenceType.GetVirtualMachine()));

            throw new NotImplementedException();
        }
        protected static void GetInheritedTypes(IReferenceType type, HashSet <IReferenceType> inheritedTypes)
        {
            Contract.Requires <ArgumentNullException>(type != null, "type");
            Contract.Requires <ArgumentNullException>(inheritedTypes != null, "inheritedTypes");

            List <IReferenceType> immediateBases = new List <IReferenceType>();

            IClassType classtype = type as IClassType;

            if (classtype != null)
            {
                IClassType basetype = classtype.GetSuperclass();
                if (basetype != null)
                {
                    immediateBases.Add(basetype);
                }

                immediateBases.AddRange(classtype.GetInterfaces(false));
            }

            IInterfaceType interfacetype = type as IInterfaceType;

            if (interfacetype != null)
            {
                immediateBases.AddRange(interfacetype.GetSuperInterfaces());
            }

            foreach (var baseType in immediateBases)
            {
                if (inheritedTypes.Add(baseType))
                {
                    GetInheritedTypes(baseType, inheritedTypes);
                }
            }
        }
        /// <summary>
        /// Gets the derived-most property of a property.
        /// </summary>
        /// <param name="ppDerivedMost">Returns an IDebugProperty2 object that represents the derived-most property.</param>
        /// <returns>If successful, returns S_OK; otherwise returns error code. Returns S_GETDERIVEDMOST_NO_DERIVED_MOST if there is no derived-most property to retrieve.</returns>
        /// <remarks>
        /// For example, if this property describes an object that implements ClassRoot but which is actually an instantiation
        /// of ClassDerived that is derived from ClassRoot, then this method returns an IDebugProperty2 object describing the
        /// ClassDerived object.
        /// </remarks>
        public int GetDerivedMostProperty(out IDebugProperty2 ppDerivedMost)
        {
            ppDerivedMost = null;
            if (_evaluatedExpression.Value == null)
            {
                return(AD7Constants.S_GETDERIVEDMOST_NO_DERIVED_MOST);
            }

            IReferenceType propertyReferenceType = _evaluatedExpression.ValueType as IReferenceType;
            IReferenceType valueReferenceType    = _evaluatedExpression.Value.GetValueType() as IReferenceType;

            if (propertyReferenceType == null || valueReferenceType == null)
            {
                return(AD7Constants.S_GETDERIVEDMOST_NO_DERIVED_MOST);
            }

            if (valueReferenceType.Equals(propertyReferenceType))
            {
                return(AD7Constants.S_GETDERIVEDMOST_NO_DERIVED_MOST);
            }

            string castName = string.Format("({0})({1})", valueReferenceType.GetName(), _evaluatedExpression.FullName);

            ppDerivedMost = new JavaDebugProperty(this, _evaluatedExpression.Name, castName, valueReferenceType, _evaluatedExpression.Value, _evaluatedExpression.HasSideEffects, _evaluatedExpression.Field);
            return(VSConstants.S_OK);
        }
Example #7
0
        /// <summary>
        /// Tests whether the specified type is the same type
        /// as the CodeTypeInfo parameter describes.
        /// </summary>
        static bool Is(IType t, CodeTypeInfo cti)
        {
            ITypeReference r = t as ITypeReference;

            if (r != null)
            {
                return(Is(r, cti));
            }

            IArrayType a = t as IArrayType;

            if (a != null && cti != null)
            {
                return(Is(a.ElementType, cti.ArrayElementType) &&
                       (a.Dimensions.Count == cti.ArrayDimensions || (a.Dimensions.Count == 0 && cti.ArrayDimensions == 1)));
            }

            IReferenceType rt = t as IReferenceType;

            if (rt != null)
            {
                return(Is(rt.ElementType, cti));
            }

            IGenericArgument ga = t as IGenericArgument;

            if (ga != null)
            {
                return(true);
            }

            return(false);
        }
Example #8
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IModelElementExtension extensionsCasted = item.As <IModelElementExtension>();

                if ((extensionsCasted != null))
                {
                    this._parent.Extensions.Add(extensionsCasted);
                }
                if ((this._parent.Parent == null))
                {
                    NMF.Models.Meta.IModelElement parentCasted = item.As <NMF.Models.Meta.IModelElement>();
                    if ((parentCasted != null))
                    {
                        this._parent.Parent = parentCasted;
                        return;
                    }
                }
                if ((this._parent.Type == null))
                {
                    IReferenceType typeCasted = item.As <IReferenceType>();
                    if ((typeCasted != null))
                    {
                        this._parent.Type = typeCasted;
                        return;
                    }
                }
            }
Example #9
0
        public void Bind(JavaDebugProgram program, JavaDebugThread thread, IReferenceType type, IEnumerable <string> sourcePaths)
        {
            IVirtualMachine virtualMachine = program.VirtualMachine;

            IEnumerable <string> validPaths = sourcePaths.Where(i => string.Equals(Path.GetFileName(RequestLocation.DocumentPosition.GetFileName()), Path.GetFileName(i), StringComparison.OrdinalIgnoreCase));

            List <JavaDebugBoundBreakpoint> boundBreakpoints = new List <JavaDebugBoundBreakpoint>();
            List <IDebugErrorBreakpoint2>   errorBreakpoints = new List <IDebugErrorBreakpoint2>();

            foreach (var path in validPaths)
            {
                TextSpan range = RequestLocation.DocumentPosition.GetRange();
                try
                {
                    ReadOnlyCollection <ILocation> locations = type.GetLocationsOfLine(range.iStartLine + 1);
                    ILocation bindLocation = locations.OrderBy(i => i.GetCodeIndex()).FirstOrDefault();
                    if (bindLocation != null && IsFirstOnLine())
                    {
                        IEventRequestManager eventRequestManager = virtualMachine.GetEventRequestManager();

                        IBreakpointRequest eventRequest = eventRequestManager.CreateBreakpointRequest(bindLocation);
                        eventRequest.SuspendPolicy = SuspendPolicy.All;

                        JavaDebugCodeContext             codeContext     = new JavaDebugCodeContext(program, bindLocation);
                        BreakpointResolutionLocationCode location        = new BreakpointResolutionLocationCode(codeContext);
                        DebugBreakpointResolution        resolution      = new DebugBreakpointResolution(program, thread, enum_BP_TYPE.BPT_CODE, location);
                        JavaDebugBoundBreakpoint         boundBreakpoint = new JavaDebugBoundBreakpoint(this, program, eventRequest, resolution);
                        if (!_disabled)
                        {
                            boundBreakpoint.Enable(1);
                        }

                        boundBreakpoints.Add(boundBreakpoint);
                    }
                }
                catch (MissingInformationException)
                {
                }
            }

            _boundBreakpoints.AddRange(boundBreakpoints);
            if (boundBreakpoints.Count > 0)
            {
                _errorBreakpoints.Clear();
            }

            _errorBreakpoints.AddRange(errorBreakpoints);

            if (boundBreakpoints.Count > 0)
            {
                DebugEvent debugEvent = new DebugBreakpointBoundEvent(enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS, this, new EnumDebugBoundBreakpoints(boundBreakpoints));
                program.Callback.Event(DebugEngine, program.Process, program, null, debugEvent);
            }

            foreach (var errorBreakpoint in errorBreakpoints)
            {
                DebugEvent debugEvent = new DebugBreakpointErrorEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, errorBreakpoint);
                program.Callback.Event(DebugEngine, program.Process, program, null, debugEvent);
            }
        }
        public void AddClassFilter(IReferenceType referenceType)
        {
            ReferenceType type = referenceType as ReferenceType;
            if (type == null || !type.VirtualMachine.Equals(this.VirtualMachine))
                throw new VirtualMachineMismatchException();

            Modifiers.Add(Types.EventRequestModifier.ClassTypeFilter(type.ReferenceTypeId));
        }
Example #11
0
        public IExceptionRequest CreateExceptionRequest(IReferenceType referenceType, bool notifyCaught, bool notifyUncaught)
        {
            Contract.Requires <VirtualMachineMismatchException>(referenceType == null || this.GetVirtualMachine().Equals(referenceType.GetVirtualMachine()));
            Contract.Ensures(Contract.Result <IExceptionRequest>() != null);
            Contract.Ensures(this.GetVirtualMachine().Equals(Contract.Result <IExceptionRequest>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
Example #12
0
        internal ObjectReference(VirtualMachine virtualMachine, ObjectId objectId, IReferenceType referenceType)
            : base(virtualMachine)
        {
            Contract.Requires(virtualMachine != null);
            Contract.Requires<ArgumentException>(objectId.Handle != 0);

            _objectId = objectId;
            _referenceType = referenceType;
        }
Example #13
0
 public DoctorSearchController()
 {
     objIDoctorSearch = new DoctorSearch();
     objDepartment    = new DepartmentMaster();
     objHospital      = new HospitalMaster();
     objLocation      = new LocationMaster();
     objLanguage      = new LanguageMaster();
     objReferenceType = new ReferenceType();
 }
Example #14
0
        /// <summary>
        /// Gets called when the parent model element of the current model element is about to change
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanging(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent)
        {
            IReferenceType        oldDeclaringType = ModelHelper.CastAs <IReferenceType>(oldParent);
            IReferenceType        newDeclaringType = ModelHelper.CastAs <IReferenceType>(newParent);
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldDeclaringType, newDeclaringType);

            this.OnDeclaringTypeChanging(e);
            this.OnPropertyChanging("DeclaringType", e, _declaringTypeReference);
        }
Example #15
0
        internal ObjectReference(VirtualMachine virtualMachine, ObjectId objectId, IReferenceType referenceType)
            : base(virtualMachine)
        {
            Contract.Requires(virtualMachine != null);
            Contract.Requires <ArgumentException>(objectId.Handle != 0);

            _objectId      = objectId;
            _referenceType = referenceType;
        }
        public JavaDebugStaticMembersPseudoProperty(IDebugProperty2 parent, IReferenceType referenceType, IEnumerable<IField> fields)
        {
            Contract.Requires<ArgumentNullException>(parent != null, "parent");
            Contract.Requires<ArgumentNullException>(referenceType != null, "referenceType");

            _parent = parent;
            _referenceType = referenceType;
            if (fields != null)
                _fields = fields.ToArray();
        }
Example #17
0
        public void AddClassFilter(IReferenceType referenceType)
        {
            ReferenceType type = referenceType as ReferenceType;

            if (type == null || !type.VirtualMachine.Equals(this.VirtualMachine))
            {
                throw new VirtualMachineMismatchException();
            }

            Modifiers.Add(Types.EventRequestModifier.ClassTypeFilter(type.ReferenceTypeId));
        }
        private bool TryGetValueInScope(string name, out EvaluatedExpression result)
        {
            Contract.Requires <ArgumentNullException>(name != null, "name");
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(name));

            result = null;

            IMethod method = _stackFrame.GetLocation().GetMethod();

            // check the stack frame
            if (_stackFrame.GetHasVariableInfo())
            {
                ILocalVariable variable = _stackFrame.GetVisibleVariableByName(name);
                if (variable != null)
                {
                    result = new EvaluatedExpression(name, name, variable, _stackFrame.GetValue(variable), false);
                    return(true);
                }

                ReadOnlyCollection <ILocalVariable> variables = method.GetVariablesByName(name);
                if (variables.Count > 0)
                {
                    return(false);
                }
                //throw new InvalidOperationException("Evaluation failed because the variable is not visible in the current scope.");
            }

            // check the enclosing object for a visible field
            IReferenceType declaringType = method.GetDeclaringType();
            IField         field         = declaringType.GetFieldByName(name);

            if (field != null)
            {
                if (field.GetIsStatic())
                {
                    result = new EvaluatedExpression(name, name, null, field, declaringType.GetValue(field), false);
                    return(true);
                }

                if (method.GetIsStatic())
                {
                    return(false);
                }
                //throw new InvalidOperationException("The instance field cannot be accessed from a static method.");

                result = new EvaluatedExpression(name, name, _stackFrame.GetThisObject(), field, _stackFrame.GetThisObject().GetValue(field), false);
                return(true);
            }

            // check the outer object?

            return(false);
            //throw new NotImplementedException();
        }
        public JavaDebugStaticMembersPseudoProperty(IDebugProperty2 parent, IReferenceType referenceType, IEnumerable <IField> fields)
        {
            Contract.Requires <ArgumentNullException>(parent != null, "parent");
            Contract.Requires <ArgumentNullException>(referenceType != null, "referenceType");

            _parent        = parent;
            _referenceType = referenceType;
            if (fields != null)
            {
                _fields = fields.ToArray();
            }
        }
Example #20
0
        public IReferenceType GetReferenceType()
        {
            if (_referenceType == null)
            {
                TypeTag         typeTag;
                ReferenceTypeId typeId;
                DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetObjectReferenceType(out typeTag, out typeId, ObjectId));
                _referenceType = VirtualMachine.GetMirrorOf(typeTag, typeId);
            }

            return(_referenceType);
        }
        public bool Equals(IReferenceType other)
        {
            ReferenceType otherType = other as ReferenceType;

            if (otherType == null)
            {
                return(false);
            }

            return(this.VirtualMachine.Equals(otherType.VirtualMachine) &&
                   this.ReferenceTypeId == otherType.ReferenceTypeId);
        }
Example #22
0
        public bool Equals(IReferenceType other)
        {
            UnloadedReferenceType otherType = other as UnloadedReferenceType;

            if (otherType == null)
            {
                return(false);
            }

            return(this.VirtualMachine.Equals(otherType.VirtualMachine) &&
                   this.Signature == otherType.Signature);
        }
        internal DynamicReferenceInstance(IReferenceInstance refInstance) : base((IValueSymbol)refInstance)
        {
            this.normalizedDict = new Dictionary <string, ISymbol>(StringComparer.OrdinalIgnoreCase);
            IReferenceType  dataType = (IReferenceType)refInstance.DataType;
            IResolvableType type2    = (IResolvableType)dataType;

            this.resolvedReferenceType = (type2 == null) ? dataType : type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            if (this.resolvedReferenceType.Category == DataTypeCategory.Struct)
            {
                ReadOnlySymbolCollection subSymbols = ((IReferenceInstanceAccess)refInstance).SubSymbols;
                this.normalizedDict = DynamicStructInstance.createMemberDictionary(false, subSymbols);
            }
        }
Example #24
0
        public int CompareTo(object obj)
        {
            IReferenceType type = obj as IReferenceType;

            if (type == null)
            {
                return(-1);
            }
            else
            {
                return(this.ElementType.CompareTo(type.ElementType));
            }
        }
        private EvaluatedExpression GetField(EvaluatedExpression value, string name)
        {
            Contract.Requires <ArgumentNullException>(value != null, "value");
            Contract.Requires <ArgumentNullException>(name != null, "name");
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(name));

            IArrayReference arrayValue = value.Value as IArrayReference;

            if (arrayValue != null)
            {
                if (name == "length")
                {
                    string fullName = string.Format("({0}).{1}", value.FullName, name);
                    return(new EvaluatedExpression(name, fullName, _stackFrame.GetVirtualMachine().GetMirrorOf(arrayValue.GetLength()), value.HasSideEffects));
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            IReferenceType declaringType = value.ValueType as IReferenceType;

            if (declaringType == null)
            {
                throw new InvalidOperationException();
            }

            IField field = declaringType.GetFieldByName(name);

            if (field != null)
            {
                string fullName = string.Format("({0}).{1}", value.FullName, name);
                if (field.GetIsStatic())
                {
                    return(new EvaluatedExpression(name, fullName, null, field, declaringType.GetValue(field), value.HasSideEffects));
                }
                else
                {
                    IObjectReference objectReference = value.Value as IObjectReference;
                    if (objectReference == null)
                    {
                        throw new InvalidOperationException("Evaluation failed (todo: distinguish between null pointer and instance field referenced as a static field).");
                    }

                    return(new EvaluatedExpression(name, fullName, objectReference, field, objectReference.GetValue(field), value.HasSideEffects));
                }
            }

            throw new NotImplementedException();
        }
Example #26
0
        public static IAssembly GetTargetAssembly(IType type)
        {
            IReferenceType referenceType = type as IReferenceType;

            if (referenceType != null)
            {
                IAssembly referenceAssembly = referenceType.ReferenceAssembly;
                if (referenceAssembly != null)
                {
                    return(referenceAssembly);
                }
            }
            return(type.RuntimeAssembly);
        }
Example #27
0
        public IExceptionRequest CreateExceptionRequest(IReferenceType referenceType, bool notifyCaught, bool notifyUncaught)
        {
            ReferenceType type = referenceType as ReferenceType;

            if ((type == null || !type.VirtualMachine.Equals(this.VirtualMachine)) && referenceType != null)
            {
                throw new VirtualMachineMismatchException();
            }

            var request = new ExceptionRequest(VirtualMachine, type, notifyCaught, notifyUncaught);

            _exceptionRequests.Add(request);
            return(request);
        }
        private EvaluatedExpression GetArrayClass(EvaluatedExpression elementType)
        {
            Contract.Requires <ArgumentNullException>(elementType != null, "elementType");
            Contract.Ensures(Contract.Result <EvaluatedExpression>() != null);

            IClassObjectReference classObject = elementType.Value as IClassObjectReference;

            if (classObject == null)
            {
                throw new ArgumentException();
            }

            IReferenceType elementReflectedType = classObject.GetReflectedType();

            return(FindClass("[" + elementReflectedType.GetSignature()));
        }
 /// <summary>
 /// Determines whether two types are equivalent (Cecil/Reflector)
 /// </summary>
 /// <param name="typeref">Cecil type reference</param>
 /// <param name="type">Reflector type reference</param>
 /// <returns>true if equivalent</returns>
 private static bool TypeMatches(TypeReference typeref, IType type)
 {
     if (type is ITypeReference)
     {
         var ityperef = (ITypeReference)type;
         if (typeref.Namespace == ityperef.Namespace && IsSameName(typeref.Name, ityperef.Name))
         {
             if (typeref.DeclaringType != null && (ityperef.Owner) is ITypeReference)
             {
                 return(TypeMatches(typeref.DeclaringType, ((ITypeReference)ityperef.Owner)));
             }
             else
             {
                 return(true);
             }
         }
         return(false);
     }
     else if (type is IGenericParameter)
     {
         IGenericParameter igenprm = (IGenericParameter)type;
         return(typeref.Name.StartsWith(igenprm.Name));
     }
     else if (type is IGenericArgument)
     {
         IGenericArgument igenarg = (IGenericArgument)type;
         return(TypeMatches(typeref, igenarg.Owner.GenericArguments[igenarg.Position]));
     }
     else if ((type is IArrayType) && (typeref is ArrayType))
     {
         IArrayType iarrtyp = (IArrayType)type;
         return(TypeMatches(((ArrayType)typeref).ElementType, iarrtyp.ElementType));
     }
     else if ((type is IReferenceType) && (typeref is ByReferenceType))
     {
         IReferenceType iref = (IReferenceType)type;
         return(TypeMatches(((ByReferenceType)typeref).ElementType, iref.ElementType));
     }
     else if ((type is IPointerType) && (typeref is PointerType))
     {
         IPointerType ipt = (IPointerType)type;
         return(TypeMatches(((PointerType)typeref).ElementType, ipt.ElementType));
     }
     return(false);
 }
Example #30
0
        /// <summary>
        /// Gets called when the parent model element of the current model element changes
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanged(IModelElement newParent, IModelElement oldParent)
        {
            IReferenceType oldDeclaringType = ModelHelper.CastAs <IReferenceType>(oldParent);
            IReferenceType newDeclaringType = ModelHelper.CastAs <IReferenceType>(newParent);

            if ((oldDeclaringType != null))
            {
                oldDeclaringType.Events.Remove(this);
            }
            if ((newDeclaringType != null))
            {
                newDeclaringType.Events.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldDeclaringType, newDeclaringType);

            this.OnDeclaringTypeChanged(e);
            this.OnPropertyChanged("DeclaringType", e);
        }
Example #31
0
        /// <summary>
        /// Displays the references in the control.
        /// </summary>
        private void DisplayReferences(Session session, List <ReferenceDescription> references)
        {
            ReferencesLV.Items.Clear();

            for (int ii = 0; ii < references.Count; ii++)
            {
                ReferenceDescription reference = references[ii];

                string referenceType = null;

                // look up the name for the reference
                IReferenceType referenceTypeNode = session.NodeCache.Find(reference.ReferenceTypeId) as IReferenceType;

                if (referenceTypeNode != null)
                {
                    referenceType = referenceTypeNode.DisplayName.Text;

                    if (!reference.IsForward && !LocalizedText.IsNullOrEmpty(referenceTypeNode.InverseName))
                    {
                        referenceType = referenceTypeNode.InverseName.Text;
                    }
                }

                // the node cache is used to store the type model so it can be accessed locally.
                string typeDefinition = session.NodeCache.GetDisplayText(reference.TypeDefinition);

                ListViewItem item = new ListViewItem(referenceType);

                // the ToString() operator on the ReferenceDescription returns the target name.
                item.SubItems.Add(reference.ToString());
                item.SubItems.Add(reference.NodeClass.ToString());
                item.SubItems.Add(typeDefinition);

                item.Tag = reference;

                ReferencesLV.Items.Add(item);
            }

            // auto size the columns.
            for (int ii = 0; ii < ReferencesLV.Columns.Count; ii++)
            {
                ReferencesLV.Columns[ii].Width = -2;
            }
        }
Example #32
0
        /// <see cref="Opc.Ua.Client.Controls.BaseListCtrl.UpdateItem(ListViewItem,object)" />
        protected override void UpdateItem(ListViewItem listItem, object item)
        {
            IReference reference = item as IReference;

            if (reference == null)
            {
                base.UpdateItem(listItem, item);
                return;
            }

            IReferenceType referenceType = m_session.NodeCache.Find(reference.ReferenceTypeId) as IReferenceType;

            if (referenceType != null)
            {
                if (reference.IsInverse)
                {
                    listItem.SubItems[0].Text = Utils.Format("{0}", referenceType.InverseName);
                }
                else
                {
                    listItem.SubItems[0].Text = Utils.Format("{0}", referenceType.DisplayName);
                }
            }
            else
            {
                listItem.SubItems[0].Text = Utils.Format("{0}", reference.ReferenceTypeId);
            }

            INode target = m_session.NodeCache.Find(reference.TargetId) as INode;

            if (target != null)
            {
                listItem.SubItems[1].Text = Utils.Format("{0}", target.DisplayName);
            }
            else
            {
                listItem.SubItems[1].Text = Utils.Format("{0}", reference.TargetId);
            }

            listItem.ImageKey = GuiUtils.GetTargetIcon(m_session, NodeClass.ReferenceType, null);
            listItem.Tag      = reference;
        }
Example #33
0
        public static string RelativeSearch(this IReferenceType reference, string query)
        {
            switch (reference.Type)
            {
            case Reference.ItemRequest:
                return(ItemRequestCore.SearchUrl(query));

            case Reference.Item:
                return(ItemCore.SearchUrl(query));

            case Reference.User:
                return(ProfileCore.SearchUrl(query));

            case Reference.Company:
                return(CompanyCore.SearchUrl(query));

            default:
                return(null);
            }
        }
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(NMF.Models.IModelElement item)
 {
     if ((this._parent.Database == null))
     {
         IUserDBInterface databaseCasted = item.As <IUserDBInterface>();
         if ((databaseCasted != null))
         {
             this._parent.Database = databaseCasted;
             return;
         }
     }
     if ((this._parent.DeclaringType == null))
     {
         IReferenceType declaringTypeCasted = item.As <IReferenceType>();
         if ((declaringTypeCasted != null))
         {
             this._parent.DeclaringType = declaringTypeCasted;
             return;
         }
     }
 }
 internal ClassObjectReference(VirtualMachine virtualMachine, ClassObjectId objectId, IReferenceType classObjectType)
     : base(virtualMachine, objectId, classObjectType)
 {
     Contract.Requires(virtualMachine != null);
 }
        public void Bind(JavaDebugProgram program, JavaDebugThread thread, IReferenceType type, IEnumerable<string> sourcePaths)
        {
            IVirtualMachine virtualMachine = program.VirtualMachine;

            IEnumerable<string> validPaths = sourcePaths.Where(i => string.Equals(Path.GetFileName(RequestLocation.DocumentPosition.GetFileName()), Path.GetFileName(i), StringComparison.OrdinalIgnoreCase));

            List<JavaDebugBoundBreakpoint> boundBreakpoints = new List<JavaDebugBoundBreakpoint>();
            List<IDebugErrorBreakpoint2> errorBreakpoints = new List<IDebugErrorBreakpoint2>();
            foreach (var path in validPaths)
            {
                TextSpan range = RequestLocation.DocumentPosition.GetRange();
                try
                {
                    ReadOnlyCollection<ILocation> locations = type.GetLocationsOfLine(range.iStartLine + 1);
                    ILocation bindLocation = locations.OrderBy(i => i.GetCodeIndex()).FirstOrDefault();
                    if (bindLocation != null && IsFirstOnLine())
                    {
                        IEventRequestManager eventRequestManager = virtualMachine.GetEventRequestManager();

                        IBreakpointRequest eventRequest = eventRequestManager.CreateBreakpointRequest(bindLocation);
                        eventRequest.SuspendPolicy = SuspendPolicy.All;

                        JavaDebugCodeContext codeContext = new JavaDebugCodeContext(program, bindLocation);
                        BreakpointResolutionLocationCode location = new BreakpointResolutionLocationCode(codeContext);
                        DebugBreakpointResolution resolution = new DebugBreakpointResolution(program, thread, enum_BP_TYPE.BPT_CODE, location);
                        JavaDebugBoundBreakpoint boundBreakpoint = new JavaDebugBoundBreakpoint(this, program, eventRequest, resolution);
                        if (!_disabled)
                            boundBreakpoint.Enable(1);

                        boundBreakpoints.Add(boundBreakpoint);
                    }
                }
                catch (MissingInformationException)
                {
                }
            }

            _boundBreakpoints.AddRange(boundBreakpoints);
            if (boundBreakpoints.Count > 0)
            {
                _errorBreakpoints.Clear();
            }

            _errorBreakpoints.AddRange(errorBreakpoints);

            if (boundBreakpoints.Count > 0)
            {
                DebugEvent debugEvent = new DebugBreakpointBoundEvent(enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS, this, new EnumDebugBoundBreakpoints(boundBreakpoints));
                program.Callback.Event(DebugEngine, program.Process, program, null, debugEvent);
            }

            foreach (var errorBreakpoint in errorBreakpoints)
            {
                DebugEvent debugEvent = new DebugBreakpointErrorEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, errorBreakpoint);
                program.Callback.Event(DebugEngine, program.Process, program, null, debugEvent);
            }
        }
 public virtual void VisitReferenceType(IReferenceType value)
 {
     this.VisitType(value.ElementType);
 }
        public IExceptionRequest CreateExceptionRequest(IReferenceType referenceType, bool notifyCaught, bool notifyUncaught)
        {
            Contract.Requires<VirtualMachineMismatchException>(referenceType == null || this.GetVirtualMachine().Equals(referenceType.GetVirtualMachine()));
            Contract.Ensures(Contract.Result<IExceptionRequest>() != null);
            Contract.Ensures(this.GetVirtualMachine().Equals(Contract.Result<IExceptionRequest>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
Example #39
0
        public bool Equals(IReferenceType other)
        {
            ReferenceType otherType = other as ReferenceType;
            if (otherType == null)
                return false;

            return this.VirtualMachine.Equals(otherType.VirtualMachine)
                && this.ReferenceTypeId == otherType.ReferenceTypeId;
        }
 internal ClassLoaderReference(VirtualMachine virtualMachine, ClassLoaderId classLoaderId, IReferenceType classLoaderType)
     : base(virtualMachine, classLoaderId, classLoaderType)
 {
     Contract.Requires(virtualMachine != null);
 }
Example #41
0
        public IReferenceType GetReferenceType()
        {
            if (_referenceType == null)
            {
                TypeTag typeTag;
                ReferenceTypeId typeId;
                DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetObjectReferenceType(out typeTag, out typeId, ObjectId));
                _referenceType = VirtualMachine.GetMirrorOf(typeTag, typeId);
            }

            return _referenceType;
        }
Example #42
0
 internal ArrayReference(VirtualMachine virtualMachine, ArrayId arrayId, IReferenceType arrayType)
     : base(virtualMachine, arrayId, arrayType)
 {
     Contract.Requires(virtualMachine != null);
 }
 public JavaDebugStaticMembersPseudoProperty(IDebugProperty2 parent, IReferenceType referenceType)
     : this(parent, referenceType, null)
 {
 }
Example #44
0
 internal ThreadReference(VirtualMachine virtualMachine, ThreadId threadId, IReferenceType threadType)
     : base(virtualMachine, threadId, threadType)
 {
     Contract.Requires(virtualMachine != null);
 }
 public void AddClassFilter(IReferenceType referenceType)
 {
     throw new NotImplementedException();
 }
 public virtual IType TransformReferenceType(IReferenceType value)
 {
     value.ElementType = this.TransformType(value.ElementType);
     return value;
 }
        public bool Equals(IReferenceType other)
        {
            UnloadedReferenceType otherType = other as UnloadedReferenceType;
            if (otherType == null)
                return false;

            return this.VirtualMachine.Equals(otherType.VirtualMachine)
                && this.Signature == otherType.Signature;
        }
 public bool Equals(IReferenceType other)
 {
     throw new NotImplementedException();
 }
Example #49
0
        public IExceptionRequest CreateExceptionRequest(IReferenceType referenceType, bool notifyCaught, bool notifyUncaught)
        {
            ReferenceType type = referenceType as ReferenceType;
            if ((type == null || !type.VirtualMachine.Equals(this.VirtualMachine)) && referenceType != null)
                throw new VirtualMachineMismatchException();

            var request = new ExceptionRequest(VirtualMachine, type, notifyCaught, notifyUncaught);
            _exceptionRequests.Add(request);
            return request;
        }
Example #50
0
        internal void BindVirtualizedBreakpoints(JavaDebugProgram program, JavaDebugThread thread, IReferenceType type, IEnumerable<string> sourcePaths)
        {
            Contract.Requires<ArgumentNullException>(program != null, "program");
            Contract.Requires<ArgumentNullException>(sourcePaths != null, "sourcePaths");

            var breakpoints = VirtualizedBreakpoints.ToArray();
            foreach (var breakpoint in breakpoints)
            {
                breakpoint.Bind(program, thread, type, sourcePaths);
            }
        }