示例#1
0
 public static string sourceCodeLine(this MethodMapping methodMapping)
 {
     if (methodMapping.File.fileExists())
     {
         var sourceCodeLine = Files_WinForms.getLineFromSourceCode(methodMapping.File, methodMapping.Start_Line.uInt());
         if (methodMapping.SourceCode.contains(sourceCodeLine) || sourceCodeLine.contains(methodMapping.SourceCode))
         {
             return(sourceCodeLine.trim());
         }
         ;
     }
     return(methodMapping.SourceCode);
 }
示例#2
0
        public static int getINodePosition(this O2MappedAstData astData, MethodMapping methodMapping)
        {
            var position          = -1;
            var methodSignature   = methodMapping.ParentMethod;
            var iMethod           = astData.iMethod_withSignature(methodSignature);
            var methodDeclaration = astData.methodDeclaration(iMethod);
            var iNodes            = methodDeclaration.iNodes();

            if (iNodes.isNull())
            {
                return(position);
            }
            var iNodeAtLocation = astData.iNode(methodMapping.File, methodMapping.Start_Line, methodMapping.Start_Column);

            for (int i = 0; i < iNodes.size(); i++)
            {
                if (iNodes[i] == iNodeAtLocation)
                {
                    position = i;
                    break;
                }
            }
            if (position.eq(-1))
            {
                return(position);
            }
            //Hack to try to find the exact INode we had before
            if (position.typeName() != methodMapping.INodeType)
            {
                if (position > 0 && iNodes[position - 1].typeName() == methodMapping.INodeType)
                {
                    position--;
                }
                else
                if (position < (iNodes.size() - 1) && iNodes[position + 1].typeName() == methodMapping.INodeType)
                {
                    position++;
                }
            }
            return(position);
        }
 public static int getINodePosition(this O2MappedAstData astData, MethodMapping methodMapping)
 {
     var position = -1;
     var methodSignature = methodMapping.ParentMethod;
     var iMethod = astData.iMethod_withSignature(methodSignature);
     var methodDeclaration = astData.methodDeclaration(iMethod);
     var iNodes = methodDeclaration.iNodes();
     if (iNodes.isNull())
         return position;
     var iNodeAtLocation = astData.iNode(methodMapping.File,  methodMapping.Start_Line, methodMapping.Start_Column );
     for(int i=0; i < iNodes.size(); i++)
         if (iNodes[i] == iNodeAtLocation)
         {
             position = i;
             break;
         }
     if (position.eq(-1))
         return position;
     //Hack to try to find the exact INode we had before
     if (position.typeName() != methodMapping.INodeType)
     {
         if (position > 0 && iNodes[position-1].typeName() == methodMapping.INodeType)
             position--;
         else
             if (position < (iNodes.size()-1) &&iNodes[position+1].typeName() == methodMapping.INodeType)
                 position++;
     }
     return position;
 }