use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions in project titan.EclipsePlug-ins by eclipse.
the class StatementBlock method registerDefinition.
/**
* Registers a definition (for example new variable) into the list of
* definitions available in this statement block.
*
* Please note, that this is done while the semantic check is happening,
* as it must not be allowed to reach definitions not yet defined.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param definition
* the definition to register.
*/
public void registerDefinition(final CompilationTimeStamp timestamp, final Definition definition) {
if (definition == null) {
return;
}
final Identifier identifier = definition.getIdentifier();
if (identifier == null) {
return;
}
if (definitionMap == null) {
definitionMap = new HashMap<String, Definition>(3);
}
final String definitionName = identifier.getName();
if (definitionMap.containsKey(definitionName)) {
if (definition.getLocation() != null && definitionMap.get(definitionName).getLocation() != null) {
final Location otherLocation = definitionMap.get(definitionName).getLocation();
otherLocation.reportSingularSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
definition.getLocation().reportSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
}
} else {
definitionMap.put(definitionName, definition);
if (parentScope != null && definition.getLocation() != null) {
if (parentScope.hasAssignmentWithId(timestamp, identifier)) {
definition.getLocation().reportSemanticError(MessageFormat.format(HIDINGSCOPEELEMENT, identifier.getDisplayName()));
final List<ISubReference> subReferences = new ArrayList<ISubReference>();
subReferences.add(new FieldSubReference(identifier));
final Reference reference = new Reference(null, subReferences);
final Assignment assignment = parentScope.getAssBySRef(timestamp, reference);
if (assignment != null && assignment.getLocation() != null) {
assignment.getLocation().reportSingularSemanticError(MessageFormat.format(HIDDENSCOPEELEMENT, identifier.getDisplayName()));
}
} else if (parentScope.isValidModuleId(identifier)) {
definition.getLocation().reportSemanticWarning(MessageFormat.format(HIDINGMODULEIDENTIFIER, identifier.getDisplayName()));
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions in project titan.EclipsePlug-ins by eclipse.
the class ImportSelectionDialog method organizeImportsEdit.
/**
* Organize the imports according to the global preferences. If set,
* <ul>
* <li>Add imports necessary for missing references,</li>
* <li>Remove unused imports,</li>
* <li>Sort the import statements.</li>
* </ul>
* <p>
* These changes are not applied in the function, just collected in a
* <link>MultiTextEdit</link>, which is then returned.
* </p>
* TODO: notice and handle ambiguous references
*
* @param module
* The module which import statements are to organize.
* @param document
* The document that contains the module.
*
* @return The edit, which contains the proper changes.
*/
private static MultiTextEdit organizeImportsEdit(final TTCN3Module module, final IDocument document) throws BadLocationException {
final IProject prj = module.getProject();
final String doc = document.get();
final MultiTextEdit insertEdit = new MultiTextEdit();
final MultiTextEdit removeEdit = new MultiTextEdit();
final List<ImportText> newImports = new ArrayList<ImportText>();
final List<ImportText> importsKept = new ArrayList<ImportText>();
boolean needSorting = false;
if (addImports) {
// register the new needed imports
final Set<String> importNamesAdded = new HashSet<String>();
for (final Reference ref : module.getMissingReferences()) {
final Location missLoc = findReferenceInProject(ref, prj);
if (missLoc != null) {
final IFile file = (IFile) missLoc.getFile();
final ProjectSourceParser parser = GlobalParser.getProjectSourceParser(file.getProject());
final Module addMod = parser.containedModule(file);
final String importName = addMod.getIdentifier().getTtcnName();
if (!importNamesAdded.contains(importName)) {
final StringBuilder impText = new StringBuilder("import from ").append(importName).append(" all;");
// if (importChangeMethod.equals(OrganizeImportPreferencePage.COMMENT_THEM)) {
impText.append(" // Added automatically to resolve ").append(ref.getDisplayName());
// }
newImports.add(new ImportText(importName, impText.toString() + NEWLINE));
importNamesAdded.add(importName);
if (reportDebug) {
final StringBuilder sb = new StringBuilder("For ").append(ref.getDisplayName()).append(": ");
sb.append(impText.toString());
TITANDebugConsole.println(sb.toString());
}
}
}
}
if (sortImports && !newImports.isEmpty()) {
needSorting = true;
}
}
if (!needSorting && sortImports) {
// are the imports already sorted ?
final List<ImportModule> oldImports = module.getImports();
for (int size = oldImports.size(), i = 0; i < size - 1 && !needSorting; i++) {
if (oldImports.get(i).getName().compareTo(oldImports.get(i + 1).getName()) > 0) {
needSorting = true;
}
if (oldImports.get(i).getLocation().getOffset() > oldImports.get(i + 1).getLocation().getOffset()) {
needSorting = true;
}
}
if (!needSorting && oldImports.size() > 1) {
// are the import strictly before the definitions ?
final int lastImportOffset = oldImports.get(oldImports.size() - 1).getLocation().getOffset();
final Definitions defs = module.getAssignmentsScope();
if (defs.getNofAssignments() > 0 && !oldImports.isEmpty()) {
for (int i = 0, size = defs.getNofAssignments(); i < size; ++i) {
final int temp = defs.getAssignmentByIndex(i).getLocation().getOffset();
if (temp < lastImportOffset) {
needSorting = true;
}
}
}
}
}
if (needSorting || removeImports) {
// remove the imports not needed, or every if sorting is required
for (final ImportModule m : module.getImports()) {
final Location delImp = m.getLocation();
final IRegion startLineRegion = document.getLineInformationOfOffset(delImp.getOffset());
final IRegion endLineRegion = document.getLineInformationOfOffset(delImp.getEndOffset());
final String delimeter = document.getLineDelimiter(document.getLineOfOffset(delImp.getEndOffset()));
final int delLength = delimeter == null ? 0 : delimeter.length();
if (needSorting || (removeImports && !m.getUsedForImportation())) {
if (reportDebug) {
final MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream();
TITANDebugConsole.println("Removing " + "'" + doc.substring(startLineRegion.getOffset(), endLineRegion.getOffset() + endLineRegion.getLength() + delLength) + "'", stream);
TITANDebugConsole.println("From " + startLineRegion.getOffset() + " till " + ((endLineRegion.getOffset() - startLineRegion.getOffset()) + endLineRegion.getLength() + delLength), stream);
}
/*if (importChangeMethod.equals(OrganizeImportPreferencePage.COMMENT_THEM)) {
removeEdit.addChild(new InsertEdit(m.getLocation().getOffset(), "/*"));
// hack to handle the semicolon
removeEdit.addChild(new InsertEdit(m.getLocation().getEndOffset() + 1, ""));
} else {*/
removeEdit.addChild(new DeleteEdit(startLineRegion.getOffset(), (endLineRegion.getOffset() - startLineRegion.getOffset()) + endLineRegion.getLength() + delLength));
// }
}
if (needSorting && (!removeImports || m.getUsedForImportation())) {
importsKept.add(new ImportText(m.getName(), doc.substring(startLineRegion.getOffset(), endLineRegion.getOffset() + endLineRegion.getLength() + delLength)));
}
}
}
if (!newImports.isEmpty() || (sortImports && needSorting)) {
// always insert at the beginning of the file
final int line = document.getLineOfOffset(module.getAssignmentsScope().getLocation().getOffset());
final IRegion lineRegion = document.getLineInformation(line);
final String delimeter = document.getLineDelimiter(line);
final int delimeterLength = delimeter == null ? 0 : delimeter.length();
final int startPos = lineRegion.getOffset() + lineRegion.getLength() + delimeterLength;
if (sortImports) {
if (needSorting || !newImports.isEmpty()) {
final List<ImportText> results = new ArrayList<ImportText>();
results.addAll(importsKept);
results.addAll(newImports);
Collections.sort(results);
for (final ImportText i : results) {
insertEdit.addChild(new InsertEdit(startPos, i.getText()));
}
}
} else {
Collections.sort(newImports);
for (final ImportText i : newImports) {
insertEdit.addChild(new InsertEdit(startPos, i.getText()));
}
}
}
final MultiTextEdit resultEdit = new MultiTextEdit();
if (insertEdit.hasChildren()) {
resultEdit.addChild(insertEdit);
}
if (removeEdit.hasChildren()) {
resultEdit.addChild(removeEdit);
}
return resultEdit;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions in project titan.EclipsePlug-ins by eclipse.
the class DependencyCollector method readDependencies.
public WorkspaceJob readDependencies() {
final WorkspaceJob job = new WorkspaceJob("ExtractModulePar: reading dependencies from source project") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(sourceProj);
// find all dependencies of the 'selection' definition
Set<IResource> allFiles = new HashSet<IResource>();
Set<IResource> asnFiles = new HashSet<IResource>();
NavigableSet<ILocateableNode> dependencies = new TreeSet<ILocateableNode>(new LocationComparator());
for (Def_ModulePar def : selection) {
/*
* Def_ModulePars with mutliple entries in a single modulepar block have incorrect location info
* (all entries have a location info equal to the location of their parent block)
* that is why the dependencies must be collected into a set that is not sorted by location
*
* TODO fix grammar definitions
* */
Set<ILocateableNode> nonSortedTempSet = new HashSet<ILocateableNode>();
collectDependencies(def, nonSortedTempSet, allFiles, asnFiles);
dependencies.addAll(nonSortedTempSet);
allFiles.add(def.getLocation().getFile());
// adding the selection itself to the dependencies
if (!dependencies.contains(def)) {
dependencies.add(def);
}
// get imports and friends for all files
for (IResource r : allFiles) {
if (!(r instanceof IFile)) {
continue;
}
IFile f = (IFile) r;
Module m = projectSourceParser.containedModule(f);
ImportFinderVisitor impVisitor = new ImportFinderVisitor();
m.accept(impVisitor);
List<ImportModule> impDefs = impVisitor.getImportDefs();
List<FriendModule> friendDefs = impVisitor.getFriendDefs();
filterImportDefinitions(allFiles, impDefs, projectSourceParser);
filterFriendDefinitions(allFiles, friendDefs, projectSourceParser);
dependencies.addAll(impDefs);
dependencies.addAll(friendDefs);
// the dependencies are sorted by file & location to avoid reading through a file multiple times
}
}
// collect the text to insert into the new project
copyMap = new HashMap<IPath, StringBuilder>();
try {
InputStream is = null;
InputStreamReader isr = null;
IResource lastFile = null;
IResource currFile;
ILocateableNode lastD = null;
int currOffset = 0;
for (ILocateableNode d : dependencies) {
currFile = d.getLocation().getFile();
if (!(currFile instanceof IFile)) {
ErrorReporter.logError("ExtractModulePar/DependencyCollector: IResource `" + currFile.getName() + "' is not an IFile.");
continue;
}
if (currFile != lastFile) {
// started reading new file
lastD = null;
if (lastFile != null) {
addToCopyMap(lastFile.getProjectRelativePath(), MODULE_TRAILER);
}
if (isr != null) {
isr.close();
}
if (is != null) {
is.close();
}
is = ((IFile) currFile).getContents();
isr = new InputStreamReader(is);
currOffset = 0;
Module m = projectSourceParser.containedModule((IFile) currFile);
String moduleName = m.getIdentifier().getTtcnName();
addToCopyMap(currFile.getProjectRelativePath(), MessageFormat.format(MODULE_HEADER, moduleName));
}
int toSkip = getNodeOffset(d) - currOffset;
if (toSkip < 0) {
reportOverlappingError(lastD, d);
continue;
}
isr.skip(toSkip);
// separators
if (d instanceof ImportModule && lastD instanceof ImportModule) {
addToCopyMap(currFile.getProjectRelativePath(), SINGLE_SEPARATOR);
} else if (d instanceof FriendModule && lastD instanceof FriendModule) {
addToCopyMap(currFile.getProjectRelativePath(), SINGLE_SEPARATOR);
} else {
addToCopyMap(currFile.getProjectRelativePath(), DOUBLE_SEPARATOR);
}
//
insertDependency(d, currFile, isr);
currOffset = d.getLocation().getEndOffset();
lastFile = currFile;
lastD = d;
}
if (lastFile != null) {
addToCopyMap(lastFile.getProjectRelativePath(), MODULE_TRAILER);
}
if (isr != null) {
isr.close();
}
if (is != null) {
is.close();
}
// copy the full content of asn files without opening them
filesToCopy = new ArrayList<IFile>();
for (IResource r : asnFiles) {
if (!(r instanceof IFile)) {
ErrorReporter.logError("ExtractModulePar/DependencyCollector: IResource `" + r.getName() + "' is not an IFile.");
continue;
}
filesToCopy.add((IFile) r);
}
} catch (IOException ioe) {
ErrorReporter.logError("ExtractModulePar/DependencyCollector: Error while reading source project.");
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
private void insertDependency(final ILocateableNode d, final IResource res, final InputStreamReader isr) throws IOException {
char[] content = new char[d.getLocation().getEndOffset() - getNodeOffset(d)];
isr.read(content, 0, content.length);
addToCopyMap(res.getProjectRelativePath(), new String(content));
}
};
job.setUser(true);
job.schedule();
return job;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions in project titan.EclipsePlug-ins by eclipse.
the class AstWalkerRunnerJava method walkChildren.
private void walkChildren(ASTVisitor visitor, Object[] children) {
LoggerVisitor logger = new LoggerVisitor();
for (Object child : children) {
if (child instanceof Definitions) {
Definitions definitions = (Definitions) child;
moduleElementName = definitions.getFullName();
logToConsole("Starting processing: " + moduleElementName);
myASTVisitor.myFunctionTestCaseVisitHandler.clearEverything();
if (Boolean.parseBoolean(props.getProperty("ast.log.enabled"))) {
definitions.accept(logger);
}
definitions.accept(visitor);
logToConsole("Finished processing: " + moduleElementName);
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions in project titan.EclipsePlug-ins by eclipse.
the class Definitions method updateSyntax.
/**
* Handles the incremental parsing of this list of definitions.
*
* @param reparser
* the parser doing the incremental parsing.
* @param importedModules
* the list of module importations found in the same
* module.
* @param friendModules
* the list of friend module declaration in the same
* module.
* @param controlpart
* the control part found in the same module.
* @throws ReParseException
* if there was an error while refreshing the location
* information and it could not be solved internally.
*/
public void updateSyntax(final TTCN3ReparseUpdater reparser, final List<ImportModule> importedModules, final List<FriendModule> friendModules, final ControlPart controlpart) throws ReParseException {
// calculate damaged region
int result = 0;
boolean enveloped = false;
int nofDamaged = 0;
int leftBoundary = location.getOffset();
int rightBoundary = location.getEndOffset();
final int damageOffset = reparser.getDamageStart();
final int damageEndOffset = reparser.getDamageEnd();
IAppendableSyntax lastAppendableBeforeChange = null;
IAppendableSyntax lastPrependableBeforeChange = null;
boolean isControlPossible = controlpart == null;
if (controlpart != null) {
final Location tempLocation = controlpart.getLocation();
if (reparser.envelopsDamage(tempLocation)) {
enveloped = true;
} else if (!reparser.isDamaged(tempLocation)) {
if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
leftBoundary = tempLocation.getEndOffset();
lastAppendableBeforeChange = controlpart;
}
if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = controlpart;
}
}
}
for (int i = 0, size = groups.size(); i < size && !enveloped; i++) {
final Group tempGroup = groups.get(i);
final Location tempLocation = tempGroup.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 = tempGroup;
}
if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = tempGroup;
}
}
}
if (!groups.isEmpty()) {
isControlPossible &= groups.get(groups.size() - 1).getLocation().getEndOffset() < leftBoundary;
}
for (int i = 0, size = importedModules.size(); i < size && !enveloped; i++) {
final ImportModule tempImport = importedModules.get(i);
if (tempImport.getParentGroup() == null) {
final Location tempLocation = tempImport.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 = tempImport;
}
if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = tempImport;
}
}
}
}
if (!importedModules.isEmpty()) {
isControlPossible &= importedModules.get(importedModules.size() - 1).getLocation().getEndOffset() < leftBoundary;
}
for (int i = 0, size = friendModules.size(); i < size && !enveloped; i++) {
final FriendModule tempFriend = friendModules.get(i);
if (tempFriend.getParentGroup() == null) {
final Location tempLocation = tempFriend.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 = tempFriend;
}
if (tempLocation.getOffset() > damageEndOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = tempFriend;
}
}
}
}
if (!friendModules.isEmpty()) {
isControlPossible &= friendModules.get(friendModules.size() - 1).getLocation().getEndOffset() < leftBoundary;
}
for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext() && !enveloped; ) {
final Definition temp = iterator.next();
if (temp.getParentGroup() == null) {
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() > damageEndOffset && cumulativeLocation.getOffset() < rightBoundary) {
rightBoundary = cumulativeLocation.getOffset();
lastPrependableBeforeChange = temp;
}
}
final Location tempCommentLocation = temp.getCommentLocation();
if (tempCommentLocation != null && reparser.isDamaged(tempCommentLocation)) {
nofDamaged++;
rightBoundary = tempLocation.getEndOffset();
}
}
}
if (!definitions.isEmpty()) {
isControlPossible &= definitions.get(definitions.size() - 1).getLocation().getEndOffset() < leftBoundary;
}
// was not enveloped
if (!enveloped && reparser.isDamaged(location)) {
// 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, importedModules, friendModules);
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
lastCompilationTimeStamp = null;
}
// extend damaged region till the neighbor definitions just here to avoid calculating something damaged or extended:
// Perhaps it should be moved even farther:
reparser.extendDamagedRegion(leftBoundary, rightBoundary);
}
// update what is left
for (int i = 0; i < groups.size(); i++) {
final Group temp = groups.get(i);
final Location tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
temp.updateSyntax(reparser, importedModules, definitions, friendModules);
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
groups.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
e.decreaseDepth();
throw e;
}
}
}
}
for (int i = 0; i < importedModules.size(); i++) {
final ImportModule temp = importedModules.get(i);
if (temp.getParentGroup() == null) {
final Location tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
final boolean isDamaged = enveloped && reparser.envelopsDamage(tempLocation);
temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
if (isDamaged) {
((TTCN3Module) parentScope).checkRoot();
}
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
importedModules.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
e.decreaseDepth();
throw e;
}
}
}
}
}
for (int i = 0; i < friendModules.size(); i++) {
final FriendModule temp = friendModules.get(i);
if (temp.getParentGroup() == null) {
final Location tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
final boolean isDamaged = enveloped && reparser.envelopsDamage(tempLocation);
temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
if (isDamaged) {
((TTCN3Module) parentScope).checkRoot();
}
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
friendModules.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
e.decreaseDepth();
throw e;
}
}
}
}
}
for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
final Definition temp = iterator.next();
if (temp.getParentGroup() == null) {
final Location tempLocation = temp.getLocation();
final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
if (reparser.isAffected(cumulativeLocation)) {
try {
final boolean isDamaged = enveloped && reparser.envelopsDamage(tempLocation);
temp.updateSyntax(reparser, isDamaged);
if (reparser.getNameChanged()) {
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
// to recheck the whole module
lastCompilationTimeStamp = null;
reparser.setNameChanged(false);
// This could also spread
}
if (isDamaged) {
// TODO lets move this into the definitions
temp.checkRoot();
}
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
definitions.remove(temp);
reparser.extendDamagedRegion(cumulativeLocation);
result = 1;
} else {
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
e.decreaseDepth();
throw e;
}
}
}
}
}
if (result == 1) {
removeStuffInRange(reparser, importedModules, friendModules);
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
lastCompilationTimeStamp = null;
}
for (int i = 0, size = groups.size(); i < size; i++) {
final Group temp = groups.get(i);
final Location 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);
if (temp.getParentGroup() == null) {
final Location 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);
if (temp.getParentGroup() == null) {
final Location tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
reparser.updateLocation(tempLocation);
}
}
}
for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
final Definition temp = iterator.next();
if (temp.getParentGroup() == null) {
final Location tempLocation = temp.getLocation();
final Location cumulativeLocation = temp.getCumulativeDefinitionLocation();
if (reparser.isAffected(tempLocation)) {
if (tempLocation != cumulativeLocation) {
reparser.updateLocation(cumulativeLocation);
}
reparser.updateLocation(tempLocation);
}
}
}
final boolean tempIsControlPossible = isControlPossible;
if (!enveloped) {
if (reparser.envelopsDamage(location)) {
reparser.extendDamagedRegion(leftBoundary, rightBoundary);
result = reparse(reparser, tempIsControlPossible);
result = Math.max(result - 1, 0);
lastCompilationTimeStamp = null;
} else {
result = Math.max(result, 1);
}
}
if (result == 0) {
lastUniquenessCheckTimeStamp = null;
} else {
if (doubleDefinitions != null) {
doubleDefinitions.clear();
}
lastUniquenessCheckTimeStamp = null;
throw new ReParseException(result);
}
}
Aggregations