Package com.dubture.symfony.core.model

Examples of com.dubture.symfony.core.model.SymfonyModelAccess


                if (sourceMethod != null && sourceMethod.getParent() != null) {
                 
                  SourceType sourceType = (SourceType) sourceMethod.getParent();
                  String fqn = sourceType.getFullyQualifiedName("\\");
                  IDLTKSearchScope scope = SearchEngine.createSearchScope(source);
                  SymfonyModelAccess model = SymfonyModelAccess.getDefault();
                  IType[] types = model.findTypes(fqn, MatchRule.EXACT, 0, 0, scope, null);
                 
                  if (types.length == 1) {                   
                    IType type = types[0];                   
                    IMethod method = type.getMethod(sourceMethod.getElementName());
                    route = model.getRoute(type, method);                   
                  }
                 
                }
              }
            } catch (ModelException e) {
View Full Code Here


public class InsertParameterHandler extends BaseTextInsertionHandler {
  @Override
  protected List<String[]> getInput() {

    SymfonyModelAccess modelAccess = SymfonyModelAccess.getDefault();
    List<Parameter> parameters = modelAccess.findParameters(project);
    List<String[]> input = new ArrayList<String[]>();

    for (Parameter parameter : parameters) {
      input.add(new String[] { parameter.key, parameter.key });
    }
View Full Code Here

{

    @Override
    protected List<String[]> getInput()
    {
        SymfonyModelAccess modelAccess = SymfonyModelAccess.getDefault();
        List<Service> services = modelAccess.findServices(project.getPath());
        List<String[]> input = new ArrayList<String[]>();
       
        for (Service service : services) {
            String display = service.getId() + " - " + service.getClassName();
           
View Full Code Here

        List<String> statements = new ArrayList<String>();
        SymfonyTemplateContext symfonyContext = (SymfonyTemplateContext) context;
        String value = (String) symfonyContext.getTemplateVariable("use_parent");
        List<String> interfaces = (List<String>) symfonyContext.getTemplateVariable("interfaces");
        SymfonyModelAccess model = SymfonyModelAccess.getDefault();       
        IDLTKSearchScope scope = SearchEngine.createSearchScope(symfonyContext.getSourceModule().getScriptProject());

        if (interfaces!= null && interfaces.size() > 0) {         
          for (String _interface : interfaces) {

            String stmt = "use " + _interface.replaceFirst("/", "").replace("/", "\\") + ";";

            if (!statements.contains(stmt))
              statements.add(stmt);   

            IType[] types = model.findTypes(_interface, MatchRule.EXACT, 0, 0, scope, null)

            for (IType type : types) {
              for (IMethod method : type.getMethods()) {

                for (IParameter param : method.getParameters()) {

                  if (param.getType() != null && !internal.contains(param.getType())) {

                    IType[] paramTypes = model.findTypes(param.getType(), MatchRule.EXACT, 0, 0, scope, null);

                    if (paramTypes.length == 1) {

                      IType paramType = paramTypes[0];                     
                      String statement = "use " + paramType.getTypeQualifiedName("\\") + ";";
View Full Code Here

    try {
     
      Translation translation = (Translation) getModelElement();     
     
      SymfonyModelAccess model = SymfonyModelAccess.getDefault();
      List<TransUnit> units = model.findTranslations(translation);
     
      String html = HTMLUtils.translation2Html(translation, units);
     
      if (html != null && html.length() > 0)
        return html;
View Full Code Here

@SuppressWarnings({ "restriction", "deprecation" })
public class CodeassistUtils {

  public static void reportTranslations(ICompletionReporter reporter, String prefix, SourceRange range, IScriptProject project) {

    SymfonyModelAccess model = SymfonyModelAccess.getDefault();
   
    List<Bundle> bundles = model.findBundles(project);
    List<TransUnit> units = model.findTranslations(project.getPath());   
   
    for (TransUnit unit : units) {

      Bundle targetBundle = null;
View Full Code Here

  /**
   * Report the different parts of a ViewPath (Bundle:Controller(/Subpath):template) to the completion engine
   */
  public static void reportViewpath(ICompletionReporter reporter, ViewPath viewPath, String prefix, SourceRange range, IScriptProject project)
  {
        SymfonyModelAccess model = SymfonyModelAccess.getDefault();
        String bundle = viewPath.getBundle();
        String controller = viewPath.getController();
        String template = viewPath.getTemplate();
        IDLTKSearchScope projectScope = SearchEngine.createSearchScope(project);
     
        // complete the bundle part
        if (bundle == null && controller == null && template == null) {

            List<Bundle> bundles = model.findBundles(project);

            for (Bundle b : bundles) {             
               
                IType[] bundleTypes = PhpModelAccess.getDefault().findTypes(b.getElementName(), MatchRule.EXACT, 0, 0, projectScope, null);
               
                if (bundleTypes.length == 1) {
                   
                    ModelElement bType = (ModelElement) bundleTypes[0];
                   
                    if (CodeAssistUtils.startsWithIgnoreCase(bType.getElementName(), prefix)) {
                        Bundle bundleType = new Bundle(bType, b.getElementName());
                        reporter.reportType(bundleType, ":", range);                       
                    }
                }
            }          
        // complete the controller part: "Bundle:|
        } else if (controller == null && template == null) {           
           
            IType[] controllers = model.findBundleControllers(bundle, project);
           
            for (IPath path : model.findBundleViewPaths(bundle, project)) {
               
                IType t  = null;
                for (IType type : controllers) {
                   
                    String pathString = path.removeLastSegments(path.segmentCount()-1).toString();
                   
                    if (type.getElementName().contains(pathString)) {
                        t = type;
                        break;
                    }
                }
               
                if (t == null) {
                    continue;
                }
               
                Controller ctrl = new Controller((ModelElement)t, path.toString());
                reporter.reportType(ctrl, ":", range);
            }

           
        // complete template path: "Bundle:Controller:|
        } else if (bundle != null && controller != null) {

            IModelElement[] templates = model.findTemplates(bundle, controller, project);
           
            if (templates != null) {               
                for (IModelElement tpl : templates) {

                    if (CodeAssistUtils.startsWithIgnoreCase(tpl.getElementName(), prefix)) {
                        Template t = new Template((ModelElement) tpl, tpl.getElementName());
                        reporter.reportType(t, "", range);
                    }
                   
                }
            }
           
        // project root: "::|
        } else if (bundle == null && controller == null && template != null) {

            IModelElement[] templates = model.findRootTemplates(project);
           
            if (templates != null) {               
                for (IModelElement tpl : templates) {
                   
                    if (CodeAssistUtils.startsWithIgnoreCase(tpl.getElementName(), prefix)) {
                        Template t = new Template((ModelElement) tpl, tpl.getElementName());
                        reporter.reportType(t, "", range);
                    }
                   
                }
            }
           
        // bundle root: "AcmeDemoBundle::|
        } else if (bundle != null && controller == null && template != null) {
           
            IModelElement[] templates = model.findBundleRootTemplates(bundle, project);
           
            if (templates != null) {               
                for (IModelElement tpl : templates) {
                   
                    if (CodeAssistUtils.startsWithIgnoreCase(tpl.getElementName(), prefix)) {
View Full Code Here

        String content = sourceUnit.getSourceContents();

        int startOffset = SymfonyTextSequenceUtilities.readLiteralStartIndex(content, offset);
        int endOffset = SymfonyTextSequenceUtilities.readLiteralEndIndex(content, offset);

        SymfonyModelAccess model = SymfonyModelAccess.getDefault();
        IScriptProject project = sourceModule.getScriptProject();


        if (startOffset >= 0 && endOffset != 0 && (endOffset > startOffset)) {


            String literal = content.substring(startOffset, endOffset);

            // viewpaths are linked using ViewpathHyperlinkDetector

//            // try to resolve a viewepath first
//            ViewPath viewPath = new ViewPath(literal);
//
//            if (viewPath.isValid()) {
//
//                IModelElement template = model.findTemplate(viewPath, project);
//
//                if (template != null) {
//                    return new IModelElement[] { template };
//                }
//            }

            // nope, not a viewpath, check for a route
            Route route = model.findRoute(literal, project);

            if (route != null) {

                IMethod method = model.findAction(route, project);

                if (method != null)
                    return new IModelElement[] { method };
            }

            // next search for a service
            Service service = model.findService(literal, project.getPath());

            if (service != null) {

                IType serviceType = model.findServiceType(service, project);

                if (serviceType != null)
                    return new IModelElement[] { serviceType };

            }
View Full Code Here

TOP

Related Classes of com.dubture.symfony.core.model.SymfonyModelAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.