In Liferay Dev Studio, you can search through Liferay DXP’s source code to aid in
the development of your project. Liferay provides great resources to help with
development (e.g., official documentation,
etc.), but sometimes, searching through Liferay’s codebase (i.e., platform and
official apps) for patterns is just as useful. For example, if you’re creating a
custom app that extends a class provided in Liferay’s
portal-kernel JAR, you
can inspect that class and research how it’s used in other areas of Liferay DXP’s
To do this, you must be developing in a Liferay Workspace. Liferay Workspace is able to provide this functionality by targeting a specific Liferay DXP version, which indexes the configured Liferay DXP source code to provide advanced search. See the Managing the Target Platform in Liferay Workspace tutorial for more information on how this works.
Workspace does not perform portal source indexing by default. You must enable
this functionality by adding the following property to your workspace’s
In this tutorial, you’ll explore three use cases where advanced search would be useful.
These examples are just a small subset of what you can search in Liferay Dev Studio. See Eclipse’s documentation on Java Search for a comprehensive guide.
Search Class Hierarchy
Inspecting classes that extend a similar superclass can help you find useful
patterns and examples for how you can develop your own app. For example, suppose
your app extends the
class. You an search classes that extend that same class in Dev Studio by
MVCPortlet declaration and selecting Open Type Hierarchy.
This opens a window that lets you inspect all classes residing in the target
platform that extend
Great! Now you can search for all extensions and implementations of a class/interface to aid in your quest for developing the perfect app.
Search Method Declarations
Sometimes you want a search to be more granular, exploring the declarations of a specific method provided by a class/interface. Liferay Dev Studio’s advanced search has no limits; Liferay Workspace’s target platform indexing provides method exploration too!
Suppose in the
class you’re extending, you’d like to search for declarations of its
method you’re overriding. You can do this by right-clicking the
declaration in your custom app’s class and selecting Declarations →
The rendered Search window displays the other occurrences in the target platform where that method was overridden.
Search Annotation References
Annotations used in Liferay DXP’s source code can sometimes be cryptic. With the ability to search where these types of annotations reside in Liferay’s target platform, you can find how they could be used in your own app.
For example, you may find some official documentation on using the
annotation in an OSGi module and implement it in your custom app. It could be
useful to reference real world examples in Liferay DXP’s apps to check how it was
used elsewhere. You could search for this by right-clicking the annotation in a
class and selecting References → Workspace.
The rendered Search window displays the other occurrences in the target platform where that annotation was used.
Excellent! You now have the tools to search the configured target platform specified in your Liferay Workspace!