For go-to-the-declaration feature and many others like documentation hovers you need to implement selection engine. Task of selection engine is to determine model element from given offset in source file.
Selection engines could be contributed via org.eclipse.dltk.core.selectionEngine extension point, they should implement ISelectionEngine interface. DLTK already has partial implementation of this interface: ScriptSelectionEngine, so you could just extend it.
For example implementation, you can look at RubySelectionEngine.