NaturalDocs:: SymbolTable:: Symbol

A class representing a symbol or a potential symbol. 

Summary
A class representing a symbol or a potential symbol.
The class is implemented as a blessed arrayref.
Creates and returns a new object.
Adds a symbol definition.
Changes the information about an existing definition.
Removes a symbol definition.
Adds a reference that can be interpreted as this symbol.
Deletes a reference that can be interpreted as this symbol.
Removes all references that can be interpreted as this symbol.
Returns whether the symbol is defined anywhere or not.
Returns whether the symbol is defined in the passed file.
Returns an array of all the files that define this symbol.
Returns the file that contains the global definition of this symbol, or undef if the symbol isn’t defined.
Returns the type of symbol defined in the passed file, or undef if it’s not defined in that file.
Returns the type of the global definition.
Returns the prototype of symbol defined in the passed file, or undef if it doesn’t exist or is not defined in that file.
Returns the prototype of the global definition.
Returns whether the symbol can be interpreted as any references.
Returns an array of all the references that can be interpreted as this symbol.
Returns a hash of all the references that can be interpreted as this symbol and their scores.

Implementation

Members

The class is implemented as a blessed arrayref.  The following constants are its members. 

DEFINITIONSA hashref of all the files which define this symbol.  The keys are the file names, and the values are NaturalDocs::SymbolTable::SymbolDefinition objects.  If no files define this symbol, this item will be undef. 
GLOBAL_DEFINITIONThe name of the file which defines the global version of the symbol, which is what is used if a file references the symbol but does not have its own definition.  If there are no definitions, this item will be undef. 
REFERENCESA hashref of the references that can be interpreted as this symbol.  This doesn’t mean these references necessarily are.  The keys are the reference strings, and the values are the scores of the interpretations.  If no references can be interpreted as this symbol, this item will be undef. 

Modification Functions

New

sub New

Creates and returns a new object. 

AddDefinition

sub AddDefinition #(file, type, prototype)

Adds a symbol definition.  If this is the first definition for this symbol, it will become the global definition.  If the definition already exists for the file, it will be ignored. 

Parameters

fileThe file that defines the symbol. 
typeThe topic type of the definition.  One of Topic Types
prototypeThe prototype of the definition, if applicable.  Undef otherwise. 

ChangeDefinition

sub ChangeDefinition #(file, type, prototype)

Changes the information about an existing definition. 

Parameters

fileThe file that defines the symbol.  Must exist. 
typeThe new topic type of the definition.  One of Topic Types
prototypeThe new prototype of the definition, if applicable.  Undef otherwise. 

DeleteDefinition

sub DeleteDefinition #(file)

Removes a symbol definition.  If the definition served as the global definition, a new one will be selected. 

Parameters

fileThe definition to delete. 

AddReference

sub AddReference #(referenceString, score)

Adds a reference that can be interpreted as this symbol.  It can be, but not necessarily is. 

Parameters

referenceStringThe string of the reference. 
scoreThe score of this interpretation. 

DeleteReference

sub DeleteReference #(referenceString)

Deletes a reference that can be interpreted as this symbol. 

Parameters

referenceStringThe string of the reference to delete. 

DeleteAllReferences

sub DeleteAllReferences

Removes all references that can be interpreted as this symbol. 

Information Functions

IsDefined

sub IsDefined

Returns whether the symbol is defined anywhere or not.  If it’s not, that means it’s just a potential interpretation of a reference. 

IsDefinedIn

sub IsDefinedIn #(file)

Returns whether the symbol is defined in the passed file. 

Definitions

sub Definitions

Returns an array of all the files that define this symbol.  If none do, will return an empty array. 

GlobalDefinition

sub GlobalDefinition

Returns the file that contains the global definition of this symbol, or undef if the symbol isn’t defined. 

TypeDefinedIn

sub TypeDefinedIn #(file)

Returns the type of symbol defined in the passed file, or undef if it’s not defined in that file. 

GlobalType

sub GlobalType

Returns the type of the global definition.  Will be one of Topic Types or undef if the symbol isn’t defined. 

PrototypeTypeDefinedIn

Returns the prototype of symbol defined in the passed file, or undef if it doesn’t exist or is not defined in that file. 

GlobalPrototype

sub GlobalPrototype

Returns the prototype of the global definition.  Will be undef if it doesn’t exist or the symbol isn’t defined. 

HasReferences

sub HasReferences

Returns whether the symbol can be interpreted as any references. 

References

sub References

Returns an array of all the references that can be interpreted as this symbol.  If none, will return an empty array. 

ReferencesAndScores

sub ReferencesAndScores

Returns a hash of all the references that can be interpreted as this symbol and their scores.  The keys are the reference strings, and the values are the scores.  If none, will return an empty hash.