Package de.innovationgate.eclipse.editors.tmlscript

Source Code of de.innovationgate.eclipse.editors.tmlscript.TMLScriptSingelLineCommentRule

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.tmlscript;

import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;

import de.innovationgate.eclipse.editors.helpers.CharacterScannerWrapper;

public class TMLScriptSingelLineCommentRule extends SingleLineRule {

  public TMLScriptSingelLineCommentRule() {
    super("//", null, new Token(TMLScriptPartitionScanner.SCOMMENT), '\\', true);
  }

  @Override
  protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
    if (super.sequenceDetected(scanner, sequence, eofAllowed)) {
      CharacterScannerWrapper scannerWrapper = new CharacterScannerWrapper(scanner);
      char c = (char)scannerWrapper.read();
      int i = 0;
      int j = 0;
      while(scannerWrapper.getColumn()!=0){
        scannerWrapper.unread();
        scannerWrapper.unread();
        c =(char) scannerWrapper.read()
        if(c=='"'){
          i++;
        }
        if( c=='\''){
          j++;
       
      }
      scannerWrapper.reset();
     
      if(i%2==0 && j%2==0){
        return true;
      }
    }
   
   
    return false;
  }

}
TOP

Related Classes of de.innovationgate.eclipse.editors.tmlscript.TMLScriptSingelLineCommentRule

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.