-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1500 from xushiwei/typesutil
typesutil.Check: support Go/Go+ mixed project
- Loading branch information
Showing
4 changed files
with
78 additions
and
200 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2023 The GoPlus Authors (goplus.org). All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package typesutil | ||
|
||
import ( | ||
"go/token" | ||
"go/types" | ||
"unsafe" | ||
) | ||
|
||
// A Scope maintains a set of objects and links to its containing | ||
// (parent) and contained (children) scopes. Objects may be inserted | ||
// and looked up by name. The zero value for Scope is a ready-to-use | ||
// empty scope. | ||
type Scope struct { | ||
parent *Scope | ||
children []*Scope | ||
number int // parent.children[number-1] is this scope; 0 if there is no parent | ||
elems map[string]types.Object // lazily allocated | ||
pos, end token.Pos // scope extent; may be invalid | ||
comment string // for debugging only | ||
isFunc bool // set if this is a function scope (internal use only) | ||
} | ||
|
||
// ScopeDelete deletes an object from specified scope by its name. | ||
func ScopeDelete(s *types.Scope, name string) { | ||
delete((*Scope)(unsafe.Pointer(s)).elems, name) | ||
} |