Package org.eclipse.ui.editors.text

Examples of org.eclipse.ui.editors.text.TextFileDocumentProvider$FileInfo


       
        model = new ToolCursor();
        model.setFile(modelFile);
        model.setPlanName(planName);
        model.setToolName(cursorName);
        model.provider = new TextFileDocumentProvider();
        model.provider.connect(modelFile);
        model.document = model.provider.getDocument(modelFile);
       
        model.parse(model.document);
        getCursorCache(project).put(keyString, model);
View Full Code Here


          return null;
       
        model = new ToolClass();
        model.setFile(modelFile);
        model.setPlanName(planName);
        model.provider = new TextFileDocumentProvider();
        model.provider.connect(modelFile);
        model.document = model.provider.getDocument(modelFile);
       
        model.parse(model.document);
        getTypeCache(model.getProject()).put(keyString, model);
View Full Code Here

    this.setDirty(true);
  }
 
  public static ToolClass parseUsingGrammar(IFile file){
    try {
      TextFileDocumentProvider provider = new TextFileDocumentProvider();
      provider.connect(file);
      IDocument document = provider.getDocument(file);   
      String source = document.get();
      CommonTokenStream tokens = createTokenStream(source);
      ToolClass toolClass =  parseSource(tokens, file);
      if (toolClass != null){
        toolClass.document = document;
View Full Code Here

    }
    return null;
  }
  public static ToolClass parseUsingGrammar(File file){
    try {
      TextFileDocumentProvider provider = new TextFileDocumentProvider();
      provider.connect(file);
      IDocument document = provider.getDocument(file);   
      String source = document.get();
      CommonTokenStream tokens = createTokenStream(source);
      ToolClass toolClass =  parseSource(tokens, null);
      if (toolClass != null){
        toolClass.document = document;
View Full Code Here

  }

  @SuppressWarnings("static-access")
  public static ToolPlan parseUsingGrammar(IFile file){
    try {
    TextFileDocumentProvider provider = new TextFileDocumentProvider();
    provider.connect(file);
    IDocument document = provider.getDocument(file);   
    String source = document.get();
    ErrorReporter parseErrors = new ErrorReporter();
      CommonTree tree = null;
      CommonTokenStream tokens = createTokenStream(source);
      parser.setTokenStream(tokens);
View Full Code Here

        if (describer.describe(modelFile.getContents(), null) != IContentDescriber.VALID)
          return null;
        ToolInterface inter = new ToolInterface();
        inter.setFile(modelFile);
        inter.setPlanName(plan);
        IDocumentProvider provider = new TextFileDocumentProvider();
        provider.connect(modelFile);
        IDocument document = provider.getDocument(modelFile);
        inter.parse(document);
        getTypeCache(project).put((plan + "." + interfaceName).toUpperCase(), model);
        model = inter;
      } catch (CoreException e) {
        ToolModelActivator.log(IStatus.ERROR,"Error updating Interface Model.", e);
View Full Code Here

      final IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
      if (activeEditor != null) { // If it's null then there is no editor connected to the java file extension
        final IEditorInput editorInput = activeEditor.getEditorInput();
        final IFile htmlFile = ResourceUtil.getFile(editorInput);
        final IFile javaFile = WicketHyperlink.getJavaFile(htmlFile);
        final IDocumentProvider provider = new TextFileDocumentProvider();
        provider.connect(javaFile);

        final IDocument jdoc = provider.getDocument(javaFile);
        int nol = jdoc.getNumberOfLines();
        for (int lidx = 0; lidx < nol; lidx++) {
          IRegion li = jdoc.getLineInformation(lidx);
          String line = jdoc.get(li.getOffset(), li.getLength());
          String[] ss = line.split("\"");
          if (ss.length > 1) {
            for (int i = 1; i < ss.length; i += 2) {
              final String proposedWid = ss[i];
              if (proposedWid.length() > 0 && !proposedWid.contains(":") && !proposedWid.contains("~")) {
                final CompletionProposal proposal = new CompletionProposal(proposedWid, rtr.getOffset(), existingWid.length(), rtr.getOffset(), img, proposedWid, null, line.replaceAll("\"" + proposedWid + "\"", "\"<b>" + proposedWid + "</b>\""));
                proposals.put(proposedWid, proposal);
              }
            }
          }
        }
        provider.disconnect(javaFile);
      }
    } catch (Exception e) {
    }

    return new ArrayList<CompletionProposal>(proposals.values());
View Full Code Here

      if (isExcluded(javaFile)) {
        return;
      }

      try {
        final IDocumentProvider provider = new TextFileDocumentProvider();
        provider.connect(htmlFile);
        final IDocument document = provider.getDocument(htmlFile);
        LDL = document.getLineDelimiter(0).length();
        int sc = 0;
        boolean commented = false;
        String wid_const = DocumentHelper.WICKET;
        for (int i = 0; i < document.getNumberOfLines(); i++) {
          final IRegion li = document.getLineInformation(i);
          final String line = document.get(li.getOffset(), li.getLength());

          if (line.contains("<!--")) {
            commented = true;
            continue;
          }
          if (line.contains("-->")) {
            commented = false;
            continue;
          }

          if (line.contains(QWickieActivator.WICKET_DTD)) {
            wid_const = DocumentHelper.getWicketNamespace(line);
          }

          final String wid_const_id = wid_const + ":id=\"";
          if (line.contains(wid_const_id) && !commented) {
            final String wid = line.split(wid_const_id)[1].split("\"")[0];
            int jlc = getJavaLine(javaFile, wid);
            if (jlc == -1) { // wicket id was not found in this java file
              // get the supertypes for the WebPage (maybe it's added in a BasePage?)
              final List<Object> superTypes = TypeHelper.getSupertypes(javaFile);
              for (final Object superType : superTypes) {
                if (superType instanceof IFile) {
                  jlc = getJavaLine((IFile) superType, wid);
                } else if (superType instanceof IClassFile) {
                  jlc = getJavaLine((IClassFile) superType, wid);
                }
                if (jlc == -1) {
                  // not found, then search in the used types
                  final List<JavaElement> wcts = TypeHelper.getWicketComponentTypes(javaFile);
                  for (final JavaElement wct : wcts) {
                    jlc = getJavaLine(wct, wid);
                    if (jlc > -1) {
                      break;
                    }
                  }
                  if (jlc == -1) {
                    // not found, then search in the used models
                    final List<IVariableBinding> wmts = TypeHelper.getWicketModelTypes(javaFile);
                    for (final IVariableBinding wmt : wmts) {
                      if (wid.equals(wmt.getName())) {
                        jlc = 0;
                        break;
                      }
                    }
                  }
                }
                if (jlc > -1) { // found, so don't go further
                  break;
                }
              }
              if (jlc == -1) {
                final int widPos = sc + line.indexOf("\"" + wid + "\"") + 1;
                FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
                IRegion tagBegin = frda.find(widPos, "<", false, true, false, false);
                IRegion tagEnd = frda.find(tagBegin.getOffset(), " ", true, true, false, false);
                String htmlTag = document.get(tagBegin.getOffset() + 1, tagEnd.getOffset() - tagBegin.getOffset() - 1);
                String htmlSnippet = htmlTag.toLowerCase();
                if (htmlFile != null && "input".equals(htmlSnippet)) {
                  tagEnd = frda.find(tagBegin.getOffset(), ">", true, true, false, false);
                  htmlSnippet = document.get(tagBegin.getOffset() + 1, tagEnd.getOffset() - tagBegin.getOffset() - 1).toLowerCase().trim();
                  if (htmlSnippet.contains("type")) {
                    final String[] hss = htmlSnippet.split(" ");
                    if (hss != null) {
                      for (int j = 0; j < hss.length; j++) {
                        String hs = hss[j];
                        if (hs.startsWith("type")) {
                          htmlSnippet = htmlTag + " " + hs.replace("type=", "").split("\"")[1];
                        }
                      }
                    }
                  } else {
                    htmlSnippet = htmlTag.toLowerCase();
                  }
                }
                addMarker(htmlFile, getErrorText(wid), wid, htmlSnippet, i, widPos, wid.length());
                markJava(javaFile, wid, htmlSnippet);
              }
            }
          }
          sc += li.getLength() + LDL;
        }
        provider.disconnect(htmlFile);
      } catch (final Exception e) {
        QWickieActivator.getDefault().getLog().log(new Status(Status.ERROR, QWickieActivator.PLUGIN_ID, "Error in builder", e));
      }
    }
View Full Code Here

  /**
   * mark an error in a java file
   */
  private void markJava(final IFile javaFile, final String wid, final String htmlSnippet) {
    final IDocumentProvider provider = new TextFileDocumentProvider();
    try {
      provider.connect(javaFile);
      final IDocument document = provider.getDocument(javaFile);
      final String className = javaFile.getName().replaceAll(".java", "");
      final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
      final IRegion region = frda.find(0, "class " + className, true, true, true, false);
      if (region != null) {
        addMarker(javaFile, getErrorText(wid), wid, htmlSnippet, document.getLineOfOffset(region.getOffset()), region.getOffset() + 6,
            className.length());
      }
      provider.disconnect(javaFile);
    } catch (final Exception e) {
    }
  }
View Full Code Here

  /**
   * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
   */
  @Override
  protected void doSetInput(IEditorInput input) throws CoreException {
    setDocumentProvider(new TextFileDocumentProvider() {
      @Override
      public void connect(Object element) throws CoreException {
        super.connect(element);
        IDocument document = getDocument(element);
        if (document != null) {
View Full Code Here

TOP

Related Classes of org.eclipse.ui.editors.text.TextFileDocumentProvider$FileInfo

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.