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();
}
}
}
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);
}
}
Aggregations