gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name , gboolean update, const char* name) { if (0 == source_file_class_id) source_file_class_id = tm_work_object_register(tm_source_file_free , tm_source_file_update, NULL); #ifdef TM_DEBUG g_message("Source File init: %s", file_name); #endif if (FALSE == tm_work_object_init(&(source_file->work_object), source_file_class_id, file_name, FALSE)) return FALSE; source_file->inactive = FALSE; if (NULL == LanguageTable) { initializeParsing(); installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; if (NULL == TagEntrySetArglistFunction) TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } if (name == NULL) source_file->lang = LANG_AUTO; else source_file->lang = getNamedLanguage(name); if (update) tm_source_file_update(TM_WORK_OBJECT(source_file), TRUE, FALSE, FALSE); return TRUE; }
gint tm_source_file_get_named_lang(const gchar *name) { if (NULL == LanguageTable) { initializeParsing(); installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; if (NULL == TagEntrySetArglistFunction) TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } return getNamedLanguage(name); }
static langType getInterpreterLanguage (const char *const fileName) { langType result = LANG_IGNORE; FILE* const fp = fopen (fileName, "r"); if (fp != NULL) { vString* const vLine = vStringNew (); const char* const line = readLine (vLine, fp); if (line != NULL && line [0] == '#' && line [1] == '!') { const char* const lastSlash = strrchr (line, '/'); const char *const cmd = lastSlash != NULL ? lastSlash+1 : line+2; vString* const interpreter = determineInterpreter (cmd); result = getExtensionLanguage (vStringValue (interpreter)); if (result == LANG_IGNORE) result = getNamedLanguage (vStringValue (interpreter)); vStringDelete (interpreter); } vStringDelete (vLine); fclose (fp); } return result; }
static void qtMocMakeTagForProperty (CXXToken * pToken, const char *pszType) { tagEntryInfo tag; initTagEntry(&tag, vStringValue(pToken->pszWord), K_PROPERTY); tag.lineNumber = pToken->iLineNumber; tag.filePosition = pToken->oFilePosition; tag.isFileScope = false; if(!cxxScopeIsGlobal()) { tag.extensionFields.scopeLangType = getNamedLanguage ("C++", 0); /* ??? */ tag.extensionFields.scopeKindIndex = cxxScopeGetKind(); tag.extensionFields.scopeName = cxxScopeGetFullName(); } tag.extensionFields.typeRef[0] = "typename"; tag.extensionFields.typeRef[1] = pszType; makeTagEntry(&tag); }
extern langType getLanguageComponentInFieldName (const char *fullName, const char **fieldName) { const char *tmp; langType language; tmp = strchr (fullName, '.'); if (tmp) { size_t len = tmp - fullName; if (len == 1 && fullName[0] == '*') { language = LANG_AUTO; *fieldName = tmp + 1; } else if (len == 0) { language = LANG_IGNORE; *fieldName = tmp + 1; } else { language = getNamedLanguage (fullName, len); if (language == LANG_IGNORE) *fieldName = NULL; else *fieldName = tmp + 1; } } else { language = LANG_AUTO; *fieldName = fullName; } return language; }