oracle / opengrok

OpenGrok is a fast and usable source code search and cross reference engine, written in Java
http://oracle.github.io/opengrok/
Other
4.34k stars 745 forks source link

Seeing an empty Navigate pane #3543

Closed viri closed 1 year ago

viri commented 3 years ago
opengrok version: 1.3.16

universal ctags version:

Universal Ctags 5.9.0, Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Dec 22 2020, 17:47:52
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +packcc

tomcat version:
Server version: Apache Tomcat/9.0.21
Server built:   Jun 4 2019 20:19:36 UTC
Server number:  9.0.21.0
OS Name:        Linux
OS Version:     2.6.32-754.35.1.el6.x86_64
Architecture:   amd64
JVM Version:    11.0.9.1+1-LTS
JVM Vendor:     Azul Systems, Inc.

java version:

openjdk version "11.0.9.1" 2020-11-04 LTS
OpenJDK Runtime Environment Zulu11.43+55-CA (build 11.0.9.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.43+55-CA (build 11.0.9.1+1-LTS, mixed mode)

We are seeing an issue where the indexing for a code base would finish but some of the indexed Java classes would show an empty Navigate pane like this:

image

The same Java class in another version that is indexed in the same way would show the contents in the Navigate pane.

I am thinking that a reindex would probably fix the issue but I am not very certain it would. However, I wanted to give it a try.

So currently I index my projects using the following settings:

java -Djava.util.logging.config.file=<<logging_props>> -Xmx16G -jar opengrok.jar -s ${sourceDir} -d ${dataDir}  -W  <<config_xml>> -A .rc:org.opensolaris.opengrok.analysis.plain.PlainAnalyzerFactory -r off -c  <<ctgas__exec>> -P -S -v -q

My source directory structure would look like

 /MainLine_A/
        |_subprojA1
        |_subprojA2
        |_subprojA3
        |_subprojA4
        |_subprojA5
        |_subprojA6
        |_subprojA7
        |_subprojA8

During the indexing command like above, I specify the -s argument to be /MainLine_A for example. Then I get a nice split of subprojects just like above when searching code on the Opengrok app.

If the problem is with let's say a code file in "subprojA6", can I selectively reindex this sub-project only without having to reindex the whole codebase?

Thanks! Vinay Chilakamarri

vladak commented 3 years ago

The data to generate the Navigate window is part of the xref and generated via writeSymbolTable(): https://github.com/oracle/opengrok/blob/610d9085dcb52fc16b3f50d16e64cc03a62b7ea1/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexXrefUtils.java#L362-L396

The definitions originate from a ctags run on given file. Either the ctags run is done in the context of indexing and the definitions are stored in the index or they are determined dynamically if the xref is generated on the fly, e.g. here: https://github.com/oracle/opengrok/blob/610d9085dcb52fc16b3f50d16e64cc03a62b7ea1/opengrok-web/src/main/webapp/xref.jspf#L104

So, if the same file has different definitions on multiple deployments, I'd look into differences in the defitions ctags generates. Is the ctags version same on these deployments ?

Also, one thing to note: currently if you display the xref for historical versions of given file (by clicking on the revision number in the history view) the navigate window will be empty. I'd have to see why it works like that.

As for reindexing a sub-project, this is not possible. The granularity for indexing is per project. And that requires special workflow (see https://github.com/oracle/opengrok/wiki/Per-project-management-and-workflow).

vladak commented 3 years ago

To have the Navigate window display tags (definitions, ...) for historical versions of the file in the Navigate window, it is necessary to enable ctags run in the web application, by adding these web app tunables to the configuration:

  <void property="ctags">                                                       
    <string>/usr/local/bin/ctags</string>                                       
  </void>                                                                       
  <void property="webappCtags">                                                 
    <boolean>true</boolean>                                                     
  </void>

e.g. via read-only configuration when running the indexer.

vladak commented 3 years ago

Now, it would be nice if the xref writer could handle the case of webappCtags = false (which is the default) and grey out the link to the Navigate window when generating xref on the fly. Maybe better to be done in JavaScript.

viri commented 3 years ago

Hi Vlad, thank you for your response. Yes, the ctags version is the same across the deployment as I use the same environment settings and the script to generate the indexes. I will try to reindex the project and see if it helps in going past this issue.