<s> from devon . projects import jump <EOL> import os . path , re <EOL> reStrings = ( <EOL> r'<STR_LIT>' , <EOL> r"<STR_LIT>" , <EOL> ) <EOL> reCIncludes = ( <EOL> r"<STR_LIT>" , <EOL> r'<STR_LIT>' , <EOL> ) <EOL> reFileNameCandidate = re . compile ( r"<STR_LIT>" ) <EOL> class CJumper ( jump . Jumper ) : <EOL> def canHandleFileType ( self , ext ) : <EOL> return ext in ( "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT:h>" , "<STR_LIT>" ) <EOL> canHandleFileType = classmethod ( canHandleFileType ) <EOL> def jumpRelative ( self , sourcePath , relative ) : <EOL> if relative == "<STR_LIT>" : <EOL> return self . getJumpRelativeUp ( sourcePath ) <EOL> else : <EOL> return jump . Jumper . jumpRelative ( self , sourcePath , relative ) <EOL> def jumpText ( self , sourcePath , sourceText , caretOffset ) : <EOL> sourceDirPath = os . path . dirname ( sourcePath ) <EOL> for ( target , relist ) in jump . getPatternMatch ( sourceText , [ reCIncludes , reStrings ] ) : <EOL> fullPath = jump . expandIncludedPath ( self . project , sourceDirPath , target ) <EOL> if fullPath : <EOL> return fullPath <EOL> if reFileNameCandidate . match ( sourceText ) : <EOL> fullPath = jump . expandProjectPath ( self . project , sourceText ) <EOL> if fullPath : <EOL> return fullPath <EOL> def getJumpRelativeUp ( self , sourcePath ) : <EOL> implExts = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> headExts = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> sourceDirPath = os . path . dirname ( sourcePath ) <EOL> sourceName , sourceExt = os . path . splitext ( sourcePath ) <EOL> candidateExts = None <EOL> if sourceExt in implExts : <EOL> candidateExts = headExts <EOL> elif sourceExt in headExts : <EOL> candidateExts = implExts <EOL> if candidateExts : <EOL> sourceFileName = os . path . basename ( sourceName ) <EOL> for ext in candidateExts : <EOL> targetPath = "<STR_LIT>" % ( sourceFileName , ext ) <EOL> fullPath = jump . recurseProjectPaths ( self . project , sourceDirPath , targetPath ) <EOL> if fullPath : <EOL> return fullPath </s>
