Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Misc comment updates and renames.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsf committed Sep 20, 2010
1 parent 2e462ce commit abc6d57
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
13 changes: 10 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"io"
)

//-------------------------------------------------------------------------
// Config
//
// Structure represents persistent config storage of the gocode daemon. Usually
// the config is located somewhere in ~/.config/gocode directory.
//-------------------------------------------------------------------------

var Config = struct {
ProposeBuiltins bool "propose-builtins"
DenyPackageRenames bool "deny-package-renames"
Expand Down Expand Up @@ -203,7 +210,7 @@ func readConfig(v interface{}) os.Error {
return nil
}

func XDGHomeDir() string {
func xdgHomeDir() string {
xdghome := os.Getenv("XDG_CONFIG_HOME")
if xdghome == "" {
xdghome = path.Join(os.Getenv("HOME"), ".config")
Expand All @@ -212,12 +219,12 @@ func XDGHomeDir() string {
}

func makeSureConfigDirExists() {
dir := path.Join(XDGHomeDir(), "gocode")
dir := path.Join(xdgHomeDir(), "gocode")
if !fileExists(dir) {
os.MkdirAll(dir, 0755)
}
}

func configFile() string {
return path.Join(XDGHomeDir(), "gocode", "config.ini")
return path.Join(xdgHomeDir(), "gocode", "config.ini")
}
4 changes: 3 additions & 1 deletion decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ var declClassToString = [...]string{
//-------------------------------------------------------------------------

type Decl struct {
// Name starts with '$' if the declaration describes an anonymous type.
// '$s_%d' for anonymous struct types
// '$i_%d' for anonymous interface types
Name string
Type ast.Expr
Class int16
Flags int16

// functions for interface type, fields+methods for struct type
// variables with anonymous struct/interface type may have children too
Children map[string]*Decl

// embedded types
Expand Down
3 changes: 3 additions & 0 deletions declcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,13 @@ func pathAndAlias(imp *ast.ImportSpec) (string, string) {

func findGlobalFile(imp string) string {
pkgfile := fmt.Sprintf("%s.a", imp)

// if lib-path is defined, use it
if Config.LibPath != "" {
return path.Join(Config.LibPath, pkgfile)
}

// otherwise figure out the default lib-path
goroot := os.Getenv("GOROOT")
if goroot == "" {
goroot = runtime.GOROOT()
Expand Down
4 changes: 3 additions & 1 deletion goremote/goremote.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ func processFile(out io.Writer, filename string) {
}
}

const head = `package main
const head = `// WARNING! Autogenerated by goremote, don't touch.
package main
import (
"os"
Expand Down
7 changes: 4 additions & 3 deletions package.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import (

//-------------------------------------------------------------------------
// PackageFileCache
//
// Structure that represents a cache for an imported pacakge. In other words
// these are the contents of an archive (*.a) file.
//-------------------------------------------------------------------------

type PackageFileCache struct {
name string // file name
mtime int64
defalias string

// used as a temporary for foreignifying package contents
scope *Scope
main *Decl // package declaration
others map[string]*Decl
Expand All @@ -42,6 +44,7 @@ func NewPackageFileCache(name string) *PackageFileCache {
return m
}

// Creates a cache that stays in cache forever. Useful for built-in packages.
func NewPackageFileCacheForever(name, defalias string) *PackageFileCache {
m := new(PackageFileCache)
m.name = name
Expand All @@ -60,10 +63,8 @@ func (m *PackageFileCache) updateCache() {
}

if m.mtime != stat.Mtime_ns {
// clear tmp scope
m.mtime = stat.Mtime_ns

// try load new
data, err := ioutil.ReadFile(m.name)
if err != nil {
return
Expand Down
5 changes: 5 additions & 0 deletions ripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"go/scanner"
)

// All the code in this file serves single purpose:
// It separates a function with the cursor inside and the rest of the code. I'm
// doing that, because sometimes parser is not able to recover itself from an
// error and the autocompletion results become less complete.

type TokPos struct {
Tok token.Token
Pos token.Position
Expand Down
4 changes: 4 additions & 0 deletions scope.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package main

//-------------------------------------------------------------------------
// Scope
//-------------------------------------------------------------------------

type Scope struct {
parent *Scope // nil for universe scope
entities map[string]*Decl
Expand Down

0 comments on commit abc6d57

Please sign in to comment.