Implementation of the <code>IAction</code> prototype. Checks if the selected
lines are all commented or not and uncomments/comments them respectively.
499191
public void run() {
		if (fOperationTarget == null || fDocumentPartitioning == null || fPrefixesMap == null)
			return;

		ITextEditor editor= getTextEditor();
		if (editor == null)
			return;

		if (!validateEditorInputState())
			return;

		final int operationCode;
		if (isSelectionCommented(editor.getSelectionProvider().getSelection()))
			operationCode= ITextOperationTarget.STRIP_PREFIX;
		else
			operationCode= ITextOperationTarget.PREFIX;

		Shell shell= editor.getSite().getShell();
		if (!fOperationTarget.canDoOperation(operationCode)) {
			if (shell != null)
				MessageDialog.openError(shell, "ToggleComment_error_title", "ToggleComment_error_message");
			return;
		}

		Display display= null;
		if (shell != null && !shell.isDisposed())
			display= shell.getDisplay();

		BusyIndicator.showWhile(display, new Runnable() {
			public void run() {
				fOperationTarget.doOperation(operationCode);
			}
		});
	}
635492
function emitTrailingCommentsOfPosition(pos) {
                if (compilerOptions.removeComments) {
                    return;
                }
                var trailingComments = ts.getTrailingCommentRanges(currentText, pos);
                // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
                ts.emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
            }
508689
private Description checkAnnotations(
      Tree tree,
      int treePos,
      List<? extends AnnotationTree> annotations,
      Comment danglingJavadoc,
      int firstModifierPos,
      int lastModifierPos,
      VisitorState state) {
    SuggestedFix.Builder builder = SuggestedFix.builder();
    List<AnnotationTree> moveBefore = new ArrayList<>();
    List<AnnotationTree> moveAfter = new ArrayList<>();

    boolean annotationProblem = false;
    for (AnnotationTree annotation : annotations) {
      int annotationPos = ((JCTree) annotation).getStartPosition();
      if (annotationPos <= firstModifierPos) {
        continue;
      }
      AnnotationType annotationType =
          ASTHelpers.getAnnotationType(annotation, getSymbol(tree), state);
      if (annotationPos >= lastModifierPos) {
        if (tree instanceof ClassTree || annotationType == AnnotationType.DECLARATION) {
          annotationProblem = true;
          moveBefore.add(annotation);
        }
      } else {
        annotationProblem = true;
        if (tree instanceof ClassTree
            || annotationType == AnnotationType.DECLARATION
            || annotationType == null) {
          moveBefore.add(annotation);
        } else {
          moveAfter.add(annotation);
        }
      }
    }
    if (annotationProblem) {
      for (AnnotationTree annotation : moveBefore) {
        builder.delete(annotation);
      }
      for (AnnotationTree annotation : moveAfter) {
        builder.delete(annotation);
      }
      String javadoc =
          danglingJavadoc == null ? "" : removeJavadoc(state, treePos, danglingJavadoc, builder);
      builder
          .replace(
              firstModifierPos,
              firstModifierPos,
              String.format("%s%s ", javadoc, joinSource(state, moveBefore)))
          .replace(
              lastModifierPos, lastModifierPos, String.format("%s ", joinSource(state, moveAfter)));
      ImmutableList<String> names =
          annotations.stream()
              .map(ASTHelpers::getSymbol)
              .filter(Objects::nonNull)
              .map(Symbol::getSimpleName)
              .map(a -> "@" + a)
              .collect(toImmutableList());
      String flattened = names.stream().collect(joining(", "));
      String isAre = names.size() > 1 ? "are not type annotations" : "is not a type annotation";
      String message =
          String.format(
              "%s %s, so should appear before any modifiers and after Javadocs.", flattened, isAre);
      return buildDescription(tree).setMessage(message).addFix(builder.build()).build();
    }
    return NO_MATCH;
  }
254131
public final void mCOMMENT() throws RecognitionException {
        try {
            int _type = COMMENT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // EventFilter.g:204:5: ( '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' | '/*' ( options {greedy=false; } : . )* '*/' )
            int alt15=2;
            int LA15_0 = input.LA(1);

            if ( (LA15_0=='/') ) {
                int LA15_1 = input.LA(2);

                if ( (LA15_1=='/') ) {
                    alt15=1;
                }
                else if ( (LA15_1=='*') ) {
                    alt15=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 15, 1, input);

                    throw nvae;

                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 15, 0, input);

                throw nvae;

            }
            switch (alt15) {
                case 1 :
                    // EventFilter.g:204:9: '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n'
                    {
                    match("//"); 



                    // EventFilter.g:204:14: (~ ( '\\n' | '\\r' ) )*
                    loop12:
                    do {
                        int alt12=2;
                        int LA12_0 = input.LA(1);

                        if ( ((LA12_0 >= '\u0000' && LA12_0 <= '\t')||(LA12_0 >= '\u000B' && LA12_0 <= '\f')||(LA12_0 >= '\u000E' && LA12_0 <= '\uFFFF')) ) {
                            alt12=1;
                        }


                        switch (alt12) {
                    	case 1 :
                    	    // EventFilter.g:
                    	    {
                    	    if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '\t')||(input.LA(1) >= '\u000B' && input.LA(1) <= '\f')||(input.LA(1) >= '\u000E' && input.LA(1) <= '\uFFFF') ) {
                    	        input.consume();
                    	    }
                    	    else {
                    	        MismatchedSetException mse = new MismatchedSetException(null,input);
                    	        recover(mse);
                    	        throw mse;
                    	    }


                    	    }
                    	    break;

                    	default :
                    	    break loop12;
                        }
                    } while (true);


                    // EventFilter.g:204:28: ( '\\r' )?
                    int alt13=2;
                    int LA13_0 = input.LA(1);

                    if ( (LA13_0=='\r') ) {
                        alt13=1;
                    }
                    switch (alt13) {
                        case 1 :
                            // EventFilter.g:204:28: '\\r'
                            {
                            match('\r'); 

                            }
                            break;

                    }


                    match('\n'); 

                    _channel=HIDDEN;

                    }
                    break;
                case 2 :
                    // EventFilter.g:205:9: '/*' ( options {greedy=false; } : . )* '*/'
                    {
                    match("/*"); 



                    // EventFilter.g:205:14: ( options {greedy=false; } : . )*
                    loop14:
                    do {
                        int alt14=2;
                        int LA14_0 = input.LA(1);

                        if ( (LA14_0=='*') ) {
                            int LA14_1 = input.LA(2);

                            if ( (LA14_1=='/') ) {
                                alt14=2;
                            }
                            else if ( ((LA14_1 >= '\u0000' && LA14_1 <= '.')||(LA14_1 >= '0' && LA14_1 <= '\uFFFF')) ) {
                                alt14=1;
                            }


                        }
                        else if ( ((LA14_0 >= '\u0000' && LA14_0 <= ')')||(LA14_0 >= '+' && LA14_0 <= '\uFFFF')) ) {
                            alt14=1;
                        }


                        switch (alt14) {
                    	case 1 :
                    	    // EventFilter.g:205:42: .
                    	    {
                    	    matchAny(); 

                    	    }
                    	    break;

                    	default :
                    	    break loop14;
                        }
                    } while (true);


                    match("*/"); 



                    _channel=HIDDEN;

                    }
                    break;

            }
            state.type = _type;
            state.channel = _channel;
        }
        finally {
        	// do for sure before leaving
        }
    }
750067
function hasCommentAfter(node, sourceCode) {
  return sourceCode.getCommentsAfter(node)
    .some(comment => comment.loc.start.line === node.loc.end.line)
}
321568
function hasCommentInsideNonSpecifiers(node, sourceCode) {
  const tokens = sourceCode.getTokens(node)
  const openBraceIndex = tokens.findIndex(token => isPunctuator(token, '{'))
  const closeBraceIndex = tokens.findIndex(token => isPunctuator(token, '}'))
  // Slice away the first token, since we're no looking for comments _before_
  // `node` (only inside). If there's a `{...}` part, look for comments before
  // the `{`, but not before the `}` (hence the `+1`s).
  const someTokens = openBraceIndex >= 0 && closeBraceIndex >= 0
    ? tokens.slice(1, openBraceIndex + 1).concat(tokens.slice(closeBraceIndex + 1))
    : tokens.slice(1)
  return someTokens.some(token => sourceCode.getCommentsBefore(token).length > 0)
}
979308
function onComment(isBlock, text, _s, _e, sLoc, eLoc) {

  var tRegex = /test\s*>\s*(.*)/i;
  var aRegex = /#\s*(.*)/i;
  var isTest = R.test(tRegex);
  var extractTest = R.pipe(R.match(tRegex), R.last(), R.trim());
  var isAssertion = R.test(aRegex);
  var extractAssertion = R.pipe(R.match(aRegex), R.last(), R.trim());
  var lastTestFound = R.last(tests);
  var newTest;

  function belongToTest(locLine, test) {
    return (test === undefined) ? false : locLine - 1 === test.loc.endLine;
  }

  function createEmptyTest(title) {
    return {
      title: title || null,
      loc: { startLine: sLoc.line, endLine: eLoc.line },
      assertions: []
    };
  }

  function addAssertionToTest(assertion, test) {
    test.assertions.push(assertion);
    test.loc.endLine = eLoc.line;
    return test;
  }

  function setTestTitle(title, test) {
    test.title = title;
    return test;
  }

  function buildTest(test, string) {
    if (isTest(string)) {
      setTestTitle(extractTest(string), test);
    } else if (isAssertion(string)) {
      addAssertionToTest(extractAssertion(string), test);
    }
    return test;
  }

  if (!isBlock) {
    if (isTest(text)) {
      newTest = R.pipe(extractTest, createEmptyTest)(text);
      tests.push(newTest);
    } else if (isAssertion(text) && belongToTest(sLoc.line, lastTestFound)) {
      addAssertionToTest(extractAssertion(text), lastTestFound);
    }
  }

  if (isBlock && isTest(text)) {
    newTest = R.reduce(buildTest, createEmptyTest(), R.split('\n', text));
    tests.push(newTest);
  }
}
764702
private boolean ignoreComment( ) throws IOException
    {
    	StringBuffer comment = new StringBuffer();
        int prev = 0;
        int character = 0;
        boolean endFound = false;
        boolean eofFound = false;
        while( endFound == false )
        {
            prev = character;
            character = readCharacter();
            if (character != -1) 
            {
                comment.append( (char) character );
                if ( character == '>' && prev =='%' )
                {
                   String fullComment = comment.toString(); 
                   if (fullComment.endsWith("--%>"))
                   {
                     endFound = true;
                   }
                }
            }
            else 
            {
              eofFound = endFound = true;
            }
        } // end "while"
        return eofFound;
    }
525900
static MatchedComment match(Commented<ExpressionTree> actual, String formal) {
    Optional<Comment> lastBlockComment =
        Streams.findLast(
            actual.beforeComments().stream().filter(c -> c.getStyle() == CommentStyle.BLOCK));

    if (lastBlockComment.isPresent()) {
      Matcher m =
          PARAMETER_COMMENT_PATTERN.matcher(Comments.getTextFromComment(lastBlockComment.get()));
      if (m.matches()) {
        return MatchedComment.create(
            lastBlockComment.get(),
            m.group(1).equals(formal) ? MatchType.EXACT_MATCH : MatchType.BAD_MATCH);
      }
    }

    Optional<Comment> approximateMatchComment =
        Stream.concat(actual.beforeComments().stream(), actual.afterComments().stream())
            .filter(comment -> isApproximateMatchingComment(comment, formal))
            .findFirst();

    if (approximateMatchComment.isPresent()) {
      // Report EXACT_MATCH for comments that don't use the recommended style (e.g. `/*foo*/`
      // instead of `/* foo= */`), but which match the formal parameter name exactly, since it's
      // a style nit rather than a possible correctness issue.
      // TODO(cushon): revisit this if we standardize on the recommended comment style.
      String text =
          CharMatcher.anyOf("=:")
              .trimTrailingFrom(Comments.getTextFromComment(approximateMatchComment.get()).trim());
      return MatchedComment.create(
          approximateMatchComment.get(),
          text.equals(formal) ? MatchType.EXACT_MATCH : MatchType.APPROXIMATE_MATCH);
    }

    return MatchedComment.notAnnotated();
  }
304058
def _get_line_no_from_comments(py_line):
    """"""
    matched = LINECOL_COMMENT_RE.match(py_line)
    if matched:
        return int(matched.group(1))
    else:
        return 0
1068730
public boolean isLineOfCode(final String line) {
        if (line.length() < getIndicatorAreaPos() + 1) {
            return false;
        }

        /* Remove white space lines */
        if (line.trim().length() == 0) {
            return false;
        }

        /* Remove comments and special lines */
        if (isComment(line)) {
            return false;
        }

        /*
         * If there is a single token on this line, make sure it is not a
         * compiler directive.
         */
        String[] tokens = line.trim().split("[\\s\\.]+");
        if (tokens.length == 1
                && COMPILER_DIRECTIVES.contains(tokens[0].toUpperCase(Locale
                        .getDefault()))) {
            return false;
        }

        return true;
    }
17908
private String readComment() {
    if (pos == data.length || data[pos] != '/') throw new AssertionError();
    pos++;
    int commentType = pos < data.length ? data[pos++] : -1;
    if (commentType == '*') {
      StringBuilder result = new StringBuilder();
      boolean startOfLine = true;

      for (; pos + 1 < data.length; pos++) {
        char c = data[pos];
        if (c == '*' && data[pos + 1] == '/') {
          pos += 2;
          return result.toString().trim();
        }
        if (c == '\n') {
          result.append('\n');
          newline();
          startOfLine = true;
        } else if (!startOfLine) {
          result.append(c);
        } else if (c == '*') {
          if (data[pos + 1] == ' ') {
            pos += 1; // Skip a single leading space, if present.
          }
          startOfLine = false;
        } else if (!Character.isWhitespace(c)) {
          result.append(c);
          startOfLine = false;
        }
      }
      throw unexpected("unterminated comment");
    } else if (commentType == '/') {
      if (pos < data.length && data[pos] == ' ') {
        pos += 1; // Skip a single leading space, if present.
      }
      int start = pos;
      while (pos < data.length) {
        char c = data[pos++];
        if (c == '\n') {
          newline();
          break;
        }
      }
      return new String(data, start, pos - 1 - start);
    } else {
      throw unexpected("unexpected '/'");
    }
  }
1117585
def is_code?(lineno)
      unless @is_begin_comment
        @is_begin_comment = Array.new(@lines.size, false)
        pending = []
        state = :code
        @lines.each_with_index do |line, index|
          case state
          when :code
            if /^=begin\b/ =~ line
              state = :comment
              pending << index
            end
          when :comment
            pending << index
            if /^=end\b/ =~ line
              state = :code
              pending.each{|idx| @is_begin_comment[idx] = true}
              pending.clear
            end
          end
        end
      end
      @lines[lineno] && !@is_begin_comment[lineno] && @lines[lineno] !~ /^\s*(#|$)/ 
    end
519136
protected void compareComment(Comment control, Comment test,
                                  DifferenceListener listener) throws DifferenceFoundException {
        if (!XMLUnit.getIgnoreComments()) {
            compareCharacterData(control, test, listener, COMMENT_VALUE);
        }
    }
773398
function (filter) {
            if (!filter) {
                filter = null;
            }
            var comments = this.__comments;

            if (filter !== null) {
                comments = comments.filter(function (c) {
                    return c.context === filter;
                });
            }

            return comments;
        }
1222971
@Override
    public void handleComment(
            final char[] buffer,
            final int contentOffset, final int contentLen,
            final int outerOffset, final int outerLen,
            final int line, final int col)
            throws ParseException {

        this.someSelectorsMatch = false;
        for (int i = 0; i < this.selectorsLen; i++) {

            this.selectorMatches[i] =
                    this.selectorFilters[i].matchComment(false, this.markupLevel, this.markupBlocks[this.markupLevel]);
            if (this.selectorMatches[i]) {
                this.someSelectorsMatch = true;
            }

        }

        if (this.someSelectorsMatch) {
            markCurrentSelection();
            this.selectedHandler.handleComment(
                    buffer, contentOffset, contentLen, outerOffset, outerLen, line, col);
            unmarkCurrentSelection();
            return;
        }

        unmarkCurrentSelection();
        this.nonSelectedHandler.handleComment(
                buffer, contentOffset, contentLen, outerOffset, outerLen, line, col);

    }
151065
private void scanTwoDigitSpecial() {

        if (mInput == '=' && (mType == TokenType.COMP || mType == TokenType.EQ || mType == TokenType.N_EQ)) {
            mOutput.append(mInput);
            mPos++;
        } else if (mInput == '/' && (mType == TokenType.SLASH)) {
            mOutput.append(mInput);
            mType = TokenType.DESC_STEP;
            mPos++;
        } else if (mInput == '.' && (mType == TokenType.POINT)) {
            mOutput.append(mInput);
            mType = TokenType.PARENT;
            mPos++;
        } else if (mInput == '<' && mOutput.toString().equals("<")) {
            mOutput.append(mInput);
            mType = TokenType.L_SHIFT;
            mPos++;
        } else if (mInput == '>' && mOutput.toString().equals(">")) {
            mOutput.append(mInput);
            mType = TokenType.R_SHIFT;
            mPos++;
        } else if (mInput == ':' && mType == TokenType.OPEN_BR) {
            // could be start of a comment
            mOutput = new StringBuilder();
            mType = TokenType.COMMENT;
            mCommentCount++;
            mState = State.COMMENT;
            mPos++;
        } else {
            mFinnished = true;
        }
    }