Search in sources :

Example 1 with CfgLocation

use of org.eclipse.titan.common.parsers.cfg.CfgLocation in project titan.EclipsePlug-ins by eclipse.

the class ProjectConfigurationParser method removeMarkersAndDefinitions.

/**
 * Remove markers and definitions of file
 * @param aFile file
 */
private void removeMarkersAndDefinitions(final IFile aFile) {
    MarkerHandler.markAllOnTheFlyMarkersForRemoval(aFile);
    MarkerHandler.markAllTaskMarkersForRemoval(aFile);
    final Set<Map.Entry<String, CfgDefinitionInformation>> entries = definitions.entrySet();
    for (final Iterator<Map.Entry<String, CfgDefinitionInformation>> mapIter = entries.iterator(); mapIter.hasNext(); ) {
        final Map.Entry<String, CfgDefinitionInformation> entry = mapIter.next();
        final CfgDefinitionInformation info = entry.getValue();
        final List<CfgLocation> list = info.getLocations();
        for (final Iterator<CfgLocation> listIter = list.iterator(); listIter.hasNext(); ) {
            final CfgLocation location = listIter.next();
            if (location.getFile().equals(aFile)) {
                listIter.remove();
            }
        }
        if (list.isEmpty()) {
            mapIter.remove();
        }
    }
}
Also used : CfgDefinitionInformation(org.eclipse.titan.common.parsers.cfg.CfgDefinitionInformation) CfgLocation(org.eclipse.titan.common.parsers.cfg.CfgLocation) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with CfgLocation

use of org.eclipse.titan.common.parsers.cfg.CfgLocation in project titan.EclipsePlug-ins by eclipse.

the class OpenDeclaration method handleDefinitions.

/**
 * Jumps to the definition of the constant selected by the user.
 *
 * @param file
 *                The current file.
 * @param offset
 *                The position of the cursor.
 * @param document
 *                The document opened in the configuration file editor.
 */
public void handleDefinitions(final IFile file, final int offset, final IDocument document) {
    ConfigReferenceParser refParser = new ConfigReferenceParser(false);
    refParser.findReferenceForOpening(file, offset, document);
    String definitionName = refParser.getDefinitionName();
    if (definitionName == null) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOTDEFINITION);
        return;
    }
    List<ConfigDeclarationCollectionHelper> collected = new ArrayList<ConfigDeclarationCollectionHelper>();
    Map<String, CfgDefinitionInformation> definitions = GlobalParser.getConfigSourceParser(file.getProject()).getAllDefinitions();
    CfgDefinitionInformation definition = definitions.get(definitionName);
    if (definition != null) {
        List<CfgLocation> locations = definition.getLocations();
        for (CfgLocation location : locations) {
            collected.add(new ConfigDeclarationCollectionHelper(definitionName, location));
        }
    } else {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOTCONSTANTDEFINITION);
        return;
    }
    if (collected.isEmpty()) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOTCONSTANTDEFINITION);
        return;
    }
    ConfigDeclarationCollectionHelper declaration = null;
    if (collected.size() == 1) {
        declaration = collected.get(0);
    } else {
        Object result = openCollectionListDialog(collected);
        if (result != null) {
            declaration = (ConfigDeclarationCollectionHelper) result;
        }
    }
    if (declaration != null) {
        selectAndRevealRegion(declaration.location.getFile(), declaration.location.getOffset(), declaration.location.getEndOffset(), true);
    }
}
Also used : CfgDefinitionInformation(org.eclipse.titan.common.parsers.cfg.CfgDefinitionInformation) ConfigReferenceParser(org.eclipse.titan.designer.editors.configeditor.ConfigReferenceParser) ArrayList(java.util.ArrayList) CfgLocation(org.eclipse.titan.common.parsers.cfg.CfgLocation)

Aggregations

CfgDefinitionInformation (org.eclipse.titan.common.parsers.cfg.CfgDefinitionInformation)2 CfgLocation (org.eclipse.titan.common.parsers.cfg.CfgLocation)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConfigReferenceParser (org.eclipse.titan.designer.editors.configeditor.ConfigReferenceParser)1