use of org.eclipse.titan.designer.AST.TTCN3.definitions.VisibilityModifier in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method calculateEditLocations.
private WorkspaceJob calculateEditLocations(final NavigableSet<ILocateableNode> nodes, final IFile file, final List<Location> locations_out) throws CoreException {
final WorkspaceJob job = new WorkspaceJob("MinimizeVisibilityRefactoring: calculate edit locations") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
final int BUF_LEN = 8;
try {
InputStream is = file.getContents();
InputStreamReader isr = new InputStreamReader(is);
int currOffset = 0;
char[] content = new char[BUF_LEN];
for (ILocateableNode node : nodes) {
int toSkip = node.getLocation().getOffset() - currOffset;
if (toSkip < 0) {
ErrorReporter.logError("MinimizeVisibilityRefactoring.ChangeCreator: Negative skip value" + " while parsing file: " + file.getName() + ", offset: " + node.getLocation().getOffset() + "->" + currOffset);
continue;
}
isr.skip(toSkip);
isr.read(content);
String str = new String(content);
VisibilityModifier vm = parseVisibilityModifier(str);
int vmLen = 0;
if (vm != null) {
switch(vm) {
case Public:
vmLen = 7;
break;
case Friend:
vmLen = 7;
break;
case Private:
vmLen = 8;
break;
}
}
locations_out.add(new Location(node.getLocation().getFile(), node.getLocation().getLine(), node.getLocation().getOffset(), node.getLocation().getOffset() + vmLen));
currOffset = node.getLocation().getOffset() + BUF_LEN;
}
isr.close();
is.close();
} catch (IOException ioe) {
ErrorReporter.logError("MinimizeVisibilityRefactoring.CreateChange: " + "Error while reading source project.");
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return job;
}
Aggregations