Search in sources :

Example 41 with ReParseException

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

the class For_Loop_Definitions method updateSyntax.

/**
 * Handles the incremental parsing of this list of definitions.
 *
 * @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) {
        // handle the simple case quickly
        for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
            final Definition temp = iterator.next();
            final Location temporalLocation = temp.getLocation();
            final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
            if (reparser.isAffected(temporalLocation)) {
                if (!temporalLocation.equals(cumulativeLocation)) {
                    reparser.updateLocation(cumulativeLocation);
                }
                reparser.updateLocation(temporalLocation);
            }
        }
        return;
    }
    // calculate damaged region
    int result = 0;
    lastCompilationTimeStamp = null;
    boolean enveloped = false;
    int nofDamaged = 0;
    int leftBoundary = location.getOffset();
    int rightBoundary = location.getEndOffset();
    final int damageOffset = reparser.getDamageStart();
    IAppendableSyntax lastAppendableBeforeChange = null;
    IAppendableSyntax lastPrependableBeforeChange = null;
    for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext() && !enveloped; ) {
        final Definition temp = iterator.next();
        final Location tempLocation = temp.getLocation();
        final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
        if (tempLocation.equals(cumulativeLocation) && reparser.envelopsDamage(cumulativeLocation)) {
            enveloped = true;
            leftBoundary = cumulativeLocation.getOffset();
            rightBoundary = cumulativeLocation.getEndOffset();
        } else if (reparser.isDamaged(cumulativeLocation)) {
            nofDamaged++;
            if (reparser.getDamageStart() == cumulativeLocation.getEndOffset()) {
                lastAppendableBeforeChange = temp;
            } else if (reparser.getDamageEnd() == cumulativeLocation.getOffset()) {
                lastPrependableBeforeChange = temp;
            }
        } else {
            if (cumulativeLocation.getEndOffset() < damageOffset && cumulativeLocation.getEndOffset() > leftBoundary) {
                leftBoundary = cumulativeLocation.getEndOffset();
                lastAppendableBeforeChange = temp;
            }
            if (cumulativeLocation.getOffset() >= damageOffset && cumulativeLocation.getOffset() < rightBoundary) {
                rightBoundary = cumulativeLocation.getOffset();
                lastPrependableBeforeChange = temp;
            }
        }
    }
    // was not enveloped
    if (!enveloped && isDamaged) {
        reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        // the extension might be correct
        if (lastAppendableBeforeChange != null) {
            final boolean isBeingExtended = reparser.startsWithFollow(lastAppendableBeforeChange.getPossibleExtensionStarterTokens());
            if (isBeingExtended) {
                leftBoundary = lastAppendableBeforeChange.getLocation().getOffset();
                nofDamaged++;
                enveloped = false;
                reparser.extendDamagedRegion(leftBoundary, rightBoundary);
            }
        }
        if (lastPrependableBeforeChange != null) {
            final List<Integer> temp = lastPrependableBeforeChange.getPossiblePrefixTokens();
            if (temp != null && reparser.endsWithToken(temp)) {
                rightBoundary = lastPrependableBeforeChange.getLocation().getEndOffset();
                nofDamaged++;
                enveloped = false;
                reparser.extendDamagedRegion(leftBoundary, rightBoundary);
            }
        }
        if (nofDamaged != 0) {
            // remove damaged stuff
            removeStuffInRange(reparser);
            lastUniquenessCheckTimeStamp = null;
        }
    }
    // update what is left
    for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
        final Definition temp = iterator.next();
        final Location temporalLocation = temp.getLocation();
        final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
        if (reparser.isAffected(cumulativeLocation)) {
            try {
                temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(temporalLocation));
                if (reparser.getNameChanged()) {
                    lastUniquenessCheckTimeStamp = null;
                    reparser.setNameChanged(false);
                }
            } catch (ReParseException e) {
                if (e.getDepth() == 1) {
                    enveloped = false;
                    definitions.remove(temp);
                    reparser.extendDamagedRegion(cumulativeLocation);
                    result = 1;
                } else {
                    e.decreaseDepth();
                    throw e;
                }
            }
        }
    }
    if (result == 1) {
        removeStuffInRange(reparser);
        lastUniquenessCheckTimeStamp = null;
    }
    for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
        final Definition temp = iterator.next();
        final Location temporalLocation = temp.getLocation();
        final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
        if (reparser.isAffected(temporalLocation)) {
            if (!temporalLocation.equals(cumulativeLocation)) {
                reparser.updateLocation(cumulativeLocation);
            }
            reparser.updateLocation(temporalLocation);
        }
    }
    if (!enveloped && reparser.envelopsDamage(location)) {
        // whole definition region has to be re-parsed
        throw new ReParseException();
    }
    if (result != 0) {
        lastUniquenessCheckTimeStamp = null;
        throw new ReParseException(result);
    }
}
Also used : IAppendableSyntax(org.eclipse.titan.designer.AST.TTCN3.IAppendableSyntax) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) Location(org.eclipse.titan.designer.AST.Location)

Example 42 with ReParseException

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

the class Group method updateSyntax.

/**
 * Handles the incremental parsing of this list of definitions.
 *
 * @param reparser
 *                the parser doing the incremental parsing.
 * @param allImportedModules
 *                the list of module importations found in the same
 *                module.
 * @param allDefinitions
 *                the list of definitions found in the same module.
 * @param allFriends
 *                the list of friend module declarations found in the
 *                same module.
 * @return in case of processing error the minimum amount of semantic
 *         levels that must be destroyed to handle the syntactic
 *         changes, otherwise 0.
 */
public void updateSyntax(final TTCN3ReparseUpdater reparser, final List<ImportModule> allImportedModules, final List<Definition> allDefinitions, final List<FriendModule> allFriends) throws ReParseException {
    int result = 0;
    Location tempLocation = identifier.getLocation();
    if (reparser.isDamaged(tempLocation)) {
        if (reparser.envelopsDamage(tempLocation) || reparser.isExtending(tempLocation)) {
            reparser.extendDamagedRegion(tempLocation);
            result = reparseIdentifier(reparser);
            if (result != 0) {
                throw new ReParseException(result);
            }
        } else {
            throw new ReParseException();
        }
    } else {
        reparser.updateLocation(tempLocation);
    }
    if (reparser.isDamaged(innerLocation) && !reparser.envelopsDamage(innerLocation)) {
        throw new ReParseException();
    }
    boolean enveloped = false;
    int nofDamaged = 0;
    int leftBoundary = innerLocation.getOffset();
    int rightBoundary = innerLocation.getEndOffset();
    final int damageOffset = reparser.getDamageStart();
    IAppendableSyntax lastAppendableBeforeChange = null;
    IAppendableSyntax lastPrependableBeforeChange = null;
    for (int i = 0, size = groups.size(); i < size && !enveloped; i++) {
        final Group temp = groups.get(i);
        tempLocation = temp.getLocation();
        if (reparser.envelopsDamage(tempLocation)) {
            enveloped = true;
            leftBoundary = tempLocation.getOffset();
            rightBoundary = tempLocation.getEndOffset();
        } else if (reparser.isDamaged(tempLocation)) {
            nofDamaged++;
        } else {
            if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
                leftBoundary = tempLocation.getEndOffset();
                lastAppendableBeforeChange = temp;
            }
            if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
                rightBoundary = tempLocation.getOffset();
                lastPrependableBeforeChange = temp;
            }
        }
    }
    for (int i = 0, size = importedModules.size(); i < size && !enveloped; i++) {
        final ImportModule temp = importedModules.get(i);
        tempLocation = temp.getLocation();
        if (reparser.envelopsDamage(tempLocation)) {
            enveloped = true;
            leftBoundary = tempLocation.getOffset();
            rightBoundary = tempLocation.getEndOffset();
        } else if (reparser.isDamaged(tempLocation)) {
            nofDamaged++;
        } else {
            if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
                leftBoundary = tempLocation.getEndOffset();
                lastAppendableBeforeChange = temp;
            }
            if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
                rightBoundary = tempLocation.getOffset();
                lastPrependableBeforeChange = temp;
            }
        }
    }
    for (int i = 0, size = friendModules.size(); i < size && !enveloped; i++) {
        final FriendModule temp = friendModules.get(i);
        tempLocation = temp.getLocation();
        if (reparser.envelopsDamage(tempLocation)) {
            enveloped = true;
            leftBoundary = tempLocation.getOffset();
            rightBoundary = tempLocation.getEndOffset();
        } else if (reparser.isDamaged(tempLocation)) {
            nofDamaged++;
        } else {
            if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
                leftBoundary = tempLocation.getEndOffset();
                lastAppendableBeforeChange = temp;
            }
            if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
                rightBoundary = tempLocation.getOffset();
                lastPrependableBeforeChange = temp;
            }
        }
    }
    for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext() && !enveloped; ) {
        final Definition temp = iterator.next();
        tempLocation = temp.getLocation();
        if (reparser.envelopsDamage(tempLocation)) {
            enveloped = true;
            leftBoundary = tempLocation.getOffset();
            rightBoundary = tempLocation.getEndOffset();
        } else if (reparser.isDamaged(tempLocation)) {
            nofDamaged++;
            if (reparser.getDamageStart() == tempLocation.getEndOffset()) {
                lastAppendableBeforeChange = temp;
            } else if (reparser.getDamageEnd() == tempLocation.getOffset()) {
                lastPrependableBeforeChange = temp;
            }
        // reparser.extendDamagedRegion(temp_location);
        } else {
            if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
                leftBoundary = tempLocation.getEndOffset();
                lastAppendableBeforeChange = temp;
            }
            if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
                rightBoundary = tempLocation.getOffset();
                lastPrependableBeforeChange = temp;
            }
        }
        final Location tempCommentLocation = temp.getCommentLocation();
        if (tempCommentLocation != null && reparser.isDamaged(tempCommentLocation)) {
            rightBoundary = tempCommentLocation.getOffset();
            lastPrependableBeforeChange = temp;
        }
    }
    // was not enveloped
    if (!enveloped && reparser.envelopsDamage(location)) {
        reparser.extendDamagedRegion(leftBoundary, rightBoundary);
    }
    // correct
    if (lastAppendableBeforeChange != null) {
        final boolean isBeingExtended = reparser.startsWithFollow(lastAppendableBeforeChange.getPossibleExtensionStarterTokens());
        if (isBeingExtended) {
            leftBoundary = lastAppendableBeforeChange.getLocation().getOffset();
            nofDamaged++;
            enveloped = false;
            reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        }
    }
    if (lastPrependableBeforeChange != null) {
        final List<Integer> temp = lastPrependableBeforeChange.getPossiblePrefixTokens();
        if (temp != null && reparser.endsWithToken(temp)) {
            rightBoundary = lastPrependableBeforeChange.getLocation().getEndOffset();
            nofDamaged++;
            enveloped = false;
            reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        }
    }
    if (nofDamaged != 0) {
        // remove damaged stuff
        removeStuffInRange(reparser, allImportedModules, allDefinitions, friendModules);
    }
    // update what is left
    for (int i = 0; i < groups.size(); i++) {
        final Group temp = groups.get(i);
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            try {
                temp.updateSyntax(reparser, allImportedModules, allDefinitions, friendModules);
            } catch (ReParseException e) {
                if (e.getDepth() == 1) {
                    enveloped = false;
                    groups.remove(i);
                    i--;
                    reparser.extendDamagedRegion(tempLocation);
                    result = 1;
                } else {
                    e.decreaseDepth();
                    throw e;
                }
            }
        }
    }
    for (int i = 0; i < importedModules.size(); i++) {
        final ImportModule temp = importedModules.get(i);
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            try {
                temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
            } catch (ReParseException e) {
                if (e.getDepth() == 1) {
                    enveloped = false;
                    importedModules.remove(i);
                    i--;
                    reparser.extendDamagedRegion(tempLocation);
                    result = 1;
                } else {
                    e.decreaseDepth();
                    throw e;
                }
            }
        }
    }
    for (int i = 0; i < friendModules.size(); i++) {
        final FriendModule temp = friendModules.get(i);
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            try {
                temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
            } catch (ReParseException e) {
                if (e.getDepth() == 1) {
                    enveloped = false;
                    friendModules.remove(i);
                    i--;
                    reparser.extendDamagedRegion(tempLocation);
                    result = 1;
                } else {
                    e.decreaseDepth();
                    throw e;
                }
            }
        }
    }
    for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
        final Definition temp = iterator.next();
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            try {
                final boolean isDamaged = enveloped && reparser.envelopsDamage(tempLocation);
                temp.updateSyntax(reparser, isDamaged);
                if (reparser.getNameChanged()) {
                    lastUniquenessCheckTimeStamp = null;
                    reparser.setNameChanged(false);
                }
                if (isDamaged) {
                    temp.checkRoot();
                }
            } catch (ReParseException e) {
                if (e.getDepth() == 1) {
                    enveloped = false;
                    definitions.remove(temp);
                    reparser.extendDamagedRegion(tempLocation);
                    result = 1;
                } else {
                    e.decreaseDepth();
                    throw e;
                }
            }
        }
    }
    if (result == 1) {
        removeStuffInRange(reparser, allImportedModules, allDefinitions, friendModules);
    }
    for (int i = 0, size = groups.size(); i < size; i++) {
        final Group temp = groups.get(i);
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            reparser.updateLocation(tempLocation);
        }
    }
    for (int i = 0, size = importedModules.size(); i < size; i++) {
        final ImportModule temp = importedModules.get(i);
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            reparser.updateLocation(tempLocation);
        }
    }
    for (int i = 0, size = friendModules.size(); i < size; i++) {
        final FriendModule temp = friendModules.get(i);
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            reparser.updateLocation(tempLocation);
        }
    }
    for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
        final Definition temp = iterator.next();
        tempLocation = temp.getLocation();
        if (reparser.isAffected(tempLocation)) {
            reparser.updateLocation(tempLocation);
        }
    }
    if (withAttributesPath != null && reparser.isAffected(withAttributesPath.getLocation())) {
        if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
            reparser.extendDamagedRegion(withAttributesPath.getLocation());
            result = reparseOptionalWithStatement(reparser);
            if (result != 0) {
                throw new ReParseException(result);
            }
            return;
        }
        withAttributesPath.updateSyntax(reparser, reparser.envelopsDamage(withAttributesPath.getLocation()));
        reparser.updateLocation(withAttributesPath.getLocation());
    }
    if (!enveloped && reparser.envelopsDamage(innerLocation)) {
        reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        result = reparseModuleDefinitionsList(reparser);
    }
    reparser.updateLocation(innerLocation);
    if (result > 1) {
        throw new ReParseException(result - 1);
    }
    return;
}
Also used : IAppendableSyntax(org.eclipse.titan.designer.AST.TTCN3.IAppendableSyntax) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) Location(org.eclipse.titan.designer.AST.Location)

Example 43 with ReParseException

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

the class Def_Template 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 (type != null) {
            if (enveloped) {
                type.updateSyntax(reparser, false);
                reparser.updateLocation(type.getLocation());
            } else if (reparser.envelopsDamage(type.getLocation())) {
                try {
                    type.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(type.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        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 (derivedReference != null) {
            if (enveloped) {
                derivedReference.updateSyntax(reparser, false);
                reparser.updateLocation(derivedReference.getLocation());
            } else if (reparser.envelopsDamage(derivedReference.getLocation())) {
                try {
                    derivedReference.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(derivedReference.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (body != null) {
            if (enveloped) {
                body.updateSyntax(reparser, false);
                reparser.updateLocation(body.getLocation());
            } else if (reparser.envelopsDamage(body.getLocation())) {
                try {
                    body.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(body.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 (type != null) {
        type.updateSyntax(reparser, false);
        reparser.updateLocation(type.getLocation());
    }
    if (formalParList != null) {
        formalParList.updateSyntax(reparser, false);
        reparser.updateLocation(formalParList.getLocation());
    }
    if (derivedReference != null) {
        derivedReference.updateSyntax(reparser, false);
        reparser.updateLocation(derivedReference.getLocation());
    }
    if (body != null) {
        body.updateSyntax(reparser, false);
        reparser.updateLocation(body.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 44 with ReParseException

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

the class Def_Testcase method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        lastTimeChecked = null;
        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.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 (runsOnReference != null) {
            if (enveloped) {
                runsOnReference.updateSyntax(reparser, false);
                reparser.updateLocation(runsOnReference.getLocation());
            } else if (reparser.envelopsDamage(runsOnReference.getLocation())) {
                try {
                    runsOnReference.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(runsOnReference.getLocation());
                } catch (ReParseException e) {
                    removeBridge();
                    throw e;
                }
            }
        }
        if (systemReference != null) {
            if (enveloped) {
                systemReference.updateSyntax(reparser, false);
                reparser.updateLocation(systemReference.getLocation());
            } else if (reparser.envelopsDamage(systemReference.getLocation())) {
                try {
                    systemReference.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(systemReference.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 (runsOnReference != null) {
        runsOnReference.updateSyntax(reparser, false);
        reparser.updateLocation(runsOnReference.getLocation());
    }
    if (systemReference != null) {
        systemReference.updateSyntax(reparser, false);
        reparser.updateLocation(systemReference.getLocation());
    }
    if (block != null) {
        block.updateSyntax(reparser, false);
        reparser.updateLocation(block.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 45 with ReParseException

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

the class Def_Timer method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        lastTimeChecked = null;
        int result = 1;
        final Location tempIdentifier = identifier.getLocation();
        if (reparser.envelopsDamage(tempIdentifier) || reparser.isExtending(tempIdentifier)) {
            reparser.extendDamagedRegion(tempIdentifier);
            final IIdentifierReparser r = new IdentifierReparser(reparser);
            result = r.parseAndSetNameChanged();
            identifier = r.getIdentifier();
            if (result != 0) {
                throw new ReParseException(result);
            }
            if (dimensions != null) {
                dimensions.updateSyntax(reparser, false);
            }
            if (defaultDuration != null) {
                defaultDuration.updateSyntax(reparser, false);
                reparser.updateLocation(defaultDuration.getLocation());
            }
            if (withAttributesPath != null) {
                withAttributesPath.updateSyntax(reparser, false);
                reparser.updateLocation(withAttributesPath.getLocation());
            }
            return;
        }
        throw new ReParseException();
    }
    reparser.updateLocation(identifier.getLocation());
    if (dimensions != null) {
        dimensions.updateSyntax(reparser, false);
    }
    if (defaultDuration != null) {
        defaultDuration.updateSyntax(reparser, false);
        reparser.updateLocation(defaultDuration.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