MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / id

Method id

src/common/supportfile/language.cpp:77–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77QString Language::id(const QString &filePath)
78{
79 Language::initialize();
80 auto jsonObj = documents::languageGlobal.object();
81 QFileInfo info(filePath);
82 for (auto id : ids()) {
83 auto langObjChild = jsonObj.value(id).toObject();
84 QJsonArray suffixArray = langObjChild.value(Key_2::get()->suffix).toArray();
85 QJsonArray baseArray = langObjChild.value(Key_2::get()->base).toArray();
86 QJsonArray mimeArray = langObjChild.value(Key_2::get()->mimeType).toArray();
87
88 for (auto suffix : suffixArray) {
89 if (suffix.toString().isEmpty())
90 continue;
91
92 if (info.fileName().endsWith(suffix.toString()))
93 return id;
94
95 if (info.suffix() == suffix.toString())
96 return id;
97 }
98
99 for (auto base : baseArray) {
100 if (info.fileName() == base.toString()
101 || info.fileName().toLower() == base.toString().toLower()) {
102 return id;
103 }
104 }
105
106 QMimeDatabase mimeDB;
107 for (auto mime : mimeArray) {
108 if (mimeDB.mimeTypeForFile(info).name() == mime.toString()) {
109 return id;
110 }
111 }
112 }
113
114 return "";
115}
116
117QString Language::idAlias(const QString &id)
118{

Callers

nothing calls this directly

Calls 10

toArrayMethod · 0.80
endsWithMethod · 0.80
fileNameMethod · 0.80
initializeFunction · 0.50
getFunction · 0.50
objectMethod · 0.45
valueMethod · 0.45
isEmptyMethod · 0.45
toStringMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected