use of org.eclipse.titan.common.parsers.Interval in project titan.EclipsePlug-ins by eclipse.
the class GeneralTITANAutoEditStrategy method findMatchingOpenBracket.
/**
* Returns the line number of the next bracket after end.
*
* @returns the line number of the next matching bracket after end
* @param document
* - the document being parsed
* @param end
* - the end position to search back from (exclusive
* limit)
* @return The position of the matching open bracket
* @exception BadLocationException
* if the offset is invalid in this document
*/
protected final int findMatchingOpenBracket(final IDocument document, final int end) throws BadLocationException {
Interval interval;
interval = rootInterval.getSmallestEnclosingInterval(end);
return document.getLineOfOffset(interval.getStartOffset());
}
use of org.eclipse.titan.common.parsers.Interval in project titan.EclipsePlug-ins by eclipse.
the class HeuristicalIntervalDetector method isWithinString.
/**
* The method determines if the given offset is within a string in the
* document.
*
* @param document
* the document being parsed
* @param offset
* the position where parsing starts from
* @param enclosingInterval
* an interval, which encloses the offset.
* @return Whether offset is within a comment.
* @exception BadLocationException
* if the offset is invalid in this document
*/
// FIXME needs correction
@Override
public boolean isWithinString(final StringBuilder document, final int offset, final Interval enclosingInterval) throws BadLocationException {
Interval interval = enclosingInterval.getSmallestEnclosingInterval(offset);
if (interval_type.MULTILINE_COMMENT.equals(interval.getType()) || interval_type.SINGLELINE_COMMENT.equals(interval.getType())) {
return false;
}
int start = interval.getStartOffset();
int counter = 0;
while (start < offset) {
char curr = document.charAt(start);
if (curr == '"' || curr == '\'') {
counter++;
}
start++;
}
return counter % 2 != 0;
}
use of org.eclipse.titan.common.parsers.Interval in project titan.EclipsePlug-ins by eclipse.
the class IntervallBasedDamagerRepairer method getDamageRegion.
@Override
public IRegion getDamageRegion(final ITypedRegion partition, final DocumentEvent e, final boolean documentPartitioningChanged) {
Interval interval = GlobalIntervalHandler.getInterval(fDocument);
if (interval != null) {
int maxLength = Math.max(0, (e.getText() == null ? e.getLength() : e.getText().length()));
int endoffset = e.getOffset() + maxLength;
Interval smallest = interval.getSmallestEnclosingInterval(e.getOffset(), endoffset);
Interval canaryInterval = smallest.getSmallestEnclosingInterval(e.getOffset());
if (interval_type.MULTILINE_COMMENT.equals(canaryInterval.getType())) {
return new Region(canaryInterval.getStartOffset(), Math.min(smallest.getEndOffset() - canaryInterval.getStartOffset() + maxLength, fDocument.getLength()));
}
}
return super.getDamageRegion(partition, e, documentPartitioningChanged);
}
use of org.eclipse.titan.common.parsers.Interval in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method getSection.
/**
* Provides position dependent section information.
*
* @param document
* The document where the check takes place.
* @param offset
* The current position of the cursor.
* @return The type of the section for the current position of the
* cursor.
*/
public section_type getSection(final IDocument document, final int offset) {
Interval interval = GlobalIntervalHandler.getInterval(document);
if (interval == null) {
return section_type.UNKNOWN;
}
for (Interval subInterval : interval.getSubIntervals()) {
int startOffset = subInterval.getStartOffset();
int endOffset = subInterval.getEndOffset();
if (subInterval instanceof CfgInterval && startOffset <= offset && endOffset >= offset) {
return ((CfgInterval) subInterval).getSectionType();
}
}
return section_type.UNKNOWN;
}
use of org.eclipse.titan.common.parsers.Interval in project titan.EclipsePlug-ins by eclipse.
the class ConfigFoldingSupport method recursiveTokens.
@Override
protected void recursiveTokens(final Interval interval) {
int endOffset = interval.getEndOffset();
int startOffset = interval.getStartOffset();
if (documentText.length() <= endOffset || documentText.length() <= startOffset) {
return;
} else if (endOffset == -1) {
endOffset = documentText.length() - 1;
}
int distance = interval.getEndLine() - interval.getStartLine();
if (distance >= foldingDistance) {
char temp = documentText.charAt(startOffset);
switch(temp) {
case '{':
case '[':
if (preferencesService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.FOLD_STATEMENT_BLOCKS, true, null)) {
positions.add(new Position(startOffset, endOffset - startOffset));
}
break;
case '(':
if (preferencesService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.FOLD_PARENTHESIS, true, null)) {
positions.add(new Position(startOffset, endOffset - startOffset));
}
break;
case '/':
if (preferencesService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.FOLD_COMMENTS, true, null)) {
positions.add(new Position(startOffset, endOffset - startOffset));
}
break;
default:
break;
}
}
for (Interval subIntervall : interval.getSubIntervals()) {
recursiveTokens(subIntervall);
}
}
Aggregations