Example #1
0
 public void CalcInjectionPoints(CPClassLayout cpInjPoints, CPTraceVar traceVar)
 {
     foreach (var inclStmt in vcCodeModel.Includes)
     {
         VCCodeInclude vcinclStmt = (VCCodeInclude)inclStmt;
         CPInclude     incl       = null;
         string        fname      = Path.GetFileName(vcinclStmt.File);
         if (!cpInjPoints.includesPos.TryGetValue(new Tuple <string, string>(vcinclStmt.Name, fname), out incl))
         {
             if (vcinclStmt.Name == traceVar.defPos.fileName)
             {
                 // define include placement
                 FilePosText inclPos = new FilePosText()
                 {
                     fileName = fname,
                     pos      = { lineNum = vcinclStmt.StartPoint.Line - 1, linePos = vcinclStmt.StartPoint.LineCharOffset },
                     posEnd   = { lineNum = vcinclStmt.EndPoint.Line - 1, linePos = vcinclStmt.EndPoint.LineCharOffset }
                 };
                 incl = new CPInclude()
                 {
                     inclOrig    = vcinclStmt.Name,
                     inclReplace = "__cp__." + vcinclStmt.Name,
                     pos         = inclPos
                 };
                 cpInjPoints.includesPos.Add(new Tuple <string, string>(vcinclStmt.Name, incl.pos.fileName), incl);
             }
         }
     }
 }
Example #2
0
            public CPTraceVar CalcInjectionPoints(CPClassLayout cpClassLayout, string className, string _fname, ITextPosition pos, out bool needDeclare)
            {
                CPTraceVar traceVar = null;

                if (!cpClassLayout.traceVarPos.TryGetValue(name, out traceVar))
                {
                    needDeclare = true;
                    // add trace pos data
                    traceVar = new CPTraceVar()
                    {
                        name       = name,
                        uniqueName = uniqueName,
                        type       = type,
                        className  = className
                    };
                    cpClassLayout.traceVarPos.Add(traceVar.name, traceVar);
                    // define trace var definition placement
                    traceVar.defPos.fileName    = ent.ProjectItem.Name;
                    traceVar.defPos.pos.lineNum = ent.EndPoint.Line;           // - 1;
                    traceVar.defPos.pos.linePos = ent.EndPoint.LineCharOffset; // - 1;
                }
                else
                {
                    needDeclare = false;
                }
                // add trace pos
                traceVar.traceVarTracePos.Add(new FilePosPnt()
                {
                    fileName = _fname,
                    pos      = { lineNum = pos.lineNum, linePos = pos.linePos }
                });
                // check and add if need file containing original variable declaration
                TextPos traceInclPos = null;

                if (!cpClassLayout.traceInclPos.TryGetValue(ent.ProjectItem.Name, out traceInclPos))
                {
                    cpClassLayout.traceInclPos.Add(ent.ProjectItem.Name, new TextPos()
                    {
                        lineNum = 0, linePos = 0
                    });
                }

                return(traceVar);
            }
Example #3
0
 public void CalcInjectionPoints(CPClassLayout cpClassLayout, CPTraceVar traceVar, bool needDeclare)
 {
     if (needDeclare)
     {
         // find all places, where this file included
         CodeElement theFunc = null;
         // find & store all constructors init points of this class
         foreach (CodeElement _func in ent.Functions)
         {
             if (_func.Name == ent.Name)
             {
                 theFunc = _func;
                 VCCodeFunction vcFunc = (VCCodeFunction)_func;
                 EditPoint      pnt    = _func.StartPoint.CreateEditPoint();
                 if (pnt.FindPattern("{"))
                 {
                     traceVar.traceVarInitPos.Add(new FilePosPnt()
                     {
                         fileName = _func.ProjectItem.Name,
                         pos      = { lineNum = pnt.Line - 1, linePos = pnt.LineCharOffset }
                     });
                 }
             }
         }
         // if no constructor found add default one
         if (traceVar.traceVarInitPos.Count == 0)
         {
             EditPoint pnt = ent.StartPoint.CreateEditPoint();
             if (pnt.FindPattern("{"))
             {
                 traceVar.injConstructorPos = new FilePosPnt()
                 {
                     fileName = ent.ProjectItem.Name,
                     pos      = { lineNum = pnt.Line - 1, linePos = pnt.LineCharOffset }
                 };
             }
         }
     }
 }