static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const fileName, const langType language, stringList *holder) { if (finfo->name != NULL) vStringDelete (finfo->name); finfo->name = fileName; if (finfo->tagPath != NULL) { if (holder) stringListAdd (holder, finfo->tagPath); else vStringDelete (finfo->tagPath); } if (0) ; else if ( Option.tagRelative == TREL_ALWAYS ) finfo->tagPath = vStringNewOwn (relativeFilename (vStringValue (fileName), getTagFileDirectory ())); else if ( Option.tagRelative == TREL_NEVER ) finfo->tagPath = vStringNewOwn (absoluteFilename (vStringValue (fileName))); else if ( Option.tagRelative == TREL_NO || isAbsolutePath (vStringValue (fileName)) ) finfo->tagPath = vStringNewCopy (fileName); else finfo->tagPath = vStringNewOwn (relativeFilename (vStringValue (fileName), getTagFileDirectory ())); finfo->isHeader = isIncludeFile (vStringValue (fileName)); }
static void makeFunctionTag (tokenInfo *const token) { vString * fulltag; if ( ! token->ignoreTag ) { fulltag = vStringNew (); if (vStringLength (token->scope) > 0) { vStringCopy(fulltag, token->scope); vStringCatS (fulltag, "."); vStringCatS (fulltag, vStringValue(token->string)); } else { vStringCopy(fulltag, token->string); } vStringTerminate(fulltag); if ( ! stringListHas(FunctionNames, vStringValue (fulltag)) ) { stringListAdd (FunctionNames, vStringNewCopy (fulltag)); makeJsTag (token, JSTAG_FUNCTION); } vStringDelete (fulltag); } }
static void makeJsTag (tokenInfo *const token, const jsKind kind, vString *const signature) { if (JsKinds [kind].enabled && ! token->ignoreTag ) { const char *name = vStringValue (token->string); vString *fullscope = vStringNewCopy (token->scope); const char *p; tagEntryInfo e; if ( (p = strrchr (name, '.')) != NULL ) { if (vStringLength (fullscope) > 0) vStringPut (fullscope, '.'); vStringNCatS (fullscope, name, (size_t) (p - name)); name = p + 1; } initTagEntry (&e, name); e.lineNumber = token->lineNumber; e.filePosition = token->filePosition; e.kindName = JsKinds [kind].name; e.kind = JsKinds [kind].letter; if ( vStringLength(fullscope) > 0 ) { jsKind parent_kind = JSTAG_CLASS; /* * If we're creating a function (and not a method), * guess we're inside another function */ if (kind == JSTAG_FUNCTION) parent_kind = JSTAG_FUNCTION; e.extensionFields.scope[0] = JsKinds [parent_kind].name; e.extensionFields.scope[1] = vStringValue (fullscope); } if (signature && vStringLength(signature)) { size_t i; /* sanitize signature by replacing all control characters with a * space (because it's simple). * there should never be any junk in a valid signature, but who * knows what the user wrote and CTags doesn't cope well with weird * characters. */ for (i = 0; i < signature->length; i++) { unsigned char c = (unsigned char) signature->buffer[i]; if (c < 0x20 /* below space */ || c == 0x7F /* DEL */) signature->buffer[i] = ' '; } e.extensionFields.signature = vStringValue(signature); } makeTagEntry (&e); vStringDelete (fullscope); } }
static void makeClassTag (tokenInfo *const token, vString *const signature) { vString * fulltag; if ( ! token->ignoreTag ) { fulltag = vStringNew (); if (vStringLength (token->scope) > 0) { vStringCopy(fulltag, token->scope); vStringCatS (fulltag, "."); vStringCatS (fulltag, vStringValue(token->string)); } else { vStringCopy(fulltag, token->string); } vStringTerminate(fulltag); if ( ! stringListHas(ClassNames, vStringValue (fulltag)) ) { stringListAdd (ClassNames, vStringNewCopy (fulltag)); makeJsTag (token, JSTAG_CLASS, signature); } vStringDelete (fulltag); } }
/* * Emits a tag for the given 'name' of kind 'kind' at the current nesting. */ static void emitRubyTag (vString* name, rubyKind kind) { tagEntryInfo tag; vString* scope; if (!RubyKinds[kind].enabled) { return; } vStringTerminate (name); scope = stringListToScope (nesting); initTagEntry (&tag, vStringValue (name)); if (vStringLength (scope) > 0) { tag.extensionFields.scope [0] = "class"; tag.extensionFields.scope [1] = vStringValue (scope); } tag.kindName = RubyKinds [kind].name; tag.kind = RubyKinds [kind].letter; makeTagEntry (&tag); stringListAdd (nesting, vStringNewCopy (name)); vStringClear (name); vStringDelete (scope); }
static tokenInfo *copyToken (tokenInfo *other) { tokenInfo *const token = xMalloc (1, tokenInfo); token->type = other->type; token->keyword = other->keyword; token->string = vStringNewCopy (other->string); token->lineNumber = other->lineNumber; token->filePosition = other->filePosition; return token; }
static void reportType (tokenInfo *const token) { vStringUpper (token->string); if (vStringLength (token->string) > 0 && ! isGeneric (token) && (SelfReferences || strcmp (vStringValue ( token->string), vStringValue (token->className)) != 0) && ! stringListHas (ReferencedTypes, vStringValue (token->string))) { printf ("%s\n", vStringValue (token->string)); stringListAdd (ReferencedTypes, vStringNewCopy (token->string)); } }
static boolean setSourceFileName (vString *const fileName) { boolean result = FALSE; if (getFileLanguage (vStringValue (fileName)) != LANG_IGNORE) { vString *pathName; if (isAbsolutePath (vStringValue (fileName)) || File.path == NULL) pathName = vStringNewCopy (fileName); else pathName = combinePathAndFile ( vStringValue (File.path), vStringValue (fileName)); setSourceFileParameters (pathName); result = TRUE; } return result; }
static void makeJsTag (tokenInfo *const token, const jsKind kind) { if (JsKinds [kind].enabled && ! token->ignoreTag ) { const char *name = vStringValue (token->string); vString *fullscope = vStringNewCopy (token->scope); const char *p; tagEntryInfo e; if ( (p = strrchr (name, '.')) != NULL ) { if (vStringLength (fullscope) > 0) vStringPut (fullscope, '.'); vStringNCatS (fullscope, name, (size_t) (p - name)); name = p + 1; } initTagEntry (&e, name); e.lineNumber = token->lineNumber; e.filePosition = token->filePosition; e.kindName = JsKinds [kind].name; e.kind = JsKinds [kind].letter; if ( vStringLength(fullscope) > 0 ) { jsKind parent_kind = JSTAG_CLASS; /* * If we're creating a function (and not a method), * guess we're inside another function */ if (kind == JSTAG_FUNCTION) parent_kind = JSTAG_FUNCTION; e.extensionFields.scope[0] = JsKinds [parent_kind].name; e.extensionFields.scope[1] = vStringValue (fullscope); } makeTagEntry (&e); vStringDelete (fullscope); } }
static bool setSourceFileName (vString *const fileName) { const langType language = getLanguageForFilenameAndContents (vStringValue (fileName)); bool result = false; if (language != LANG_IGNORE) { vString *pathName; if (isAbsolutePath (vStringValue (fileName)) || File.path == NULL) pathName = vStringNewCopy (fileName); else { char *tmp = combinePathAndFile ( vStringValue (File.path), vStringValue (fileName)); pathName = vStringNewOwn (tmp); } setSourceFileParameters (pathName, language); result = true; } return result; }
static boolean setSourceFileName (vString *const fileName) { const langType language = getFileLanguage (vStringValue (fileName)); boolean result = FALSE; if (language != LANG_IGNORE) { vString *pathName; if (isAbsolutePath (vStringValue (fileName)) || File.path == NULL) pathName = vStringNewCopy (fileName); else { char *tmp = combinePathAndFile ( vStringValue (File.path), vStringValue (fileName)); pathName = vStringNewOwn (tmp); } setSourceFileParameters (pathName, language); result = TRUE; } return result; }
static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const fileName, const langType language, stringList *holder) { if (finfo->name != NULL) vStringDelete (finfo->name); finfo->name = fileName; if (finfo->tagPath != NULL) { if (holder) stringListAdd (holder, finfo->tagPath); else vStringDelete (finfo->tagPath); } if (! Option.tagRelative || isAbsolutePath (vStringValue (fileName))) finfo->tagPath = vStringNewCopy (fileName); else finfo->tagPath = vStringNewOwn (relativeFilename (vStringValue (fileName), TagFile.directory)); finfo->isHeader = isIncludeFile (vStringValue (fileName)); finfo->language = language; }
/* * Emits a tag for the given 'name' of kind 'kind' at the current nesting. */ static void emitRubyTag (vString* name, rubyKind kind) { tagEntryInfo tag; vString* scope; const char *this_name; vStringTerminate (name); scope = stringListToScope (nesting); /* extract scope and actual name from tag name in case of tags like * "class Foo::Bar::Baz" which are parsed as a single name, "Foo.Bar.Baz" */ this_name = strrchr (vStringValue (name), '.'); if (this_name) { if (vStringLength (scope) > 0) vStringPut (scope, '.'); vStringNCat (scope, name, this_name - vStringValue (name)); vStringTerminate (scope); this_name ++; } else this_name = vStringValue (name); initTagEntry (&tag, this_name); if (vStringLength (scope) > 0) { tag.extensionFields.scope [0] = "class"; tag.extensionFields.scope [1] = vStringValue (scope); } tag.kindName = RubyKinds [kind].name; tag.kind = RubyKinds [kind].letter; makeTagEntry (&tag); stringListAdd (nesting, vStringNewCopy (name)); vStringClear (name); vStringDelete (scope); }
/* Function format: * "fn" <ident>[<type_bounds>] "(" [<args>] ")" ["->" <ret_type>] "{" [<body>] "}"*/ static void parseFn (lexerState *lexer, vString *scope, int parent_kind) { int kind = (parent_kind == K_TRAIT || parent_kind == K_IMPL) ? K_METHOD : K_FN; vString *name; vString *arg_list; unsigned long line; fpos_t pos; int paren_level = 0; boolean found_paren = FALSE; boolean valid_signature = TRUE; advanceToken(lexer, TRUE); if (lexer->cur_token != TOKEN_IDENT) return; name = vStringNewCopy(lexer->token_str); arg_list = vStringNew(); line = lexer->line; pos = lexer->pos; advanceToken(lexer, TRUE); /* HACK: This is a bit coarse as far as what tag entry means by * 'arglist'... */ while (lexer->cur_token != '{' && lexer->cur_token != ';') { if (lexer->cur_token == '}') { valid_signature = FALSE; break; } else if (lexer->cur_token == '(') { found_paren = TRUE; paren_level++; } else if (lexer->cur_token == ')') { paren_level--; if (paren_level < 0) { valid_signature = FALSE; break; } } else if (lexer->cur_token == TOKEN_EOF) { valid_signature = FALSE; break; } writeCurTokenToStr(lexer, arg_list); advanceToken(lexer, FALSE); } if (!found_paren || paren_level != 0) valid_signature = FALSE; if (valid_signature) { vStringStripTrailing(arg_list); addTag(name, arg_list->buffer, kind, line, pos, scope, parent_kind); addToScope(scope, name); parseBlock(lexer, TRUE, kind, scope); } vStringDelete(name); vStringDelete(arg_list); }
static void addGenericName (tokenInfo *const token) { vStringUpper (token->string); if (vStringLength (token->string) > 0) stringListAdd (GenericNames, vStringNewCopy (token->string)); }