Search in sources :

Example 1 with TTCN3ReferenceAnalyzer

use of org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer in project titan.EclipsePlug-ins by eclipse.

the class ConfigReferenceParser method findReferenceForOpening.

@Override
public Reference findReferenceForOpening(final IFile file, final int offset, final IDocument document) {
    Reference reference = null;
    int ofs = offset - 1;
    int endoffset = offset;
    if (-1 == offset) {
        return reference;
    }
    try {
        int tempOfs = referenceStartOffset(ofs, document);
        if (-1 == tempOfs) {
            return reference;
        }
        ofs = tempOfs + 1;
        char currentChar = document.getChar(endoffset);
        while (endoffset < document.getLength()) {
            if (!Character.isLetterOrDigit(currentChar) && currentChar != '*' && currentChar != '_' && currentChar != '.') {
                break;
            }
            currentChar = document.getChar(++endoffset);
        }
        if (!moduleParameter) {
            defineName = document.get(ofs, endoffset - ofs);
            return null;
        }
        String selected = document.get(ofs, endoffset - ofs);
        String parameter = selected;
        int dotIndex = selected.indexOf('.');
        if (dotIndex > 0) {
            String moduleName = selected.substring(0, dotIndex);
            if (!"*".equals(moduleName)) {
                exactModuleName = moduleName;
                IPreferencesService prefs = Platform.getPreferencesService();
                if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
                    TITANDebugConsole.println("Module: " + exactModuleName);
                }
            }
            parameter = selected.substring(dotIndex + 1);
        }
        TTCN3ReferenceAnalyzer refAnalyzer = new TTCN3ReferenceAnalyzer();
        reference = refAnalyzer.parse(file, parameter, 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) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 2 with TTCN3ReferenceAnalyzer

use of org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer 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 3 with TTCN3ReferenceAnalyzer

use of org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer 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

BadLocationException (org.eclipse.jface.text.BadLocationException)3 Reference (org.eclipse.titan.designer.AST.Reference)3 TTCN3ReferenceAnalyzer (org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer)3 GeneralPairMatcher (org.eclipse.titan.designer.editors.GeneralPairMatcher)2 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)1