func (s *CTagsRunner) Run(ctx *types.Context) error { buildProperties := ctx.BuildProperties ctagsTargetFilePath := ctx.CTagsTargetFile logger := ctx.GetLogger() properties := buildProperties.Clone() properties.Merge(buildProperties.SubTree(constants.BUILD_PROPERTIES_TOOLS_KEY).SubTree(constants.CTAGS)) properties[constants.BUILD_PROPERTIES_SOURCE_FILE] = ctagsTargetFilePath pattern := properties[constants.BUILD_PROPERTIES_PATTERN] if pattern == constants.EMPTY_STRING { return i18n.ErrorfWithLogger(logger, constants.MSG_PATTERN_MISSING, constants.CTAGS) } commandLine := properties.ExpandPropsInString(pattern) command, err := utils.PrepareCommand(commandLine, logger) if err != nil { return i18n.WrapError(err) } verbose := ctx.Verbose if verbose { fmt.Println(commandLine) } sourceBytes, err := command.Output() if err != nil { return i18n.WrapError(err) } ctx.CTagsOutput = string(sourceBytes) parser := &ctags.CTagsParser{} ctx.CTagsOfPreprocessedSource = parser.Parse(ctx.CTagsOutput) protos, line := parser.GeneratePrototypes() if line != -1 { ctx.PrototypesLineWhereToInsert = line } ctx.Prototypes = protos return nil }
func (s *CTagsParser) Run(ctx *types.Context) error { rows := strings.Split(ctx.CTagsOutput, "\n") rows = removeEmpty(rows) var tags []*types.CTag for _, row := range rows { tags = append(tags, parseTag(row)) } skipTagsWhere(tags, tagIsUnknown, ctx) skipTagsWhere(tags, tagIsUnhandled, ctx) addPrototypes(tags) removeDefinedProtypes(tags, ctx) removeDuplicate(tags) skipTagsWhere(tags, prototypeAndCodeDontMatch, ctx) ctx.CTagsOfPreprocessedSource = tags return nil }