/**
  * Indicates if the given file contains a main annotation (@main).
  *
  * @param file is the template file
  * @return true if the given file contains a main annotation (@main)
  */
 private boolean hasMainTag(IFile file) {
   Sequence pattern = new Sequence(IAcceleoConstants.TAG_MAIN);
   StringBuffer contents = FileContent.getFileContent(file.getLocation().toFile());
   if (pattern.search(contents).b() > -1) {
     return true;
   }
   return false;
 }
Esempio n. 2
0
 /**
  * Computes the positions of this sequence and of the ignored elements. It returns the nearest
  * one. The positions are the old positions of the elements. The returning value is an index in
  * the table 'positions'.
  *
  * @param positions are the old positions of each element
  * @param buffer is the buffer
  * @param pos is the current offset in the buffer
  * @param posEnd is the ending index
  * @param spec is a specific sequence to ignore
  * @param inhibs are some blocks to ignore
  * @return an index in the table 'positions' or -1 if there isn't any candidate
  */
 private int getOrCreateIndexOfNextPosition(
     Region[] positions,
     final StringBuffer buffer,
     int pos,
     int posEnd,
     Sequence spec,
     SequenceBlock[] inhibs) {
   if (positions[0].b() != -1 && spec != null && pos > positions[0].b()) {
     positions[0] = spec.search(buffer, pos, posEnd); // spec
   }
   if (positions[1].b() != -1 && pos > positions[1].b()) {
     positions[1] = search(buffer, pos, posEnd); // tag
   }
   for (int i = 2; i < positions.length; i++) { // inhibs
     if (positions[i].b() != -1 && pos > positions[i].b()) {
       positions[i] = inhibs[i - 2].searchBeginHeader(buffer, pos, posEnd);
     }
   }
   // Get next position
   int positionMin = posEnd;
   int iPositionMin = -1;
   for (int i = 0; i < positions.length; i++) {
     if ((positions[i].b() > -1) && (positions[i].b() < positionMin)) {
       iPositionMin = i;
       positionMin = positions[i].b();
     }
   }
   return iPositionMin;
 }