35 lines
673 B
Go
35 lines
673 B
Go
|
package importer
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
"path/filepath"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
type Class struct {
|
||
|
Name string
|
||
|
Content string
|
||
|
FilePath string
|
||
|
}
|
||
|
|
||
|
func ImportClasses(filePath string) (map[string]Class, error) {
|
||
|
content, err := ioutil.ReadFile(filePath)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("error reading file '%s': %w", filePath, err)
|
||
|
}
|
||
|
|
||
|
classes := make(map[string]Class)
|
||
|
lines := strings.Split(string(content), "\n")
|
||
|
var currentClass *Class
|
||
|
var nestedContent strings.Builder
|
||
|
|
||
|
for _, line := range lines {
|
||
|
line = strings.TrimSpace(line)
|
||
|
if strings.HasPrefix(line, "<class") {
|
||
|
name := extractAttributeValue(line, "name")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|