use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3FoldingSupport in project titan.EclipsePlug-ins by eclipse.
the class ReconcilingStrategy method fullReconciliation.
private void fullReconciliation(final boolean isInitial) {
actualCode = new StringBuilder(document.get());
GlobalIntervalHandler.putInterval(document, null);
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
analyze(isInitial);
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
List<Position> positions = (new TTCN3FoldingSupport()).calculatePositions(document);
editor.updateFoldingStructure(positions);
editor.updateOutlinePage();
}
});
}
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3FoldingSupport in project titan.EclipsePlug-ins by eclipse.
the class ReconcilingStrategy method reconcile.
@Override
public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) {
if (editor == null || document == null) {
return;
}
int lineBreaks = 0;
try {
if (DirtyRegion.INSERT.equals(dirtyRegion.getType())) {
actualCode.insert(dirtyRegion.getOffset(), dirtyRegion.getText());
lineBreaks = org.eclipse.titan.designer.editors.ttcn3editor.ReconcilingStrategy.calculateLineBreaks(dirtyRegion.getText(), document.getLegalLineDelimiters());
} else {
lineBreaks = org.eclipse.titan.designer.editors.ttcn3editor.ReconcilingStrategy.calculateLineBreaks(actualCode.substring(dirtyRegion.getOffset(), dirtyRegion.getOffset() + dirtyRegion.getLength()), document.getLegalLineDelimiters());
actualCode.delete(dirtyRegion.getOffset(), dirtyRegion.getOffset() + dirtyRegion.getLength());
}
} catch (StringIndexOutOfBoundsException e) {
ErrorReporter.logExceptionStackTrace(e);
ErrorReporter.logError("String length: " + actualCode.length() + " region type: " + dirtyRegion.getType() + " region offset: " + dirtyRegion.getOffset() + " region length: " + dirtyRegion.getLength() + " region text: '" + dirtyRegion.getText() + "'\n" + "Actual size of the document: " + document.get().length());
actualCode = new StringBuilder(document.get());
}
if (dirtyRegion.getOffset() == 0 && document.getLength() == dirtyRegion.getLength()) {
// thing
if (!editor.isDirty()) {
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
analyze(false);
}
return;
}
int firstLine;
try {
firstLine = document.getLineOfOffset(dirtyRegion.getOffset());
} catch (BadLocationException e) {
ErrorReporter.logWarningExceptionStackTrace(e);
firstLine = 0;
}
final IFile editedFile = (IFile) editor.getEditorInput().getAdapter(IFile.class);
if (editedFile == null) {
return;
}
final TTCN3ReparseUpdater reparser;
int length = dirtyRegion.getLength();
if (DirtyRegion.INSERT.equals(dirtyRegion.getType())) {
reparser = new TTCN3ReparseUpdater(editedFile, actualCode.toString(), firstLine + 1, lineBreaks, dirtyRegion.getOffset(), dirtyRegion.getOffset(), length);
} else {
reparser = new TTCN3ReparseUpdater(editedFile, actualCode.toString(), firstLine + 1, -1 * lineBreaks, dirtyRegion.getOffset(), dirtyRegion.getOffset() + length, -1 * length);
}
final IProject project = editedFile.getProject();
if (project == null) {
return;
}
final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(project);
sourceParser.updateSyntax(editedFile, reparser);
if (!editor.isSemanticCheckingDelayed()) {
sourceParser.analyzeAll();
WorkspaceJob op = new WorkspaceJob(OUTLINEUPDATE) {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
List<Position> positions = (new TTCN3FoldingSupport()).calculatePositions(document);
editor.updateFoldingStructure(positions);
editor.refreshOutlinePage();
}
});
return Status.OK_STATUS;
}
};
op.setPriority(Job.LONG);
op.setSystem(true);
op.setUser(false);
op.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
op.setRule(project);
op.schedule();
} else {
sourceParser.reportSyntacticOutdatingOnly(editedFile);
sourceParser.analyzeAllOnlySyntactically();
}
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3FoldingSupport in project titan.EclipsePlug-ins by eclipse.
the class ReconcilingStrategy method analyze.
public void analyze(final boolean isInitial) {
final IFile editedFile = (IFile) editor.getEditorInput().getAdapter(IFile.class);
if (editedFile == null || ResourceExclusionHelper.isExcluded(editedFile)) {
return;
}
IProject project = editedFile.getProject();
if (project == null) {
return;
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
List<Position> positions = (new TTCN3FoldingSupport()).calculatePositions(document);
getEditor().updateFoldingStructure(positions);
}
});
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
if (isInitial || !editor.isSemanticCheckingDelayed()) {
projectSourceParser.reportOutdating(editedFile);
projectSourceParser.analyzeAll();
WorkspaceJob op = new WorkspaceJob(OUTLINEUPDATE) {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!MarkerHandler.hasMarker(GeneralConstants.ONTHEFLY_SYNTACTIC_MARKER, editedFile)) {
getEditor().updateOutlinePage();
}
Module module = projectSourceParser.containedModule(editedFile);
if (module != null && module instanceof TTCN3Module) {
final List<Location> icList = ((TTCN3Module) module).getInactiveCodeLocations();
getEditor().updateInactiveCodeAnnotations(icList);
}
}
});
return Status.OK_STATUS;
}
};
op.setPriority(Job.LONG);
op.setSystem(true);
op.setUser(false);
op.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
op.setRule(project);
op.schedule();
} else {
projectSourceParser.reportSyntacticOutdatingOnly(editedFile);
projectSourceParser.analyzeAllOnlySyntactically();
}
}
Aggregations