com.aptana.ide.editor.js
Class JSOffsetMapper

java.lang.Object
  extended by com.aptana.ide.editors.unified.ChildOffsetMapper
      extended by com.aptana.ide.editor.js.JSOffsetMapper
All Implemented Interfaces:
IChildOffsetMapper, IOffsetMapper

public class JSOffsetMapper
extends ChildOffsetMapper
implements IChildOffsetMapper

Author:
Robin Debreuil

Field Summary
static java.lang.String MODE_INVOKING
          MODE_INVOKING for assist type
static java.lang.String MODE_NEW
          MODE_NEW for assist type
static java.lang.String MODE_NORMAL
          MODE_NORMAL for assist type
static java.lang.String MODE_STRING
          MODE_INVOKING for assist type
static java.lang.String NOT_AN_IDENTIFIER
          NOT_AN_IDENTIFIER marker for code assist
static java.lang.String NOT_INVOKING
          NOT_INVOKING marker for code assist
 
Constructor Summary
JSOffsetMapper(IParentOffsetMapper parent)
           
 
Method Summary
 ICodeLocation findTarget(Lexeme lexeme)
          findTarget
static ICodeLocation findTargetFromName(IObject object, Property prop)
          Finds a target based on the passed scope.
 java.lang.String getArgAssistNameHash()
          getArgAssistNameHash
 int getArgIndexAndCalculateMode()
          Gets the index of the arg from the current offset (arg0, arg1, ...), based on the number of commas viewed.
 int getFileIndex()
          getFileIndex
 JSScope getGlobal()
          Gets the global object for this file's environment.
static java.lang.String getIdentName(int position, LexemeList lexemeList)
          getIdentName
 java.lang.String getMode(int offset)
          Returns the invocation mode (invoking, new, or normal).
 java.lang.String getNameHash(int lexemeIndex)
          Gets the full name of of an object that is at the passed offset.
 IParseState getParseState()
          getParseState
static Property getPropertyInScope(IObject object, java.lang.String propName)
          getPropertyInScope
 IScope getScope(Lexeme lex, IScope defaultScope)
          Returns the environment scope for the specified lexeme.
 IObject lookupReturnTypeFromNameHash(java.lang.String fullname, IScope scope)
          Looks up an object in the global table based on its full name.
 IObject lookupReturnTypeFromNameHash(java.lang.String fullname, IScope scope, boolean searchForward)
          Looks up an object in the global table based on its full name.
static Property lookupTypeFromNameHash(java.lang.String fullname, IScope scope, int offset, JSOffsetMapper jsfe)
          Looks up an object in the global table based on its full name and returns the final object (not its return type).
 
Methods inherited from class com.aptana.ide.editors.unified.ChildOffsetMapper
calculateCurrentLexeme, dispose, getCurrentLexeme, getCurrentLexemeIndex, getFileService, getLexemeAtIndex, getLexemeIndexFromDocumentOffset, getLexemeList, getNextLexeme, getParent, getPreviousLexeme
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.aptana.ide.editors.unified.IChildOffsetMapper
getFileService, getParent
 
Methods inherited from interface com.aptana.ide.parsing.IOffsetMapper
calculateCurrentLexeme, dispose, getCurrentLexeme, getCurrentLexemeIndex, getLexemeAtIndex, getLexemeIndexFromDocumentOffset, getLexemeList
 

Field Detail

MODE_NORMAL

public static final java.lang.String MODE_NORMAL
MODE_NORMAL for assist type

See Also:
Constant Field Values

MODE_NEW

public static final java.lang.String MODE_NEW
MODE_NEW for assist type

See Also:
Constant Field Values

MODE_INVOKING

public static final java.lang.String MODE_INVOKING
MODE_INVOKING for assist type

See Also:
Constant Field Values

MODE_STRING

public static final java.lang.String MODE_STRING
MODE_INVOKING for assist type

See Also:
Constant Field Values

NOT_AN_IDENTIFIER

public static final java.lang.String NOT_AN_IDENTIFIER
NOT_AN_IDENTIFIER marker for code assist

See Also:
Constant Field Values

NOT_INVOKING

public static final java.lang.String NOT_INVOKING
NOT_INVOKING marker for code assist

See Also:
Constant Field Values
Constructor Detail

JSOffsetMapper

public JSOffsetMapper(IParentOffsetMapper parent)
Parameters:
parent -
Method Detail

lookupTypeFromNameHash

public static Property lookupTypeFromNameHash(java.lang.String fullname,
                                              IScope scope,
                                              int offset,
                                              JSOffsetMapper jsfe)
Looks up an object in the global table based on its full name and returns the final object (not its return type). This uses the special notation (from getNameHash) for full names.

Parameters:
fullname - Full name of the object to lookup
scope - The scope to start looking from - this allows lookup from inside a function scope.
offset -
jsfe -
Returns:
Returns the 'return type' of the given name.

getIdentName

public static java.lang.String getIdentName(int position,
                                            LexemeList lexemeList)
getIdentName

Parameters:
position -
lexemeList -
Returns:
String

getPropertyInScope

public static Property getPropertyInScope(IObject object,
                                          java.lang.String propName)
getPropertyInScope

Parameters:
object -
propName -
Returns:
Property

getMode

public java.lang.String getMode(int offset)
Returns the invocation mode (invoking, new, or normal).

Parameters:
offset - The index to check the mode at.
Returns:
Returns the invocation mode (invoking, new, or normal).

getNameHash

public java.lang.String getNameHash(int lexemeIndex)
Gets the full name of of an object that is at the passed offset. This is in the form "Math.abs().toString()", even if there are arguments.

Parameters:
lexemeIndex - - index of lexeme
Returns:
Returns a hashed string name

getArgAssistNameHash

public java.lang.String getArgAssistNameHash()
getArgAssistNameHash

Returns:
String

lookupReturnTypeFromNameHash

public IObject lookupReturnTypeFromNameHash(java.lang.String fullname,
                                            IScope scope)
Looks up an object in the global table based on its full name. This uses the special notation (from getNameHash) for full names, and uses documentation return types and prototype/object lookup to discover return types.

Parameters:
fullname - Full name of the object to lookup
scope - The scope to start looking from - this allows lookup from inside a function scope.
Returns:
Returns the 'return type' of the given name.

lookupReturnTypeFromNameHash

public IObject lookupReturnTypeFromNameHash(java.lang.String fullname,
                                            IScope scope,
                                            boolean searchForward)
Looks up an object in the global table based on its full name. This uses the special notation (from getNameHash) for full names, and uses documentation return types and prototype/object lookup to discover return types.

Parameters:
fullname - Full name of the object to lookup
scope - The scope to start looking from - this allows lookup from inside a function scope.
searchForward - Looks forward in doc if part of name not found at current fileIndex/offset
Returns:
Returns the 'return type' of the given name.

getArgIndexAndCalculateMode

public int getArgIndexAndCalculateMode()
Gets the index of the arg from the current offset (arg0, arg1, ...), based on the number of commas viewed. This also sets the 'mode' the current location is in (invoking, new, normal). This does both at once toab avoid duplication, and caches the result.

Returns:
Returns the current arg count based on commas in the source.

getFileIndex

public int getFileIndex()
getFileIndex

Returns:
int

getGlobal

public JSScope getGlobal()
Gets the global object for this file's environment.

Returns:
Returns the global object for this file's environment.

getScope

public IScope getScope(Lexeme lex,
                       IScope defaultScope)
Returns the environment scope for the specified lexeme.

Parameters:
lex -
defaultScope -
Returns:
Returns the environment scope for the specified lexeme.

getParseState

public IParseState getParseState()
getParseState

Returns:
IParseState

findTarget

public ICodeLocation findTarget(Lexeme lexeme)
Description copied from interface: IOffsetMapper
findTarget

Specified by:
findTarget in interface IOffsetMapper
Overrides:
findTarget in class ChildOffsetMapper
Returns:
ICodeLocation
See Also:
IOffsetMapper.findTarget(com.aptana.ide.lexer.Lexeme)

findTargetFromName

public static ICodeLocation findTargetFromName(IObject object,
                                               Property prop)
Finds a target based on the passed scope.

Parameters:
object -
prop -
Returns:
Returns the target based on the passed scope.