Package org.objectstyle.wolips.wodclipse.core.completion

Examples of org.objectstyle.wolips.wodclipse.core.completion.WodParserCache


    _counter = 0;
    _idToNodeMap = new HashMap<String, FuzzyXMLNode>();
    _nodeToIDMap = new HashMap<FuzzyXMLNode, String>();

    try {
      WodParserCache cache = _editor.getParserCache();
      RenderContext renderContext = new RenderContext(true);
      FuzzyXMLElement documentElement = _doc.getDocumentElement();
      StringBuffer documentContentsBuffer = new StringBuffer();
      renderHeader(documentContentsBuffer);
      renderElement(documentElement, renderContext, documentContentsBuffer, cache);
View Full Code Here


    if (node instanceof FuzzyXMLElement) {
      FuzzyXMLElement element = (FuzzyXMLElement) node;
      String tagName = element.getName();
      if (WodHtmlUtils.isWOTag(tagName)) {
        try {
          WodParserCache cache = _caches.peek();
          BuildProperties buildProperties = (BuildProperties)cache.getProject().getAdapter(BuildProperties.class);
          IWodElement wodElement = WodHtmlUtils.getWodElement(element, buildProperties, true, cache);
          if (wodElement == null) {
            return true;
          }

          String elementTypeName = wodElement.getElementType();
         
          TagDelegate tagDelegate = _tagDelegates.get(elementTypeName);
          if (tagDelegate != null) {
            tagDelegate.renderNode(wodElement, element, renderContext, xmlBuffer, _cssBuffer, _caches, _nodes);
          }
          else {
            IType type = BindingReflectionUtils.findElementType(cache.getJavaProject(), elementTypeName, false, WodParserCache.getTypeCache());
            LocalizedComponentsLocateResult componentsLocateResults = LocatePlugin.getDefault().getLocalizedComponentsLocateResult(type.getJavaProject().getProject(), wodElement.getElementType());
            IFile htmlFile = componentsLocateResults.getFirstHtmlFile();
            if (htmlFile != null) {
              WodParserCache nestedCache = WodParserCache.parser(htmlFile);
              if (nestedCache != null) {
                Wo apiModel = ApiUtils.findApiModelWo(type, WodParserCache.getTypeCache().getApiCache(cache.getJavaProject()));
                if (apiModel != null) {
                  String preview = apiModel.getPreview();
                  if (preview != null) {
                    StringBuffer previewBuffer = new StringBuffer();
                    Pattern bindingPattern = Pattern.compile("\\$([a-zA-Z0-9_]+)");
                    Matcher matcher = bindingPattern.matcher(preview);
                    while (matcher.find()) {
                      String bindingName = matcher.group(1);
                      IWodBinding binding = wodElement.getBindingNamed(bindingName);
                      if (binding == null) {
                        matcher.appendReplacement(previewBuffer, "");
                      } else {
                        matcher.appendReplacement(previewBuffer, binding.getValue());
                      }
                    }
                    matcher.appendTail(previewBuffer);
 
                    nestedCache = nestedCache.cloneCache();
                    nestedCache.getHtmlEntry().setContents("<span>" + previewBuffer.toString() + "</span>");
                  }
                }
                _caches.push(nestedCache);
                _nodes.push(node);
                try {
                  FuzzyXMLDocument nestedDocument = nestedCache.getHtmlEntry().getModel();
                  if (nestedDocument != null) {
                    nestedDocument.getDocumentElement().toXMLString(renderContext, xmlBuffer);
                  }
                } finally {
                  _nodes.pop();
View Full Code Here

   
    IDocument editDocument = documentProvider.getHtmlEditDocument();
    String documentContents = editDocument.get();

    try {
      WodParserCache cache = ((TemplateEditor) _editorInteraction.getHtmlDocumentProvider()).getSourceEditor().getParserCache();
      FuzzyXMLDocument htmlDocument = cache.getHtmlEntry().getModel();
      RenderContext renderContext = new RenderContext(true);
      renderContext.setDelegate(new PreviewRenderDelegate(cache));
      FuzzyXMLElement documentElement = htmlDocument.getDocumentElement();
      documentContents = documentElement.toXMLString(renderContext);
    } catch (Exception e) {
View Full Code Here

          if (commentText != null && commentText.startsWith("//")) {
            commentText = commentText.substring(2).trim();
            if (commentText.toLowerCase().startsWith("inherit ")) {
              String componentName = commentText.substring("inherit ".length()).trim();
              try {
                WodParserCache inheritCache = WodParserCache.parser(_wodFile.getProject(), componentName);
                WodCacheEntry wodCacheEntry = inheritCache.getWodEntry();
                IWodModel parentWodModel = wodCacheEntry.getModel();
                for (IWodElement parentWodElement : parentWodModel.getElements()) {
                  SimpleWodElement inheritedWodElement = new SimpleWodElement(parentWodElement);
                  inheritedWodElement.setInherited(true);
                  addElement(inheritedWodElement);
View Full Code Here

          // pretty expensive
          // way to go here. To find element names that have already
          // been mapped, we
          // reparse the wod file. Lame.
          Set<String> alreadyUsedElementNames = WodScanner.getTextForRulesOfType(document, ElementNameRule.class);
          WodParserCache wodParserCache = WodParserCache.parser(((FileEditorInput) _editor.getEditorInput()).getFile());
          WodCompletionUtils.fillInElementNameCompletionProposals(alreadyUsedElementNames, token, tokenOffset, offset, completionProposalsSet, guessed, wodParserCache.getHtmlEntry().getHtmlElementCache());
        } else if (tokenType == PreferenceConstants.ELEMENT_TYPE) {
          WodCompletionUtils.fillInElementTypeCompletionProposals(javaProject, token, tokenOffset, offset, completionProposalsSet, guessed, null);
        } else if (tokenType == PreferenceConstants.BINDING_NAME) {
          IType elementType = findNearestElementType(javaProject, document, scanner, tokenOffset, typeCache);
          WodCompletionUtils.fillInBindingNameCompletionProposals(javaProject, elementType, token, tokenOffset, offset, completionProposalsSet, guessed, typeCache);
View Full Code Here

    }
    return modelOffset;
  }

  public IWodModel getWodModel(boolean refreshModel) throws Exception {
    WodParserCache cache = getParserCache();
    IWodModel model;
    if (refreshModel || isDirty()) {
      model = WodModelUtils.createWodModel(cache.getWodEntry().getFile(), cache.getWodEntry().getDocument());
      cache.getWodEntry().setModel(model);
    } else {
      model = cache.getWodEntry().getModel();
    }
    return model;
  }
View Full Code Here

    List<IHyperlink> hyperlinks = new LinkedList<IHyperlink>();
    try {
      IFileEditorInput input = (IFileEditorInput) _editor.getEditorInput();
      if (input != null) {
        IFile file = input.getFile();
        WodParserCache cache = WodParserCache.parser(file);
        IWodModel model = cache.getWodEntry().getModel();
        if (model != null) {
          List<IWodElement> wodElements = model.getElements();
          if (wodElements != null) {
            for (IWodElement element : wodElements) {
              if (element.isWithin(region)) {
View Full Code Here

    try {
      if (_selection instanceof IStructuredSelection) {
        Object[] selectedObjects = ((IStructuredSelection) _selection).toArray();
        for (int i = 0; i < selectedObjects.length; i++) {
          IResource resource = (IResource) selectedObjects[i];
          WodParserCache cache = WodParserCache.parser(resource);
          List<BindingValueKey> bindingKeys = BindingReflectionUtils.getBindingKeys(cache.getJavaProject(), cache.getComponentType(), "", false, BindingReflectionUtils.MUTATORS_ONLY, false, WodParserCache.getTypeCache());
          IFile apiFile = cache.getApiFile();
          ApiModel apiModel = new ApiModel(apiFile);
          Wo wo = apiModel.getWo();
          for (BindingValueKey binding : bindingKeys) {
            if (!BindingReflectionUtils.isSystemBindingValueKey(binding, true)) {
              String bindingName = binding.getBindingName();
View Full Code Here

        if (showProgress) {
          progressMonitor.subTask("Locating components for " + resourceName + " ...");
        }
      }
      try {
        WodParserCache cache = WodParserCache.parser(resource);
        if (progressMonitor != null && cache.getWodEntry().getFile() != null) {
          if (showProgress) {
            progressMonitor.subTask("Building WO " + cache.getWodEntry().getFile().getName() + " ...");
          }
        }
        cache.clearParserCache();
        cache.parse();
        cache.validate(true, false);
      }
      catch (Throwable t) {
        t.printStackTrace();
      }
      // System.out.println("WodBuilder._validateComponent: done with " +
View Full Code Here

  }

  @Override
  public void dispose() {
    try {
      WodParserCache cache = getParserCache();
      cache.getHtmlEntry().setDocument(null);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    super.dispose();
View Full Code Here

TOP

Related Classes of org.objectstyle.wolips.wodclipse.core.completion.WodParserCache

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.