Search in sources :

Example 11 with ReParseException

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

the class FriendModule method updateSyntax.

/**
 * Handles the incremental parsing of this friend module declaration.
 *
 * @param reparser
 *                the parser doing the incremental parsing.
 * @param isDamaged
 *                true if the location contains the damaged area, false
 *                if only its' location needs to be updated.
 */
@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        boolean enveloped = false;
        int result = 1;
        final Location temporalIdentifier = identifier.getLocation();
        if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
            reparser.extendDamagedRegion(temporalIdentifier);
            final IIdentifierReparser r = new IdentifierReparser(reparser);
            result = r.parse();
            identifier = r.getIdentifier();
            // damage handled
            if (result == 0) {
                enveloped = true;
            } else {
                throw new ReParseException(result);
            }
        }
        if (withAttributesPath != null) {
            if (enveloped) {
                withAttributesPath.updateSyntax(reparser, false);
                reparser.updateLocation(withAttributesPath.getLocation());
            } else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
                reparser.extendDamagedRegion(withAttributesPath.getLocation());
                result = reparse(reparser);
            }
        }
        if (result != 0) {
            throw new ReParseException();
        }
        return;
    }
    reparser.updateLocation(identifier.getLocation());
    if (withAttributesPath != null) {
        withAttributesPath.updateSyntax(reparser, false);
        reparser.updateLocation(withAttributesPath.getLocation());
    }
}
Also used : IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) IdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser) IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) Location(org.eclipse.titan.designer.AST.Location)

Example 12 with ReParseException

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

the class ImportModule method updateSyntax.

/**
 * Handles the incremental parsing of this module importation.
 *
 * @param reparser
 *                the parser doing the incremental parsing.
 * @param isDamaged
 *                true if the location contains the damaged area, false
 *                if only its' location needs to be updated.
 */
@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        boolean enveloped = false;
        final Location temporalIdentifier = identifier.getLocation();
        if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
            reparser.extendDamagedRegion(temporalIdentifier);
            final IIdentifierReparser r = new IdentifierReparser(reparser);
            final int result = r.parse();
            identifier = r.getIdentifier();
            // damage handled
            if (result == 0) {
                enveloped = true;
            } else {
                throw new ReParseException(result);
            }
        }
        if (withAttributesPath != null) {
            if (enveloped) {
                withAttributesPath.updateSyntax(reparser, false);
                reparser.updateLocation(withAttributesPath.getLocation());
            } else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
                reparser.extendDamagedRegion(withAttributesPath.getLocation());
                final int result = reparse(reparser);
                if (result != 0) {
                    throw new ReParseException();
                }
                enveloped = true;
            }
        }
        if (!enveloped) {
            throw new ReParseException(1);
        }
        return;
    }
    reparser.updateLocation(identifier.getLocation());
    if (withAttributesPath != null) {
        withAttributesPath.updateSyntax(reparser, false);
        reparser.updateLocation(withAttributesPath.getLocation());
    }
}
Also used : IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) IdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser) IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) Location(org.eclipse.titan.designer.AST.Location)

Example 13 with ReParseException

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

the class TTCN3Module method updateSyntax.

/**
 * Handles the incremental parsing of this definition.
 *
 * @param reparser
 *                the parser doing the incremental parsing.
 * @param sourceParser
 *                the general utility handling the parse of TTCN-3 and
 *                ASN.1 files, to efficiently handle module renaming.
 */
public void updateSyntax(final TTCN3ReparseUpdater reparser, final ProjectSourceParser sourceParser) throws ReParseException {
    if (reparser.getShift() < 0) {
        throw new ReParseException();
    }
    // edited outside the module
    if (reparser.getDamageEnd() < location.getOffset()) {
        // before the module
        reparser.updateLocation(identifier.getLocation());
        if (definitions != null) {
            definitions.updateSyntax(reparser, importedModules, friendModules, controlpart);
        }
        if (controlpart != null) {
            controlpart.updateSyntax(reparser);
            reparser.updateLocation(controlpart.getLocation());
        }
        if (withAttributesPath != null) {
            withAttributesPath.updateSyntax(reparser, false);
            reparser.updateLocation(withAttributesPath.getLocation());
        }
        return;
    } else if (reparser.getDamageStart() > location.getEndOffset()) {
        // after the module
        if (withAttributesPath == null || withAttributesPath.getAttributes() == null) {
            // new attribute might have appeared
            reparser.extendDamagedRegionTillFileEnd();
            final int result = reparseAfterModule(reparser);
            if (result != 0) {
                throw new ReParseException();
            }
        }
        return;
    }
    // edited the module identifier
    final Location temporalIdentifier = identifier.getLocation();
    if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
        reparser.extendDamagedRegion(temporalIdentifier);
        final IIdentifierReparser r = new IdentifierReparser(reparser);
        final int result = r.parse();
        identifier = r.getIdentifier();
        // damage handled
        if (result != 0) {
            throw new ReParseException(result);
        }
        if (definitions != null) {
            definitions.updateSyntax(reparser, importedModules, friendModules, controlpart);
        }
        if (controlpart != null) {
            controlpart.updateSyntax(reparser);
            reparser.updateLocation(controlpart.getLocation());
        }
        if (withAttributesPath != null) {
            withAttributesPath.updateSyntax(reparser, false);
            reparser.updateLocation(withAttributesPath.getLocation());
        }
        return;
    } else if (reparser.isDamaged(temporalIdentifier)) {
        throw new ReParseException();
    }
    // the module has structurally changed
    boolean enveloped = false;
    if ((definitions != null && reparser.envelopsDamage(definitions.getLocation())) || (controlpart != null && reparser.envelopsDamage(controlpart.getLocation()))) {
        if (definitions != null && reparser.isAffected(definitions.getLocation())) {
            try {
                definitions.updateSyntax(reparser, importedModules, friendModules, controlpart);
            } catch (ReParseException e) {
                throw e;
            }
            reparser.updateLocation(definitions.getLocation());
        }
        if (controlpart != null && reparser.isAffected(controlpart.getLocation())) {
            try {
                controlpart.updateSyntax(reparser);
            } catch (ReParseException e) {
                throw e;
            }
            reparser.updateLocation(controlpart.getLocation());
        }
        enveloped = true;
    }
    if (withAttributesPath != null && reparser.isAffected(withAttributesPath.getLocation())) {
        // The modification happened inside the attribute list
        if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
            reparser.extendDamagedRegion(withAttributesPath.getLocation());
            final int result = reparseInsideAttributelist(reparser);
            if (result != 0) {
                throw new ReParseException();
            }
            return;
        } else if (enveloped) {
            // The modification happened inside the module
            withAttributesPath.updateSyntax(reparser, reparser.envelopsDamage(withAttributesPath.getLocation()));
            reparser.updateLocation(withAttributesPath.getLocation());
        } else {
            // out
            throw new ReParseException();
        }
    }
    if (!enveloped) {
        throw new ReParseException();
    }
}
Also used : IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) IdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser) IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) Location(org.eclipse.titan.designer.AST.Location)

Example 14 with ReParseException

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

the class Value_ActualParameter method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        throw new ReParseException();
    }
    if (value instanceof IIncrementallyUpdateable) {
        ((IIncrementallyUpdateable) value).updateSyntax(reparser, false);
        reparser.updateLocation(value.getLocation());
    } else if (value != null) {
        throw new ReParseException();
    }
}
Also used : IIncrementallyUpdateable(org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)

Example 15 with ReParseException

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

the class Def_Altstep method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        lastTimeChecked = null;
        boolean enveloped = false;
        final Location temporalIdentifier = identifier.getLocation();
        if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
            reparser.extendDamagedRegion(temporalIdentifier);
            final IIdentifierReparser r = new IdentifierReparser(reparser);
            final int result = r.parseAndSetNameChanged();
            identifier = r.getIdentifier();
            // damage handled
            if (result == 0 && identifier != null) {
                enveloped = true;
            } else {
                removeBridge();
                throw new ReParseException(result);
            }
        }
        if (formalParList != null) {
            if (enveloped) {
                formalParList.updateSyntax(reparser, false);
                reparser.updateLocation(formalParList.getLocation());
            } else if (reparser.envelopsDamage(formalParList.getLocation())) {
                try {
                    formalParList.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(formalParList.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (runsOnRef != null) {
            if (enveloped) {
                runsOnRef.updateSyntax(reparser, false);
                reparser.updateLocation(runsOnRef.getLocation());
            } else if (reparser.envelopsDamage(runsOnRef.getLocation())) {
                try {
                    runsOnRef.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(runsOnRef.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (altGuards != null) {
            if (enveloped) {
                altGuards.updateSyntax(reparser, false);
                reparser.updateLocation(altGuards.getLocation());
            } else if (reparser.envelopsDamage(altGuards.getLocation())) {
                try {
                    altGuards.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(altGuards.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (block != null) {
            if (enveloped) {
                block.updateSyntax(reparser, false);
                reparser.updateLocation(block.getLocation());
            } else if (reparser.envelopsDamage(block.getLocation())) {
                try {
                    block.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(block.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (withAttributesPath != null) {
            if (enveloped) {
                withAttributesPath.updateSyntax(reparser, false);
                reparser.updateLocation(withAttributesPath.getLocation());
            } else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
                try {
                    withAttributesPath.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(withAttributesPath.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (!enveloped) {
            removeBridge();
            throw new ReParseException();
        }
        return;
    }
    reparser.updateLocation(identifier.getLocation());
    if (formalParList != null) {
        formalParList.updateSyntax(reparser, false);
        reparser.updateLocation(formalParList.getLocation());
    }
    if (runsOnRef != null) {
        runsOnRef.updateSyntax(reparser, false);
        reparser.updateLocation(runsOnRef.getLocation());
    }
    if (block != null) {
        block.updateSyntax(reparser, false);
        reparser.updateLocation(block.getLocation());
    }
    if (altGuards != null) {
        altGuards.updateSyntax(reparser, false);
        reparser.updateLocation(altGuards.getLocation());
    }
    if (withAttributesPath != null) {
        withAttributesPath.updateSyntax(reparser, false);
        reparser.updateLocation(withAttributesPath.getLocation());
    }
}
Also used : IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) IdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser) IIdentifierReparser(org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) Location(org.eclipse.titan.designer.AST.Location)

Aggregations

ReParseException (org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)52 Location (org.eclipse.titan.designer.AST.Location)24 IIncrementallyUpdateable (org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable)21 IIdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser)18 IdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser)18 NULL_Location (org.eclipse.titan.designer.AST.NULL_Location)6 IAppendableSyntax (org.eclipse.titan.designer.AST.TTCN3.IAppendableSyntax)5 IType (org.eclipse.titan.designer.AST.IType)2 FileNotFoundException (java.io.FileNotFoundException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IValue (org.eclipse.titan.designer.AST.IValue)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Module (org.eclipse.titan.designer.AST.Module)1 Reference (org.eclipse.titan.designer.AST.Reference)1 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)1 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)1 ObjectIdentifierComponent (org.eclipse.titan.designer.AST.TTCN3.values.ObjectIdentifierComponent)1 Type (org.eclipse.titan.designer.AST.Type)1 ITtcn3FileReparser (org.eclipse.titan.designer.parsers.ttcn3parser.ITtcn3FileReparser)1 Ttcn3FileReparser (org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3FileReparser)1