use of org.eclipse.titan.designer.editors.GeneralPairMatcher in project titan.EclipsePlug-ins by eclipse.
the class ASN1ReferenceParser method findReferenceForOpening.
@Override
public final Reference findReferenceForOpening(final IFile file, final int offset, final IDocument document) {
Reference reference = null;
ofs = offset - 1;
if (-1 == ofs) {
return reference;
}
try {
GeneralPairMatcher pairMatcher = new ASN1ReferencePairMatcher();
ofs = referenceStartOffset(ofs, document, pairMatcher);
if (-1 == ofs) {
return reference;
}
// the last character where the loop stopped is not part
// of the reference
ofs++;
int endoffset = offset;
if (endoffset >= document.getLength()) {
return reference;
}
char currentChar = document.getChar(endoffset);
while (endoffset < document.getLength() && (Character.isLetterOrDigit(currentChar) || currentChar == '(' || currentChar == '_' || currentChar == '-')) {
if (currentChar == '(') {
break;
}
endoffset++;
if (endoffset >= document.getLength()) {
return reference;
}
currentChar = document.getChar(endoffset);
}
String toBeParsed = document.get(ofs, endoffset - ofs);
ASN1ReferenceParser refAnalyzer = newInstance();
reference = refAnalyzer.parseReference(file, toBeParsed, document.getLineOfOffset(ofs) + 1, ofs);
} catch (BadLocationException e) {
ErrorReporter.logExceptionStackTrace(e);
}
return reference;
}
use of org.eclipse.titan.designer.editors.GeneralPairMatcher in project titan.EclipsePlug-ins by eclipse.
the class ASN1ReferenceParser method findReferenceForCompletion.
@Override
public final Reference findReferenceForCompletion(final IFile file, final int offset, final IDocument document) {
Reference reference = null;
ofs = offset - 1;
if (-1 == ofs) {
return reference;
}
try {
char currentChar = document.getChar(ofs);
if (']' == currentChar || ')' == currentChar || '}' == currentChar) {
return reference;
}
GeneralPairMatcher pairMatcher = new ASN1ReferencePairMatcher();
ofs = referenceStartOffset(ofs, document, pairMatcher);
if (-1 == ofs) {
return reference;
}
// the last character where the loop stopped is not part
// of the reference
ofs++;
String toBeParsed = document.get(ofs, offset - ofs);
ASN1ReferenceParser refAnalyzer = newInstance();
reference = refAnalyzer.parseReference(file, toBeParsed, document.getLineOfOffset(ofs) + 1, ofs);
} catch (BadLocationException e) {
ErrorReporter.logExceptionStackTrace(e);
}
return reference;
}
use of org.eclipse.titan.designer.editors.GeneralPairMatcher in project titan.EclipsePlug-ins by eclipse.
the class DoubleClickStrategy method doubleClicked.
@Override
public final void doubleClicked(final ITextViewer part) {
int pos = part.getSelectedRange().x;
fText = part;
if (fText.getDocument().getLength() < pos) {
return;
}
if (pos < 0) {
return;
}
GeneralPairMatcher pairMatcher = new PairMatcher();
IRegion region = pairMatcher.match(fText.getDocument(), pos);
if (region != null) {
fText.setSelectedRange(region.getOffset() + 1, region.getLength() - 2);
return;
}
selectWord(pos);
}
use of org.eclipse.titan.designer.editors.GeneralPairMatcher in project titan.EclipsePlug-ins by eclipse.
the class TTCN3ReferenceParser method findReferenceForCompletion.
@Override
public Reference findReferenceForCompletion(final IFile file, final int offset, final IDocument document) {
Reference reference = null;
ofs = offset - 1;
if (-1 == ofs) {
return reference;
}
try {
char currentChar = document.getChar(ofs);
if (')' == currentChar || '}' == currentChar) {
return reference;
}
GeneralPairMatcher pairMatcher = new TTCN3ReferencePairMatcher();
int tempOfs = referenceStartOffset(ofs, document, pairMatcher);
if (-1 == tempOfs) {
return reference;
}
if (tempOfs > 3) {
if ("any ".equals(document.get(tempOfs - 2, 4)) || "all ".equals(document.get(tempOfs - 2, 4))) {
tempOfs -= 3;
}
}
ofs = tempOfs;
// the last character where the loop stopped is not part
// of the reference
ofs++;
String toBeParsed = document.get(ofs, offset - ofs);
TTCN3ReferenceAnalyzer refAnalyzer = new TTCN3ReferenceAnalyzer();
reference = refAnalyzer.parseForCompletion(file, toBeParsed);
} catch (BadLocationException e) {
ErrorReporter.logExceptionStackTrace(e);
}
return reference;
}
use of org.eclipse.titan.designer.editors.GeneralPairMatcher in project titan.EclipsePlug-ins by eclipse.
the class TTCN3ReferenceParser method findReferenceForOpening.
@Override
public Reference findReferenceForOpening(final IFile file, final int offset, final IDocument document) {
Reference reference = null;
ofs = offset - 1;
int endoffset = offset;
if (-1 == ofs) {
return reference;
}
try {
GeneralPairMatcher pairMatcher = new TTCN3ReferencePairMatcher();
ofs = referenceStartOffset(ofs, document, pairMatcher);
if (-1 == ofs) {
return reference;
}
// the last character where the loop stopped is not part
// of the reference
ofs++;
if (endoffset >= document.getLength()) {
return reference;
}
char currentChar = document.getChar(endoffset);
while (endoffset < document.getLength() && (Character.isLetterOrDigit(currentChar) || currentChar == '(' || currentChar == '_')) {
if (currentChar == '(') {
break;
}
endoffset++;
if (endoffset >= document.getLength()) {
return reference;
}
currentChar = document.getChar(endoffset);
}
String toBeParsed = document.get(ofs, endoffset - ofs);
if (toBeParsed.trim().length() == 0) {
return reference;
}
TTCN3ReferenceAnalyzer refAnalyzer = new TTCN3ReferenceAnalyzer();
reference = refAnalyzer.parse(file, toBeParsed, reportErrors, document.getLineOfOffset(ofs) + 1, ofs);
} catch (BadLocationException e) {
ErrorReporter.logExceptionStackTrace(e);
}
return reference;
}
Aggregations