use of org.eclipse.titan.designer.editors.ttcnppeditor.TTCNPPEditor in project titan.EclipsePlug-ins by eclipse.
the class GotoMatchingBracketAction method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof TTCNPPEditor) {
this.targetEditor = (TTCNPPEditor) activeEditor;
} else {
this.targetEditor = null;
}
if (activeEditor == null) {
return null;
}
if (!selection.isEmpty()) {
if (selection instanceof TextSelection) {
TextSelection tSelection = (TextSelection) selection;
if (tSelection.getLength() != 0) {
return null;
}
}
}
IDocument document = this.targetEditor.getDocument();
int carretOffset = this.targetEditor.getCarretOffset();
PairMatcher pairMatcher = new PairMatcher();
IRegion region = pairMatcher.match(document, carretOffset);
if (region == null) {
return null;
}
int targetOffset;
if (region.getOffset() + 1 == carretOffset) {
targetOffset = region.getOffset() + region.getLength();
} else {
targetOffset = region.getOffset() + 1;
}
this.targetEditor.setCarretOffset(targetOffset);
this.targetEditor.selectAndReveal(targetOffset, 0);
return null;
}
use of org.eclipse.titan.designer.editors.ttcnppeditor.TTCNPPEditor in project titan.EclipsePlug-ins by eclipse.
the class IndentAction method performEdits.
@Override
protected void performEdits(final RewriteSessionEditProcessor processor) throws BadLocationException {
MonoReconciler reconciler = ((TTCNPPEditor) getTargetEditor()).getReconciler();
reconciler.setIsIncrementalReconciler(false);
processor.performEdits();
IPreferencesService prefs = Platform.getPreferencesService();
reconciler.setIsIncrementalReconciler(prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEINCREMENTALPARSING, false, null));
}
use of org.eclipse.titan.designer.editors.ttcnppeditor.TTCNPPEditor in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method doOpenDeclaration.
private final void doOpenDeclaration() {
if (targetEditor == null || !(targetEditor instanceof TTCNPPEditor)) {
return;
}
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(FILENOTIDENTIFIABLE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
if (ResourceExclusionHelper.isExcluded(file)) {
MessageDialog.openError(null, "Open Declaration does not work within excluded resources", "This module is excluded from build. To use the Open Declaration " + "feature please click on the 'Toggle exclude from build state' in the context menu of the Project Explorer. ");
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
int offset;
if (!selection.isEmpty() && selection instanceof TextSelection && !"".equals(((TextSelection) selection).getText())) {
if (reportDebugInformation) {
TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
}
TextSelection tSelection = (TextSelection) selection;
offset = tSelection.getOffset() + tSelection.getLength();
} else {
offset = ((TTCNPPEditor) targetEditor).getCarretOffset();
}
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
final Module module = projectSourceParser.containedModule(file);
if (module == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("Can not find the module.");
}
return;
}
IdentifierFinderVisitor visitor = new IdentifierFinderVisitor(offset);
module.accept(visitor);
final Declaration decl = visitor.getReferencedDeclaration();
if (decl == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("No visible elements found");
}
return;
}
selectAndRevealDeclaration(decl.getIdentifier().getLocation());
}
use of org.eclipse.titan.designer.editors.ttcnppeditor.TTCNPPEditor in project titan.EclipsePlug-ins by eclipse.
the class OrganizeFromEditor method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor == null || !(editor instanceof TTCN3Editor || editor instanceof TTCNPPEditor)) {
ErrorReporter.logError("The editor is not found or not a Titan TTCN-3 editor");
return null;
}
final IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
TextFileChange change = null;
try {
change = OrganizeImports.organizeImportsChange(file);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace("Error while creating the needed import changes", e);
return null;
}
try {
change.perform(new NullProgressMonitor());
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace("Error while performing the needed import changes", e);
}
final IProject project = file.getProject();
GlobalParser.getProjectSourceParser(project).reportOutdating(file);
GlobalParser.getProjectSourceParser(project).analyzeAll();
return null;
}
Aggregations