Examples of IScanner


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

      for (int i = 0; i < methods.length; i++) {
        String methodName = methods[i].getElementName();
        try {
          if ((countStatics)
              || ((methods[i].getFlags() & Flags.AccStatic) == 0)) {
            IScanner s = ToolFactory.createScanner(false, false,
                false, false);
            s.setSource(methods[i].getSource().toCharArray());
            while (true) {
              int token = s.getNextToken();
              if (token == ITerminalSymbols.TokenNameEOF)
                break;
              if (token == ITerminalSymbols.TokenNameIdentifier) {
                add(new String(s.getCurrentTokenSource()),
                    methodName);
              }
            }
          }
        } catch (JavaModelException e) {
View Full Code Here

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

            return;
        }

        IField ifield = type.getField(field.getFieldName());
        ISourceRange sourceRange = null;
        IScanner scanner = null;
        JavaModelException ex = null;
        try {
            sourceRange = ifield.getNameRange();
        } catch (JavaModelException e) {
            ex = e;
        }
        try {
            // second try...
            if (sourceRange == null) {
                sourceRange = ifield.getSourceRange();
            }
            scanner = initScanner(type, sourceRange);
        } catch (JavaModelException e) {
            String message = "Can not complete field annotation " + field + " for the field: " + ifield + " in class: "
                    + qualifiedClassName + ", type " + type + ", bug " + bug;
            if (ex != null) {
                // report only first one
                e = ex;
            }
            FindbugsPlugin.getDefault().logMessage(IStatus.WARNING, message, e);
        }
        if (scanner == null || sourceRange == null) {
            return;
        }
        int lineNbr = scanner.getLineNumber(sourceRange.getOffset());
        lineNbr = lineNbr <= 0 ? 1 : lineNbr;
        String sourceFileStr = getSourceFileHint(type, qualifiedClassName);
        field.setSourceLines(new SourceLineAnnotation(qualifiedClassName, sourceFileStr, lineNbr, lineNbr, 0, 0));
    }
View Full Code Here

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

    private static int getLineStart(IType source) throws JavaModelException {
        ISourceRange range = source.getNameRange();
        if (range == null) {
            range = source.getSourceRange();
        }
        IScanner scanner = initScanner(source, range);
        if (scanner != null && range != null) {
            return scanner.getLineNumber(range.getOffset());
        }
        return START_LINE_OF_ENCLOSING_TYPE;
    }
View Full Code Here

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

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

      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

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

          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

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

     * 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

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

      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

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

          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

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

     * 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
TOP
Copyright © 2018 www.massapi.com. 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.