use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class MinimizeScopeActionFromEditor method findSelection.
private Definition findSelection() {
// getting the active editor
final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
TTCN3Editor targetEditor;
if (editor == null || !(editor instanceof TTCN3Editor)) {
return null;
} else {
targetEditor = (TTCN3Editor) editor;
}
final IStatusLineManager statusLineManager = targetEditor.getEditorSite().getActionBars().getStatusLineManager();
// getting current selection
final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
final TextSelection textSelection = extractSelection(selectionService.getSelection());
// iterating through part of the module
final IResource selectedRes = extractResource(targetEditor);
if (!(selectedRes instanceof IFile)) {
ErrorReporter.logError("SelectionFinder.findSelection(): Selected resource `" + selectedRes.getName() + "' is not a file.");
return null;
}
final IFile selectedFile = (IFile) selectedRes;
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(selectedFile.getProject());
final Module selectedModule = projectSourceParser.containedModule(selectedFile);
// getting current selection nodes
final int selectionOffset = textSelection.getOffset() + textSelection.getLength();
final SelectionFinderVisitor selVisitor = new SelectionFinderVisitor(selectionOffset);
selectedModule.accept(selVisitor);
final Definition selectedDef = selVisitor.getSelection();
if (selectedDef == null) {
ErrorReporter.logWarning("SelectionFinder.findSelection(): Visitor did not find a definition in the selection.");
statusLineManager.setErrorMessage(ERR_MSG_NO_SELECTION);
return null;
}
return selectedDef;
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class DependencyCollector method filterImportDefinitions.
/**
* Returns the <code>importDefs</code> list, with the {@link ImportModule}s removed which refer to
* modules that are not contained in the <code>allFiles</code> set.
*/
private static void filterImportDefinitions(final Set<IResource> allFiles, final List<ImportModule> importDefs, final ProjectSourceParser projParser) {
final List<Identifier> allFileIds = new ArrayList<Identifier>(allFiles.size());
for (IResource r : allFiles) {
if (!(r instanceof IFile)) {
continue;
}
final IFile f = (IFile) r;
final Module m = projParser.containedModule(f);
allFileIds.add(m.getIdentifier());
}
final ListIterator<ImportModule> importIt = importDefs.listIterator();
while (importIt.hasNext()) {
final ImportModule im = importIt.next();
final Identifier id = im.getIdentifier();
if (!allFileIds.contains(id)) {
importIt.remove();
}
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class DependencyCollector method filterFriendDefinitions.
/**
* Returns the <code>friendDefs</code> list, with the {@link FriendModule}s removed which refer to
* modules that are not contained in the <code>allFiles</code> set.
*/
private static void filterFriendDefinitions(final Set<IResource> allFiles, final List<FriendModule> friendDefs, final ProjectSourceParser projParser) {
final List<Identifier> allFileIds = new ArrayList<Identifier>(allFiles.size());
for (IResource r : allFiles) {
if (!(r instanceof IFile)) {
continue;
}
final IFile f = (IFile) r;
final Module m = projParser.containedModule(f);
allFileIds.add(m.getIdentifier());
}
final ListIterator<FriendModule> importIt = friendDefs.listIterator();
while (importIt.hasNext()) {
final FriendModule fm = importIt.next();
final Identifier id = fm.getIdentifier();
if (!allFileIds.contains(id)) {
importIt.remove();
}
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Expectation method runTest.
public void runTest() {
Map<String, List<Integer>> actualMarkers = new HashMap<String, List<Integer>>();
// analyze the modules, and collect the related markers
IProject project = WorkspaceHandlingLibrary.getWorkspace().getRoot().getProject(CustomConfigurable.PROJECT_TO_USE);
ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
for (String modName : expectedMarkers.keySet()) {
Module mod = parser.getModuleByName(modName);
IResource file = mod.getLocation().getFile();
MarkerHandler mh = Analyzer.builder().addProblem(type).build().analyzeModule(new NullProgressMonitor(), mod);
List<Integer> lines = new ArrayList<Integer>();
for (Marker m : mh.get(file)) {
if (m.getProblemType() == type && m.getLine() != -1) {
lines.add(m.getLine());
}
}
// save the line number of markers that were from our problem type
actualMarkers.put(modName, lines);
}
// check whether the reality complies our expectations
for (String modName : expectedMarkers.keySet()) {
for (Integer ln : expectedMarkers.get(modName)) {
if (!actualMarkers.get(modName).remove(ln)) {
fail("We expected a marker in " + modName + " at line " + ln + ", but have not found it");
}
}
}
// Check whether we managed to consume all markers that showed up during the analysis
for (String modName : actualMarkers.keySet()) {
for (Integer ln : actualMarkers.get(modName)) {
fail("Unexpected marker in " + modName + " at line " + ln);
}
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Integer_Type method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (null != myScope) {
final Module module = myScope.getModuleScope();
if (null != module) {
if (module.getSkippedFromSemanticChecking()) {
return;
}
}
}
isErroneous = false;
if (null == namedNumbers) {
parseBlockInt();
}
if (isErroneous || null == namedNumbers) {
return;
}
/* check named numbers */
final Map<String, Identifier> nameMap = new HashMap<String, Identifier>();
for (int i = 0, size = namedNumbers.getSize(); i < size; i++) {
final NamedValue namedValue = namedNumbers.getNamedValueByIndex(i);
final Identifier identifier = namedValue.getName();
if (nameMap.containsKey(identifier.getName())) {
final Location tempLocation = nameMap.get(identifier.getName()).getLocation();
tempLocation.reportSingularSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
nameMap.put(identifier.getName(), identifier);
}
}
final Map<Integer, NamedValue> valueMap = new HashMap<Integer, NamedValue>();
for (int i = 0, size = namedNumbers.getSize(); i < size; i++) {
final NamedValue namedValue = namedNumbers.getNamedValueByIndex(i);
final IValue value = namedValue.getValue();
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (last.getIsErroneous(timestamp)) {
continue;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
{
final Integer_Value integerValue = (Integer_Value) last;
if (integerValue.isNative()) {
final Integer intValue = Integer.valueOf(integerValue.intValue());
if (valueMap.containsKey(intValue)) {
value.getLocation().reportSemanticError(MessageFormat.format("Duplicate number {0} for name `{1}''", intValue, namedValue.getName().getDisplayName()));
final NamedValue temp = valueMap.get(intValue);
temp.getLocation().reportSemanticError(MessageFormat.format("Number {0} is already assigned to name `{1}''", intValue, temp.getName().getDisplayName()));
} else {
valueMap.put(intValue, namedValue);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format("Integer value `{0}'' is too big to be used as a named number", integerValue.getValueValue()));
value.setIsErroneous(true);
}
break;
}
default:
namedValue.getLocation().reportSemanticError(MessageFormat.format("INTEGER value was expected for named number `{0}''", namedValue.getName().getDisplayName()));
value.setIsErroneous(true);
break;
}
}
nameMap.clear();
if (null != constraints) {
constraints.check(timestamp);
}
if (myScope != null) {
checkEncode(timestamp);
checkVariants(timestamp);
}
}
Aggregations