Search in sources :

Example 6 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class LiferayDependencyQuickFix method _processUndefinedTypeProposals.

private List<IJavaCompletionProposal> _processUndefinedTypeProposals(IInvocationContext context, IProblemLocation problem) {
    ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
    String fullyQualifiedName = null;
    if (selectedNode instanceof Name) {
        Name node = (Name) selectedNode;
        fullyQualifiedName = node.getFullyQualifiedName();
    }
    List<String> serviceWrapperList;
    List<String> servicesList;
    boolean depWrapperCanFixed = false;
    List<IJavaCompletionProposal> proposals = new ArrayList<>();
    try {
        serviceWrapperList = TargetPlatformUtil.getServiceWrapperList().getServiceList();
        servicesList = TargetPlatformUtil.getServicesList().getServiceList();
        for (String wrapper : serviceWrapperList) {
            if (wrapper.endsWith(fullyQualifiedName)) {
                ServiceContainer bundle = TargetPlatformUtil.getServiceWrapperBundle(wrapper);
                proposals.add(_createDepProposal(context, bundle));
            }
        }
        if (!depWrapperCanFixed) {
            for (String service : servicesList) {
                if (service.endsWith(fullyQualifiedName)) {
                    ServiceContainer bundle = TargetPlatformUtil.getServiceBundle(service);
                    proposals.add(_createDepProposal(context, bundle));
                }
            }
        }
    } catch (Exception e) {
        ProjectCore.logError("Error processing undefined type proposals", e);
    }
    return proposals;
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) ASTNode(org.eclipse.jdt.core.dom.ASTNode) ArrayList(java.util.ArrayList) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal) CoreException(org.eclipse.core.runtime.CoreException) Name(org.eclipse.jdt.core.dom.Name)

Example 7 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class QuickFixGradleDep method _importNotFoundProposal.

private void _importNotFoundProposal(IInvocationContext context, IProblemLocation problem, Collection<IJavaCompletionProposal> proposals) {
    ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
    if (selectedNode == null) {
        return;
    }
    ImportDeclaration importDeclaration = (ImportDeclaration) ASTNodes.getParent(selectedNode, ASTNode.IMPORT_DECLARATION);
    if (importDeclaration == null) {
        return;
    }
    String importName = importDeclaration.getName().toString();
    List<String> serviceWrapperList;
    List<String> servicesList;
    boolean depWrapperCanFixed = false;
    try {
        serviceWrapperList = TargetPlatformUtil.getServiceWrapperList().getServiceList();
        servicesList = TargetPlatformUtil.getServicesList().getServiceList();
        if (serviceWrapperList.contains(importName)) {
            ServiceContainer bundle = TargetPlatformUtil.getServiceWrapperBundle(importName);
            depWrapperCanFixed = true;
            _createDepProposal(context, proposals, bundle);
        }
        if (!depWrapperCanFixed) {
            if (servicesList.contains(importName)) {
                ServiceContainer bundle = TargetPlatformUtil.getServiceBundle(importName);
                _createDepProposal(context, proposals, bundle);
            }
        }
        if (TargetPlatformUtil.getThirdPartyBundleList(importName) != null) {
            ServiceContainer bundle = TargetPlatformUtil.getThirdPartyBundleList(importName);
            _createDepProposal(context, proposals, bundle);
        }
    } catch (Exception e) {
        GradleCore.logError("Gradle dependence got error", e);
    }
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) ASTNode(org.eclipse.jdt.core.dom.ASTNode) ImportDeclaration(org.eclipse.jdt.core.dom.ImportDeclaration) IOException(java.io.IOException)

Example 8 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class QuickFixGradleDep method _undefinedType.

private void _undefinedType(IInvocationContext context, IProblemLocation problem, Collection<IJavaCompletionProposal> proposals) {
    ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
    String fullyQualifiedName = null;
    if (selectedNode instanceof Name) {
        Name node = (Name) selectedNode;
        fullyQualifiedName = node.getFullyQualifiedName();
    }
    List<String> serviceWrapperList;
    List<String> servicesList;
    boolean depWrapperCanFixed = false;
    try {
        serviceWrapperList = TargetPlatformUtil.getServiceWrapperList().getServiceList();
        servicesList = TargetPlatformUtil.getServicesList().getServiceList();
        for (String wrapper : serviceWrapperList) {
            if (wrapper.endsWith(fullyQualifiedName)) {
                ServiceContainer bundle = TargetPlatformUtil.getServiceWrapperBundle(wrapper);
                _createDepProposal(context, proposals, bundle);
            }
        }
        if (!depWrapperCanFixed) {
            for (String service : servicesList) {
                if (service.endsWith(fullyQualifiedName)) {
                    ServiceContainer bundle = TargetPlatformUtil.getServiceBundle(service);
                    _createDepProposal(context, proposals, bundle);
                }
            }
        }
    } catch (Exception e) {
        GradleCore.logError("Gradle dependence got error", e);
    }
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) ASTNode(org.eclipse.jdt.core.dom.ASTNode) IOException(java.io.IOException) Name(org.eclipse.jdt.core.dom.Name)

Example 9 with ServiceContainer

use of com.liferay.ide.project.core.modules.ServiceContainer in project liferay-ide by liferay.

the class NewLiferayComponentServiceOperation method getComponentDependency.

@Override
protected List<String[]> getComponentDependency() throws CoreException {
    List<String[]> componentDependency = super.getComponentDependency();
    try {
        ServiceContainer serviceBundle = TargetPlatformUtil.getServiceWrapperBundle(serviceName);
        if (serviceBundle != null) {
            Version retriveVersion = new Version(serviceBundle.getBundleVersion());
            componentDependency.add(new String[] { serviceBundle.getBundleGroup(), serviceBundle.getBundleName(), retriveVersion.getMajor() + "." + retriveVersion.getMinor() + ".0" });
        }
    } catch (Exception e) {
    }
    return componentDependency;
}
Also used : ServiceContainer(com.liferay.ide.project.core.modules.ServiceContainer) Version(org.osgi.framework.Version) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ServiceContainer (com.liferay.ide.project.core.modules.ServiceContainer)9 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 ASTNode (org.eclipse.jdt.core.dom.ASTNode)4 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 IOException (java.io.IOException)2 List (java.util.List)2 ImportDeclaration (org.eclipse.jdt.core.dom.ImportDeclaration)2 Name (org.eclipse.jdt.core.dom.Name)2 IJavaCompletionProposal (org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)2 Version (org.osgi.framework.Version)2 File (java.io.File)1 URL (java.net.URL)1 Bundle (org.osgi.framework.Bundle)1