Beispiel #1
0
 public void testConcurrentConnect() {
   try {
     tokenHandler.connect();
     tokenHandler.connect();
     tokenHandler.disconnect();
   } catch (TokenException ex) {
     fail(ex.toString());
   }
 }
Beispiel #2
0
 public void testConcurrentLogin() {
   try {
     tokenHandler.connect();
     tokenHandler.loginPIN(pinCode);
     tokenHandler.loginPIN(pinCode);
     tokenHandler.logoutPIN();
     tokenHandler.disconnect();
   } catch (Exception e) {
     fail(e.toString());
   }
 }
  /*
   * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
   */
  public void createPresentation(TextPresentation presentation, ITypedRegion region) {

    if (fScanner == null) {
      // will be removed if deprecated constructor will be removed
      addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
      return;
    }

    int lastStart = region.getOffset();
    int length = 0;
    boolean firstToken = true;
    IToken lastToken = Token.UNDEFINED;
    TextAttribute lastAttribute = getTokenTextAttribute(lastToken);

    fScanner.setRange(fDocument, lastStart, region.getLength());

    while (true) {
      IToken token = fScanner.nextToken();
      if (token.isEOF()) break;

      TextAttribute attribute = getTokenTextAttribute(token);
      if (lastAttribute != null && lastAttribute.equals(attribute)) {
        length += fScanner.getTokenLength();
        firstToken = false;
      } else {
        if (!firstToken) addRange(presentation, lastStart, length, lastAttribute);
        firstToken = false;
        lastToken = token;
        lastAttribute = attribute;
        lastStart = fScanner.getTokenOffset();
        length = fScanner.getTokenLength();
      }
    }

    addRange(presentation, lastStart, length, lastAttribute);
  }
 /**
  * Returns a text attribute encoded in the given token. If the token's data is not <code>null
  * </code> and a text attribute it is assumed that it is the encoded text attribute. It returns
  * the default text attribute if there is no encoded text attribute found.
  *
  * @param token the token whose text attribute is to be determined
  * @return the token's text attribute
  */
 protected TextAttribute getTokenTextAttribute(IToken token) {
   Object data = token.getData();
   if (data instanceof TextAttribute) return (TextAttribute) data;
   return fDefaultTextAttribute;
 }
Beispiel #5
0
 private void addToken(IToken token, int line) {
   token.setLine(line);
   expectedList.add(token);
 }