MCPcopy Create free account
hub / github.com/GuyARoss/orbit / parseInformalExportDefault

Method parseInformalExportDefault

pkg/jsparse/document.go:240–263  ·  view source on GitHub ↗
(pageDir string, line string)

Source from the content-addressed store, hash-verified

238}
239
240func (p *DefaultJSDocument) parseInformalExportDefault(pageDir string, line string) (bool, error) {
241 exportData := strings.TrimSpace(strings.Split(line, string(ExportDefaultToken))[1])
242 if len(exportData) == 0 {
243 return false, nil
244 }
245 if match := regexp.MustCompile("\\{|\\}|\\[|\\]|\\(|\\)"); !match.Match([]byte(exportData)) {
246 return false, nil
247 }
248
249 pageName := formatPathToPageName(pageDir)
250
251 p.AddOther(fmt.Sprintf("const %s = %s", pageName, exportData))
252 p.scope[pageName] = &JsDocumentScope{
253 Name: pageName,
254 Export: ExportDefault,
255 TokenType: ConstToken,
256 Args: make(JSDocArgList, 0),
257 }
258
259 p.defaultExport = p.scope[pageName]
260 p.name = pageName
261
262 return true, nil
263}
264
265func isIndexPath(finalPath string) bool {
266 // first we check if it can be found locally

Callers 2

tokenizeLineMethod · 0.95

Calls 2

AddOtherMethod · 0.95
formatPathToPageNameFunction · 0.85

Tested by 1