Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] eclipseCon 2008: Static Analysis in PTP with CDT

Hi!

I tried to use the code from page 10: Creating an AST (1): get ITranslationUnit in the following context:

I registered a listener on a File open action:

		PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
			public void run() {
				IWorkbenchWindow dwindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
				IWorkbenchPage page = dwindow.getActivePage();
				if (page != null) {
					try {
						page.addPartListener(new FileOpenedListener());
					} catch (NullPointerException npe) {
					}
				}
			}
		});

which implements the IPartListener2 interface:

public void partActivated(IWorkbenchPartReference partRef) {
	}

	public void partBroughtToTop(IWorkbenchPartReference partRef) {
	}

	public void partClosed(IWorkbenchPartReference partRef) {
	}

	public void partDeactivated(IWorkbenchPartReference partRef) {
	}

	public void partHidden(IWorkbenchPartReference partRef) {
	}

	public void partInputChanged(IWorkbenchPartReference partRef) {
		
	}

	public void partOpened(IWorkbenchPartReference partRef) {


	}

	public void partVisible(IWorkbenchPartReference partRef) {
		IEditorPart editor = partRef.getPage().getActiveEditor();
		if (editor != null) {

			IResource resource = extractResource(editor);

			if (resource != null) {
				this.openedFile = resource;
				SconsxLog.logInfo("editor :" + editor.getTitle() + " resource " + resource.getLocation());
				
				this.getUnresolvedIncludesFromAST();
				
				try {
					this.entriesBefore = CoreModel.getRawPathEntries(CoreModel.getDefault().create( resource.getProject() ));
				} catch (CModelException cme) {
					SconsxLog.logError(this.openedFile.getProject().getName() + ": Could not get include paths from opened file: " + this.openedFile.getName(), cme);
				}
				
			}
		}
	}

but i am getting a NullPointerException on ITranslationUnit tu =
        (ITranslationUnit)iad.getAdapter(ITranslationUnit.class);


Plug-in 'org.eclipse.ptp.pldt.sampleCDTstaticAnalysis' contributed an invalid Menu Extension (Path: 'sampleMenu' is invalid): cdtast2.actions.SampleAction
-- 
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx


Back to the top