Search in sources :

Example 1 with GeneralPairMatcher

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;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) GeneralPairMatcher(org.eclipse.titan.designer.editors.GeneralPairMatcher) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 2 with GeneralPairMatcher

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;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) GeneralPairMatcher(org.eclipse.titan.designer.editors.GeneralPairMatcher) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 3 with GeneralPairMatcher

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);
}
Also used : GeneralPairMatcher(org.eclipse.titan.designer.editors.GeneralPairMatcher) GeneralPairMatcher(org.eclipse.titan.designer.editors.GeneralPairMatcher) IRegion(org.eclipse.jface.text.IRegion)

Example 4 with GeneralPairMatcher

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;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) TTCN3ReferenceAnalyzer(org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer) GeneralPairMatcher(org.eclipse.titan.designer.editors.GeneralPairMatcher) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 5 with GeneralPairMatcher

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;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) TTCN3ReferenceAnalyzer(org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer) GeneralPairMatcher(org.eclipse.titan.designer.editors.GeneralPairMatcher) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

GeneralPairMatcher (org.eclipse.titan.designer.editors.GeneralPairMatcher)6 BadLocationException (org.eclipse.jface.text.BadLocationException)4 Reference (org.eclipse.titan.designer.AST.Reference)4 IRegion (org.eclipse.jface.text.IRegion)2 TTCN3ReferenceAnalyzer (org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer)2