def resolveParentType(self,classDict): parentType = TypeReference() parentType.resolvedName = self.owner parentType.referencedName = \ utils.composeQualifiedName(self.package,self.owner) self.parentType = parentType # TODO package! className = utils.spliceClass( self.parentType.referencedName, \ utils.qualSeparator) srcLocs = classDict.getSourceLocations(className) if 1 == len(srcLocs): dstLoc = srcLocs[0][0] dstLineNr = srcLocs[0][1] self.parentType.sourceFile = dstLoc self.parentType.lineNr = dstLineNr #pkgName = pkgDict.getPackageForFile(dstLoc) #attrType.resolvedName = \ # utils.composeQualifiedName(pkgName,attrType.resolvedName) #attrType.sourceFile = dstLoc #attrType.lineNr = dstLineNr elif 0 == len(srcLocs): self.log.warn( "no source locations for attribute owner: "+\ self.parentType.referencedName+" of attribute "+\ self.owner+"."+self.name) self.parentType.sourceFile = "" self.parentType.lineNr = "0" else: self.log.warn( "multiple source locations for attribute owner: "+\ self.parentType.referencedName+" of attribute "+\ self.owner+"."+self.name) self.parentType.sourceFile = "" self.parentType.lineNr = "0"
def resolveParentType(self, classDict): parentType = TypeReference() parentType.resolvedName = self.owner parentType.referencedName = \ utils.composeQualifiedName(self.package,self.owner) self.parentType = parentType # TODO package! className = utils.spliceClass( self.parentType.referencedName, \ utils.qualSeparator) srcLocs = classDict.getSourceLocations(className) if 1 == len(srcLocs): dstLoc = srcLocs[0][0] dstLineNr = srcLocs[0][1] self.parentType.sourceFile = dstLoc self.parentType.lineNr = dstLineNr #pkgName = pkgDict.getPackageForFile(dstLoc) #attrType.resolvedName = \ # utils.composeQualifiedName(pkgName,attrType.resolvedName) #attrType.sourceFile = dstLoc #attrType.lineNr = dstLineNr elif 0 == len(srcLocs): self.log.warn( "no source locations for attribute owner: "+\ self.parentType.referencedName+" of attribute "+\ self.owner+"."+self.name) self.parentType.sourceFile = "" self.parentType.lineNr = "0" else: self.log.warn( "multiple source locations for attribute owner: "+\ self.parentType.referencedName+" of attribute "+\ self.owner+"."+self.name) self.parentType.sourceFile = "" self.parentType.lineNr = "0"
def __locateAttributeType(self, pkgDict, classDict, attrType): """ identifies the source location of the attributes' type def.""" if isPrimitiveType(attrType.resolvedName): # it is a primitive type, no source location for them attrType.resolvedName = "" attrType.sourceFile = "" attrType.lineNr = "0" self.attrType = attrType return # it is a class, but does the class dictionary know it? srcLocs = classDict.getSourceLocations(attrType.resolvedName) if 1 == len(srcLocs): dstLoc = srcLocs[0][0] dstLineNr = srcLocs[0][1] pkgName = pkgDict.getPackageForFile(dstLoc) attrType.resolvedName = \ utils.composeQualifiedName(pkgName,attrType.resolvedName) attrType.sourceFile = dstLoc attrType.lineNr = dstLineNr elif 0 == len(srcLocs): # is it a library type? don't log about them if not isLibraryType(attrType.resolvedName): self.log.warn( "no source locations for attribute type: "+\ attrType.resolvedName+" of attribute "+\ self.owner+"."+self.name) attrType.sourceFile = "" attrType.lineNr = "0" else: self.log.warn( "multiple source locations (",srcLocs,\ ") for attribute type: "+\ attrType.resolvedName+" of attribute "+self.owner+\ "."+self.name) attrType.sourceFile = "" attrType.lineNr = "0" self.attrType = attrType