MCPcopy Index your code
hub / github.com/boyter/scc / ProcessConstants

Function ProcessConstants

processor/processor.go:239–305  ·  view source on GitHub ↗

ProcessConstants is responsible for setting up the language features based on the JSON file that is stored in constants Needs to be called at least once in order for anything to actually happen

()

Source from the content-addressed store, hash-verified

237// ProcessConstants is responsible for setting up the language features based on the JSON file that is stored in constants
238// Needs to be called at least once in order for anything to actually happen
239func ProcessConstants() {
240 startTime := makeTimestampNano()
241 for name, value := range languageDatabase {
242 for _, ext := range value.Extensions {
243 ExtensionToLanguage[ext] = append(ExtensionToLanguage[ext], name)
244 }
245
246 for _, fname := range value.FileNames {
247 FilenameToLanguage[fname] = name
248 }
249
250 if len(value.SheBangs) != 0 {
251 ShebangLookup[name] = value.SheBangs
252 }
253 }
254
255 // If we have anything in CountAs set it up now
256 if len(CountAs) != 0 {
257 setupCountAs()
258 }
259
260 printTraceF("nanoseconds build extension to language: %d", makeTimestampNano()-startTime)
261
262 // Configure COCOMO setting
263 _, ok := projectType[strings.ToLower(CocomoProjectType)]
264 if !ok {
265 // let's see if we can turn it into a custom one
266 spl := strings.Split(CocomoProjectType, ",")
267 val := []float64{}
268 if len(spl) == 5 {
269 // let's try to convert to float if we can
270 for i := 1; i < 5; i++ {
271 f, err := strconv.ParseFloat(spl[i], 64)
272 if err == nil {
273 val = append(val, f)
274 }
275 }
276 }
277
278 if len(val) == 4 {
279 projectType[CocomoProjectType] = val
280 } else {
281 // if nothing matches fall back to organic
282 CocomoProjectType = "organic"
283 }
284 }
285
286 // If lazy is set then we want to load in the features as we find them not in one go
287 // however otherwise being used as a library so just load them all in
288 if !isLazy {
289 startTime = makeTimestampMilli()
290 for name, value := range languageDatabase {
291 processLanguageFeature(name, value)
292 }
293
294 printTraceF("milliseconds build language features: %d", makeTimestampMilli()-startTime)
295 } else {
296 printTrace("configured to lazy load language features")

Callers 15

TestCountStatsIssue72Function · 0.85
TestCountStatsPr76Function · 0.85
TestCountStatsIssue62Function · 0.85
TestCountStatsIssue123Function · 0.85
TestCountStatsIssue230Function · 0.85
TestNewFileJobFullnameFunction · 0.85
TestNewFileJobFunction · 0.85
TestNewFileJobGitIgnoreFunction · 0.85
TestNewFileJobIgnoreFunction · 0.85
TestNewFileJobLicenseFunction · 0.85
TestNewFileJobYAMLFunction · 0.85

Calls 7

makeTimestampNanoFunction · 0.85
appendFunction · 0.85
setupCountAsFunction · 0.85
printTraceFFunction · 0.85
makeTimestampMilliFunction · 0.85
processLanguageFeatureFunction · 0.85
printTraceFunction · 0.85

Tested by 15

TestCountStatsIssue72Function · 0.68
TestCountStatsPr76Function · 0.68
TestCountStatsIssue62Function · 0.68
TestCountStatsIssue123Function · 0.68
TestCountStatsIssue230Function · 0.68
TestNewFileJobFullnameFunction · 0.68
TestNewFileJobFunction · 0.68
TestNewFileJobGitIgnoreFunction · 0.68
TestNewFileJobIgnoreFunction · 0.68
TestNewFileJobLicenseFunction · 0.68
TestNewFileJobYAMLFunction · 0.68