10.05.2015

org.stmare.usages

Eclipse plugin to see references among various files where one file references second across projects. Typical example is XML file where is a reference to other XML file. Other example is JSP, XHTML or JSF file where some components of other file are used or there are references to other pages.

It works in 2 directions:

  • direct - hyperlink
  • reverse - back references by usages view

Direct
makes clickable hyperlink for path which points to a file. The path is typically a reference to file in source directory (both java and resource) or to web content directory. It also understands spring expressions like 'classpath:path' or 'classpath*:path'.

alt

Reverse
opposite view that returns files that point to current file. Of course, there can be multiple references to the same file. All are displayed in view.
alt

Range of search
Some rules used:

  • Starts by package or file name (no slash in the begining): try to use current directory. When nothing there then use package and file name starting from root of path on classpath or root of web content. Prefer current project. When nothing in it then search other projects
  • Starts by slash '/': like previous but avoid use current path
  • Spring expression starting by 'classpath[*]:': search in root classpath package of all projects (including current)

Example

Web and common project structure:

webprj
  src
    main
      resources
        - service1.xml
        - service2.xml
        - service3.xml
      webapp
        WEB-INF
          - applicationContext1.xml
          - service1.xml
          - service2.xml
          - service3.xml
        - service1.xml
        - service2.xml
        - service3.xml

commonprj
  src
    main
      resources
        - service1.xml
        - service2.xml
        - service2b.xml
        - service3.xml
        - applicationContext2.xml

applicationContext1.xml = applicationContext2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <!-- search in current directory or in root package (or in root package of web) of current project or in root package of other projects -->
    <import resource="services1.xml"/>

    <!-- search in root package (or in root package of web) of current project or in root package of other projects -->
    <import resource="/services2.xml"/>
    <import resource="/services2b.xml"/>

    <!-- search in root package of all projects (including current) -->

    <import resource="classpath:services3.xml"/>
</beans>

Using applicationContext1.xml
Click on services1.xml - opens:

  • webprj/src/main/webapp/WEB-INF/services1.xml

Click on /services2.xml - offers to open:

  • webprj/src/main/webapp/services1.xml
  • webprj/src/main/resources/services1.xml

Click on /services2b.xml - opens:

  • commonprj/src/main/resources/services2b.xml

Click on classpath:services3.xml - offers to open:

  • webprj/src/main/resources/services3.xml
  • commonprj/src/main/resources/services3.xml

Using applicationContext2.xml
Click on services1.xml - opens:

  • commonprj/src/main/resources/services1.xml

Click on /services2.xml - offers to open:

  • commonprj/src/main/resources/services2.xml

Click on /services2b.xml - opens:

  • commonprj/src/main/resources/services2b.xml

Click on classpath:services3.xml - offers to open:

  • webprj/src/main/resources/services3.xml
  • commonprj/src/main/resources/services3.xml

Download
Eclipse plugin org.stmare.usages can be downloaded here