‎2015 Sep 25 3:35 PM
Hi experts,
I am currently creating an ADT plugin for eclipse.
My aim is to read abap source code of current frame program / class, parse it and display some extracts in my own view.
But how can I read source code via ADT SDK?
Maybe I can use AdtSourceFileRetrievalServiceFactory/IAdtSourceFileRetrievalService, but I have to pass IFile. How do I get IFile when all I have is program name?
Are there any existing code samples / template projects?
Any hints appreciated.
Thank you
Peter
Message was edited by: Peter Herweg P. S.: Of course I can read content of current editor (see below). But when coding contains INCLUDEs, I have to read content of these includes additionally. public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil .getActiveWorkbenchWindowChecked(event); try { IEditorPart editorPart = window.getActivePage().getActiveEditor(); ITextEditor editor = (ITextEditor) editorPart .getAdapter(ITextEditor.class); if (editor != null) { IDocumentProvider provider = editor.getDocumentProvider(); IDocument document = provider.getDocument(editor.getEditorInput()); try { String code = document.get(); code = AbapSource.getCleanCode(code); document.set(code); } catch (Exception ex) { //TODO } } } catch (java.lang.Exception ex) { //TODO } return null; }
‎2015 Sep 26 2:52 PM
Hello,
I found it by myself.
Using this coding I get access to InputStream:
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject("my_project");
IFolder folder = project.getFolder(".adt").getFolder("programs").getFolder("programs").getFolder("zsd_0010");
IFile file = folder.getFile("zsd_0010.asprog");
//download to semantic file system
IAdtSfsUtil sfs = AdtSfsUtilFactory.createAdtSfsUtil();
sfs.synchronizeDevelopmentObject(file, false, null);
//open stream
InputStream is = file.getContents();
Best regards
Peter