Search in sources :

Example 1 with NULL_Location

use of org.eclipse.titan.designer.AST.NULL_Location in project titan.EclipsePlug-ins by eclipse.

the class SpecificValue_Template method checkThisTemplateGeneric.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplateGeneric(final CompilationTimeStamp timestamp, final IType type, final boolean isModified, final boolean allowOmit, final boolean allowAnyOrOmit, final boolean subCheck, final boolean implicitOmit, final Assignment lhs) {
    if (getIsErroneous(timestamp)) {
        return false;
    }
    if (type == null) {
        return false;
    }
    boolean selfReference = false;
    type.check(timestamp);
    if (specificValue != null) {
        specificValue.setMyGovernor(type);
        final IValue temporalValue = type.checkThisValueRef(timestamp, specificValue);
        selfReference = type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(Expected_Value_type.EXPECTED_TEMPLATE, isModified, allowOmit, true, implicitOmit, false));
    }
    checkLengthRestriction(timestamp, type);
    if (!allowOmit && isIfpresent) {
        if (location != null && !(location instanceof NULL_Location)) {
            location.reportSemanticError("`ifpresent' is not allowed here");
        } else if (specificValue != null && !(specificValue.getLocation() instanceof NULL_Location)) {
            specificValue.getLocation().reportSemanticError("`ifpresent' is not allowed here");
        }
    }
    if (subCheck) {
        type.checkThisTemplateSubtype(timestamp, this);
    }
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)

Example 2 with NULL_Location

use of org.eclipse.titan.designer.AST.NULL_Location in project titan.EclipsePlug-ins by eclipse.

the class Export_Debug_AST method printInfoln.

private void printInfoln(int padding, String kind, String fullname, CompilationTimeStamp timestamp, Location location) {
    while (paddingBuffer.length() < padding * 2) {
        paddingBuffer.append("  ");
    }
    MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream();
    stream.print(paddingBuffer.substring(0, padding * 2));
    stream.print(kind + " " + fullname);
    if (timestamp != null) {
        stream.print(" last checked at " + timestamp);
    }
    if (location instanceof NULL_Location) {
        stream.println(" is located at null location");
    } else {
        stream.println(" is located at line " + location.getLine() + " between " + location.getOffset() + " - " + location.getEndOffset());
    }
}
Also used : NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream)

Example 3 with NULL_Location

use of org.eclipse.titan.designer.AST.NULL_Location in project titan.EclipsePlug-ins by eclipse.

the class JavaGenData method collectProjectSettings.

public void collectProjectSettings(final Location location) {
    if (location == null || (location instanceof NULL_Location)) {
        return;
    }
    final IResource f = location.getFile();
    if (f == null) {
        return;
    }
    final IProject project = f.getProject();
    if (project == null) {
        return;
    }
    try {
        String s = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TITANFlagsOptionsData.ALLOW_OMIT_IN_VALUELIST_TEMPLATE_PROPERTY));
        allowOmitInValueList = s == null || "true".equals(s);
        s = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TITANFlagsOptionsData.DISABLE_RAW_PROPERTY));
        rawDisabled = s == null || "true".equals(s);
        // Legacy codec handling is not supported in the Java code generator
        // s = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER,TITANFlagsOptionsData.ENABLE_LEGACY_ENCODING_PROPERTY));
        // legacyCodecHandling = s == null || "true".equals(s);
        legacyCodecHandling = false;
        s = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TITANFlagsOptionsData.ADD_SOURCELINEINFO_PROPERTY));
        addSourceInfo = s == null || "true".equals(s);
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return;
    }
}
Also used : NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) CoreException(org.eclipse.core.runtime.CoreException) QualifiedName(org.eclipse.core.runtime.QualifiedName) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 4 with NULL_Location

use of org.eclipse.titan.designer.AST.NULL_Location in project titan.EclipsePlug-ins by eclipse.

the class TTCN3Template method allowOmitInValueList.

/**
 * Test if omit is allowed in a value list
 * <p>
 *  Uses TITANFlagsOptionsData.ALLOW_OMIT_IN_VALUELIST_TEMPLATE_PROPERTY:
 *  (It is the same as -M flag of makefilegen) <p>
 *  If it is true the old syntax allowed.
 *  If it is false then only the new syntax is allowed.<p>
 *	For example:<p/>
 *	 ( 1 ifpresent, 2 ifpresent, omit ) //=> allowed in old solution,
 *                                           not allowed in new solution (3 error markers)<p>
 *	 ( 1, 2 ) ifpresent //= only this allowed in new solution when this function returns false<p>
 *
 * @param allowOmit true if the field is optional field,
 *                  false if the field is mandatory.<p>
 *                  Of course in this case omit value and the ifpresent clause is prohibitied=> returns false<p>
 * @return
 *   If allowOmit == false it returns false
 *   ( quick exit for mandatory fields).
 *	 If allowOmit == true it returns according to the
 *	 project property setting
 *   TITANFlagsOptionsData.ALLOW_OMIT_IN_VALUELIST_TEMPLATE_PROPERTY
 */
public static final boolean allowOmitInValueList(final Location location, final boolean allowOmit) {
    if (!allowOmit) {
        return false;
    }
    if (location == null || (location instanceof NULL_Location)) {
        return true;
    }
    final IResource f = location.getFile();
    if (f == null) {
        return true;
    }
    final IProject project = f.getProject();
    if (project == null) {
        return true;
    }
    final QualifiedName qn = new QualifiedName(ProjectBuildPropertyData.QUALIFIER, TITANFlagsOptionsData.ALLOW_OMIT_IN_VALUELIST_TEMPLATE_PROPERTY);
    try {
        final String s = project.getPersistentProperty(qn);
        return ("true".equals(s));
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return true;
    }
}
Also used : NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) CoreException(org.eclipse.core.runtime.CoreException) QualifiedName(org.eclipse.core.runtime.QualifiedName) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Aggregations

NULL_Location (org.eclipse.titan.designer.AST.NULL_Location)4 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 QualifiedName (org.eclipse.core.runtime.QualifiedName)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)1 IValue (org.eclipse.titan.designer.AST.IValue)1 MessageConsoleStream (org.eclipse.ui.console.MessageConsoleStream)1