Search in sources :

Example 1 with Location

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

the class TITANJob method createProblemMarker.

/**
 * Creates a problem marker on a given resource.
 *
 * @param resource
 *                The resource to put the marker on.
 * @param message
 *                The message of the error.
 */
private static void createProblemMarker(final IResource resource, final String message) {
    final Location location = new Location(resource);
    location.reportExternalProblem(message, IMarker.SEVERITY_ERROR, GeneralConstants.COMPILER_ERRORMARKER);
}
Also used : Location(org.eclipse.titan.designer.AST.Location)

Example 2 with Location

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

the class T3Doc method check.

public static void check(final Location commentLocation, final String type, final Type_type typeType) {
    if (!documentationEnabled) {
        return;
    }
    if (commentLocation != null) {
        final IFile file = (IFile) commentLocation.getFile();
        try {
            String[] temp;
            // "testcase"
            if (Def_Testcase.getKind().equals(type)) {
                temp = TEST_CASE;
            } else if (// "port definition"
            Def_Port.getKind().equals(type) || // " module parameter"
            Def_ModulePar.getKind().equals(type) || // "constant "
            Def_Const.getKind().equals(type)) {
                // special treatment for enum, set, seq
                // and choice
                boolean memberCapable = false;
                if (typeType != null) {
                    for (String string : TTCN3_MEMBER_CAPABLE) {
                        if (typeType.toString().equals(string)) {
                            memberCapable = true;
                        }
                    }
                } else {
                    memberCapable = true;
                }
                if (memberCapable) {
                    temp = CONSTANT_MEMBER_CAPABLE;
                } else {
                    temp = CONSTANT;
                }
            } else if (Def_Template.getKind().equals(type)) {
                temp = TEMPLATE;
            } else if (Def_Altstep.getKind().equals(type)) {
                temp = ALTSTEP;
            } else if (Def_Function.getKind().equals(type)) {
                temp = FUNCTION;
            } else if ("TYPE_SIGNATURE".equals(type)) {
                temp = TYPE_SIGNATURE;
            } else if (TTCN3Module.MODULE.equals(type)) {
                temp = MODULE;
            } else if ("group".equals(type) || ControlPart.getKind().equals(type)) {
                temp = GROUP;
            } else if ("TYPE_TTCN3_SEQUENCE".equals(type) || "TYPE_TTCN3_CHOICE".equals(type) || "TYPE_TTCN3_SET".equals(type)) {
                temp = TTCN3_SEQUENCE;
            } else if ("TYPE_SEQUENCE_OF".equals(type)) {
                temp = TTCN3_SEQUENCE_OF;
            } else if ("TYPE_TTCN3_ENUMERATED".equals(type)) {
                temp = TTCN3_SEQUENCE;
            } else if ("TYPE_PORT".equals(type) || "TYPE_COMPONENT".equals(type)) {
                temp = PORT;
            } else {
                temp = null;
            }
            File realFile = file.getLocation().toFile();
            BufferedReader in = new BufferedReader(new FileReader(realFile));
            in.skip(commentLocation.getOffset());
            String str;
            int lineCnt = 0;
            int offset = commentLocation.getOffset();
            while ((str = in.readLine()) != null) {
                if (str.indexOf("//") == -1) {
                    break;
                }
                int loc = -1;
                if (temp != null) {
                    for (String item : temp) {
                        loc = str.indexOf(item);
                        if (loc != -1) {
                            location = new Location(commentLocation.getFile(), commentLocation.getLine() + lineCnt, offset + lineCnt, offset + str.length() + lineCnt);
                            location.reportSemanticWarning(MessageFormat.format("Comment `{0}'' cannot be used with this type!", item));
                        }
                    }
                }
                offset += str.length();
                lineCnt++;
            }
            in.close();
        } catch (Exception e) {
            ErrorReporter.logExceptionStackTrace("Comment is not reachable", e);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IFile(org.eclipse.core.resources.IFile) File(java.io.File) BadLocationException(org.eclipse.jface.text.BadLocationException) Location(org.eclipse.titan.designer.AST.Location)

Example 3 with Location

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

the class Def_Extfunction 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 {
                throw new ReParseException(result);
            }
        }
        if (formalParList != null) {
            if (enveloped) {
                formalParList.updateSyntax(reparser, false);
                reparser.updateLocation(formalParList.getLocation());
            } else if (reparser.envelopsDamage(formalParList.getLocation())) {
                formalParList.updateSyntax(reparser, true);
                enveloped = true;
                reparser.updateLocation(formalParList.getLocation());
            }
        }
        if (returnType != null) {
            if (enveloped) {
                returnType.updateSyntax(reparser, false);
                reparser.updateLocation(returnType.getLocation());
            } else if (reparser.envelopsDamage(returnType.getLocation())) {
                returnType.updateSyntax(reparser, true);
                enveloped = true;
                reparser.updateLocation(returnType.getLocation());
            }
        }
        if (withAttributesPath != null) {
            if (enveloped) {
                withAttributesPath.updateSyntax(reparser, false);
                reparser.updateLocation(withAttributesPath.getLocation());
            } else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
                withAttributesPath.updateSyntax(reparser, true);
                enveloped = true;
                reparser.updateLocation(withAttributesPath.getLocation());
            }
        }
        if (!enveloped) {
            throw new ReParseException();
        }
        return;
    }
    reparser.updateLocation(identifier.getLocation());
    if (formalParList != null) {
        formalParList.updateSyntax(reparser, false);
        reparser.updateLocation(formalParList.getLocation());
    }
    if (returnType != null) {
        returnType.updateSyntax(reparser, false);
        reparser.updateLocation(returnType.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 4 with Location

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

the class Def_Function 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 (returnType != null) {
            if (enveloped) {
                returnType.updateSyntax(reparser, false);
                reparser.updateLocation(returnType.getLocation());
            } else if (reparser.envelopsDamage(returnType.getLocation())) {
                try {
                    returnType.updateSyntax(reparser, true);
                    enveloped = true;
                    reparser.updateLocation(returnType.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 (returnType != null) {
        returnType.updateSyntax(reparser, false);
        reparser.updateLocation(returnType.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 5 with Location

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

the class Def_ModulePar 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 {
                throw new ReParseException(result);
            }
        }
        if (type != null) {
            if (enveloped) {
                type.updateSyntax(reparser, false);
                reparser.updateLocation(type.getLocation());
            } else if (reparser.envelopsDamage(type.getLocation())) {
                type.updateSyntax(reparser, true);
                enveloped = true;
                reparser.updateLocation(type.getLocation());
            }
        }
        if (defaultValue != null) {
            if (enveloped) {
                defaultValue.updateSyntax(reparser, false);
                reparser.updateLocation(defaultValue.getLocation());
            } else if (reparser.envelopsDamage(defaultValue.getLocation())) {
                defaultValue.updateSyntax(reparser, true);
                enveloped = true;
                reparser.updateLocation(defaultValue.getLocation());
            }
        }
        if (withAttributesPath != null) {
            if (enveloped) {
                withAttributesPath.updateSyntax(reparser, false);
                reparser.updateLocation(withAttributesPath.getLocation());
            } else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
                withAttributesPath.updateSyntax(reparser, true);
                enveloped = true;
                reparser.updateLocation(withAttributesPath.getLocation());
            }
        }
        if (!enveloped) {
            throw new ReParseException();
        }
        return;
    }
    reparser.updateLocation(identifier.getLocation());
    if (type != null) {
        type.updateSyntax(reparser, false);
        reparser.updateLocation(type.getLocation());
    }
    if (defaultValue != null) {
        defaultValue.updateSyntax(reparser, false);
        reparser.updateLocation(defaultValue.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

Location (org.eclipse.titan.designer.AST.Location)109 Identifier (org.eclipse.titan.designer.AST.Identifier)24 ReParseException (org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)24 NULL_Location (org.eclipse.titan.designer.AST.NULL_Location)21 IIdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser)18 IdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser)18 Module (org.eclipse.titan.designer.AST.Module)16 ArrayList (java.util.ArrayList)15 IFile (org.eclipse.core.resources.IFile)13 HashMap (java.util.HashMap)11 Reference (org.eclipse.titan.designer.AST.Reference)10 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)10 Assignment (org.eclipse.titan.designer.AST.Assignment)9 IDocument (org.eclipse.jface.text.IDocument)8 InsertEdit (org.eclipse.text.edits.InsertEdit)8 ILocateableNode (org.eclipse.titan.designer.AST.ILocateableNode)8 CoreException (org.eclipse.core.runtime.CoreException)7 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)7 TITANMarker (org.eclipse.titan.common.parsers.TITANMarker)7 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)7