atom / symbols-view

Jump to symbols in Atom
MIT License
164 stars 114 forks source link

File Symbols not working, but Project Symbols shows them #150

Open jclark-dot-org opened 8 years ago

jclark-dot-org commented 8 years ago

I have a manually generated tags file (see Background, below) in my project's root folder. When I use Cmd-R (Toggle File Symbols), I get "No symbols found", but if I use Cmd-Shift-R (Toggle Project Symbols), I see all project symbols, including those in the current file. From the Project Symbols list I can jump to any symbol in the current file or elsewhere in the project. Cmd-Alt-Down and Cmd-Alt-Up (Goto/Return from Declaration) also work, even across files. It's just File Symbols that don't work.

Background: I'm trying to use Atom with the Apex, the programming languages used by Salesforce.com. The MavensMate-Atom package provides syntax highlighting, but no symbol generation. Apex is based heavily on Java, and most source code tools designed for Java do a reasonable job with Apex. Apex projects always have this structure:

Project Root
  +-- src/
        +-- classes/
        +-- objects/
        +-- (etc...)

The src/classes folder will contain Apex files using the .cls extension; these are the only files for which I need symbols. So I started by generating a tags file (Exuberant cTags 5.8 running on Max OS X 10.10.5):

ctags -a -R --langmap=java:+.cls *

This generated a ctags file that looks reasonable to my untrained eye; here's the start:

!_TAG_FILE_FORMAT   2       /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1       /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR        Darren Hiebert  /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME  Exuberant Ctags //
!_TAG_PROGRAM_URL   http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION       5.8     //
ACCRUAL_30_DD2DD    src/classes/LoanUtil.cls        /^      public static final string ACCRUAL_30_DD2DD = '30 Day\/ Due Date to Due Date';$/;"   f       class:LoanUtil
ACCRUAL_ACTUAL_DD2DD        src/classes/LoanUtil.cls        /^      public static final string ACCRUAL_ACTUAL_DD2DD = 'Actual \/ Due Date to Due Date';$/;"       f       class:LoanUtil
ACCRUAL_ACTUAL_P2P  src/classes/LoanUtil.cls        /^      public static final string ACCRUAL_ACTUAL_P2P = 'Actual \/ Payment to Payment';$/;"  f       class:LoanUtil
ACQUISITION_LOAN    src/classes/LoanUtil.cls        /^      public static final string ACQUISITION_LOAN = 'Acquisition';$/;"        f       class:LoanUtil

The total file is 63K, and appears to contain all of the symbols I'd expect to see.

jclark-dot-org commented 8 years ago

I've spend a little time looking at the code; it appears that Toggle File Symbols tries to invoke ctags directly; since I'm not using default settings (it has no idea what to do with a .cls file), it isn't getting any useable results. It looks like I could do a quick fix by adding "source.apex" to tag-generator's getLanguage(), and reporting "Java", but I may investigate adding proper apex support to ctags first. For now, an option for File Symbols to read the project's tags file and filter it would be useful for anyone using a non-standard ctags config. Or a config option to override the ctags command line on a per-file-extension bases.

ahelm commented 7 years ago

+1

I have a similar problem, the difference is that I am using Fortran with file ending *.f03 for 2003. This is not included in ctags, but can extended by --langmap=Fortran:+.f03. Therefore I would appreciate a feature with more control over ctags. In addition it would benefit other packages which depend on or mimic symbols-view, such as symbols-tree-view.