Package org.eclipse.jdt.core.compiler

Examples of org.eclipse.jdt.core.compiler.IScanner


        }
        char[] charContent = getContent(source);
        if (charContent == null) {
            return null;
        }
        IScanner scanner = ToolFactory.createScanner(false, false, false, true);
        scanner.setSource(charContent);
        int offset = range.getOffset();
        try {
            while (scanner.getNextToken() != ITerminalSymbols.TokenNameEOF) {
                // do nothing, just wait for the end of stream
                if (offset <= scanner.getCurrentTokenEndPosition()) {
                    break;
                }
            }
        } catch (InvalidInputException e) {
            FindbugsPlugin.getDefault().logException(e, "Could not init scanner for type: " + source);
View Full Code Here


      return null;
    IDocument doc = getDocument();
    if (doc == null)
      return null;

    IScanner scanner = null;
    if (fUpdatingCount == 1)
      scanner = fSharedScanner; // reuse scanner

    return new FoldingStructureComputationContext(doc, model, allowCollapse, scanner);
  }
View Full Code Here

          ctx.setHasHeaderComment();
        }
      }

      final int shift = range.getOffset();
      IScanner scanner = ctx.getScanner();
      scanner.resetTo(shift, shift + range.getLength());

      int start = shift;
      while (true) {

        int token = scanner.getNextToken();
        start = scanner.getCurrentTokenStartPosition();

        switch (token) {
        case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
        case ITerminalSymbols.TokenNameCOMMENT_BLOCK: {
          int end = scanner.getCurrentTokenEndPosition() + 1;
          regions.add(new Region(start, end - start));
          continue;
        }
        case ITerminalSymbols.TokenNameCOMMENT_LINE:
          continue;
View Full Code Here

     * scan the header content up to the first type. Once a comment is
     * found, accumulate any additional comments up to the stop condition.
     * The stop condition is reaching a package declaration, import container,
     * or the end of the input.
     */
    IScanner scanner = ctx.getScanner();
    scanner.resetTo(start, end);

    int headerStart = -1;
    int headerEnd = -1;
    try {
      boolean foundComment = false;
      int terminal = scanner.getNextToken();
      while (terminal != ITerminalSymbols.TokenNameEOF &&
              !(terminal == ITerminalSymbols.TokenNameclass ||
                      terminal == ITerminalSymbols.TokenNameinterface ||
                      terminal == ITerminalSymbols.TokenNameenum || (foundComment && (terminal == ITerminalSymbols.TokenNameimport || terminal == ITerminalSymbols.TokenNamepackage)))) {

        if (terminal == ITerminalSymbols.TokenNameCOMMENT_JAVADOC ||
                terminal == ITerminalSymbols.TokenNameCOMMENT_BLOCK ||
                terminal == ITerminalSymbols.TokenNameCOMMENT_LINE) {
          if (!foundComment)
            headerStart = scanner.getCurrentTokenStartPosition();
          headerEnd = scanner.getCurrentTokenEndPosition();
          foundComment = true;
        }
        terminal = scanner.getNextToken();
      }

    } catch (InvalidInputException ex) {
      return null;
    }
View Full Code Here

      return null;
    IDocument doc = getDocument();
    if (doc == null)
      return null;

    IScanner scanner = null;
    if (fUpdatingCount == 1)
      scanner = fSharedScanner; // reuse scanner

    return new FoldingStructureComputationContext(doc, model, allowCollapse, scanner);
  }
View Full Code Here

          ctx.setHasHeaderComment();
        }
      }

      final int shift = range.getOffset();
      IScanner scanner = ctx.getScanner();
      scanner.resetTo(shift, shift + range.getLength());

      int start = shift;
      while (true) {

        int token = scanner.getNextToken();
        start = scanner.getCurrentTokenStartPosition();

        switch (token) {
        case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
        case ITerminalSymbols.TokenNameCOMMENT_BLOCK: {
          int end = scanner.getCurrentTokenEndPosition() + 1;
          regions.add(new Region(start, end - start));
          continue;
        }
        case ITerminalSymbols.TokenNameCOMMENT_LINE:
          continue;
View Full Code Here

     * scan the header content up to the first type. Once a comment is
     * found, accumulate any additional comments up to the stop condition.
     * The stop condition is reaching a package declaration, import container,
     * or the end of the input.
     */
    IScanner scanner = ctx.getScanner();
    scanner.resetTo(start, end);

    int headerStart = -1;
    int headerEnd = -1;
    try {
      boolean foundComment = false;
      int terminal = scanner.getNextToken();
      while (terminal != ITerminalSymbols.TokenNameEOF &&
              !(terminal == ITerminalSymbols.TokenNameclass ||
                      terminal == ITerminalSymbols.TokenNameinterface ||
                      terminal == ITerminalSymbols.TokenNameenum || (foundComment && (terminal == ITerminalSymbols.TokenNameimport || terminal == ITerminalSymbols.TokenNamepackage)))) {

        if (terminal == ITerminalSymbols.TokenNameCOMMENT_JAVADOC ||
                terminal == ITerminalSymbols.TokenNameCOMMENT_BLOCK ||
                terminal == ITerminalSymbols.TokenNameCOMMENT_LINE) {
          if (!foundComment)
            headerStart = scanner.getCurrentTokenStartPosition();
          headerEnd = scanner.getCurrentTokenEndPosition();
          foundComment = true;
        }
        terminal = scanner.getNextToken();
      }

    } catch (InvalidInputException ex) {
      return null;
    }
View Full Code Here

    buf = compilationUnit.getBuffer();
  }
  final int start= range.getOffset();
  final int length= range.getLength();
  if (length > 0 && buf.getChar(start) == '/') {
    IScanner scanner= ToolFactory.createScanner(true, false, false, false);
    try {
      scanner.setSource(buf.getText(start, length).toCharArray());
      int docOffset= -1;
      int docEnd= -1;

      int terminal= scanner.getNextToken();
      loop: while (true) {
        switch(terminal) {
          case ITerminalSymbols.TokenNameCOMMENT_JAVADOC :
            docOffset= scanner.getCurrentTokenStartPosition();
            docEnd= scanner.getCurrentTokenEndPosition() + 1;
            terminal= scanner.getNextToken();
            break;
          case ITerminalSymbols.TokenNameCOMMENT_LINE :
          case ITerminalSymbols.TokenNameCOMMENT_BLOCK :
            terminal= scanner.getNextToken();
            continue loop;
          default :
            break loop;
        }
      }
View Full Code Here

      // All other element types require some parsing...
      String contents = reference.getSource();

      if (contents == null) return null;

      IScanner scanner = ToolFactory.createScanner(true, false, false, false);
      scanner.setSource(contents.toCharArray());

      int shift = range.getOffset();
      int start = shift;

      while (true) {
        int token = scanner.getNextToken();

        start = shift + scanner.getCurrentTokenStartPosition();
        int end = shift + scanner.getCurrentTokenEndPosition() + 1;

        if (!strategy.keepProcessing(token) || token == ITerminalSymbols.TokenNameEOF) {
          break; // end case.
        }
View Full Code Here

      // All other element types require some parsing...
      String contents = reference.getSource();

      if (contents == null) return null;

      IScanner scanner = ToolFactory.createScanner(true, false, false, false);
      scanner.setSource(contents.toCharArray());

      int shift = range.getOffset();
      int start = shift;

      while (true) {
        int token = scanner.getNextToken();

        start = shift + scanner.getCurrentTokenStartPosition();
        int end = shift + scanner.getCurrentTokenEndPosition() + 1;

        if (!strategy.keepProcessing(token) || token == ITerminalSymbols.TokenNameEOF) {
          break; // end case.
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.compiler.IScanner

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.