use of com.liferay.blade.api.SearchResult in project liferay-ide by liferay.
the class JSPFileWTP method findJSPTags.
@Override
public List<SearchResult> findJSPTags(String tagName, String[] attrNames) {
if ((tagName == null) || tagName.isEmpty() || ListUtil.isEmpty(attrNames)) {
throw new IllegalArgumentException("tagName can not be null or empty");
}
List<SearchResult> searchResults = new ArrayList<>();
NodeList nodeList = _getTagNodes(tagName);
for (int i = 0; i < nodeList.getLength(); i++) {
IDOMNode domNode = (IDOMNode) nodeList.item(i);
for (String attrName : attrNames) {
IDOMNode attrNode = (IDOMNode) domNode.getAttributes().getNamedItem(attrName);
if (attrNode != null) {
int startOffset = attrNode.getStartOffset();
int endOffset = startOffset + attrName.length();
int jspStartLine = _getJspLine(startOffset);
int jspEndLine = _getJspLine(endOffset);
searchResults.add(super.createSearchResult(null, startOffset, endOffset, jspStartLine, jspEndLine, true));
}
}
}
return searchResults;
}
use of com.liferay.blade.api.SearchResult in project liferay-ide by liferay.
the class JSPFileWTP method findJSPTags.
@Override
public List<SearchResult> findJSPTags(String tagName) {
if ((tagName == null) || tagName.isEmpty()) {
throw new IllegalArgumentException("tagName can not be null or empty");
}
List<SearchResult> searchResults = new ArrayList<>();
NodeList nodeList = _getTagNodes(tagName);
for (int i = 0; i < nodeList.getLength(); i++) {
IDOMNode domNode = (IDOMNode) nodeList.item(i);
int startOffset = domNode.getStartOffset();
int endOffset = domNode.getEndOffset();
int jspStartLine = _getJspLine(startOffset);
int jspEndLine = _getJspLine(endOffset);
searchResults.add(super.createSearchResult(null, startOffset, endOffset, jspStartLine, jspEndLine, true));
}
return searchResults;
}
use of com.liferay.blade.api.SearchResult in project liferay-ide by liferay.
the class JavaFileJDT method findCatchExceptions.
@Override
public List<SearchResult> findCatchExceptions(String[] exceptions) {
List<SearchResult> searchResults = new ArrayList<>();
_ast.accept(new ASTVisitor() {
@Override
public boolean visit(CatchClause node) {
SingleVariableDeclaration exception = node.getException();
String exceptionTypeName = exception.getType().toString();
boolean retVal = false;
for (String exceptionType : exceptions) {
if (exceptionTypeName.equals(exceptionType)) {
int startLine = _ast.getLineNumber(exception.getStartPosition());
int startOffset = exception.getStartPosition();
int endLine = _ast.getLineNumber(exception.getStartPosition() + exception.getLength());
int endOffset = exception.getStartPosition() + exception.getLength();
searchResults.add(createSearchResult(exceptionTypeName, startOffset, endOffset, startLine, endLine, true));
retVal = true;
}
}
return retVal;
}
});
return searchResults;
}
use of com.liferay.blade.api.SearchResult in project liferay-ide by liferay.
the class JavaFileJDT method findPackage.
@Override
public SearchResult findPackage(String packageName) {
List<SearchResult> searchResults = new ArrayList<>();
_ast.accept(new ASTVisitor() {
@Override
public boolean visit(PackageDeclaration node) {
String searchContext = node.getName().toString();
if (packageName.equals(searchContext)) {
int startLine = _ast.getLineNumber(node.getName().getStartPosition());
int startOffset = node.getName().getStartPosition();
int endLine = _ast.getLineNumber(node.getName().getStartPosition() + node.getName().getLength());
int endOffset = node.getName().getStartPosition() + node.getName().getLength();
searchResults.add(createSearchResult(searchContext, startOffset, endOffset, startLine, endLine, true));
}
return false;
}
});
if (ListUtil.isNotEmpty(searchResults)) {
return searchResults.get(0);
}
return null;
}
use of com.liferay.blade.api.SearchResult in project liferay-ide by liferay.
the class JavaFileJDT method findImplementsInterface.
@Override
public List<SearchResult> findImplementsInterface(String interfaceName) {
List<SearchResult> searchResults = new ArrayList<>();
_ast.accept(new ASTVisitor() {
@Override
public boolean visit(TypeDeclaration node) {
ITypeBinding[] superInterfaces = null;
if (node.resolveBinding() != null) {
superInterfaces = node.resolveBinding().getInterfaces();
if (ListUtil.isNotEmpty(superInterfaces)) {
String searchContext = superInterfaces[0].getName();
if (searchContext.equals(interfaceName)) {
int startLine = _ast.getLineNumber(node.getName().getStartPosition());
int startOffset = node.getName().getStartPosition();
int endLine = _ast.getLineNumber(node.getName().getStartPosition() + node.getName().getLength());
int endOffset = node.getName().getStartPosition() + node.getName().getLength();
searchResults.add(createSearchResult(searchContext, startOffset, endOffset, startLine, endLine, true));
}
}
}
return true;
}
});
return searchResults;
}
Aggregations