org.eclipse.jdt.debug.core.IJavaStackFrame Java Examples

The following examples show how to use org.eclipse.jdt.debug.core.IJavaStackFrame. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaDebugElementCodeMiningASTVisitor.java    From jdt-codemining with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean visit(ClassInstanceCreation node) {
	if (inFrame) {
		List arguments = node.arguments();
		if (arguments.size() > 0) {
			for (int i = 0; i < arguments.size(); i++) {
				Expression exp = (Expression) arguments.get(i);
				if (exp instanceof SimpleName) {
					AbstractDebugVariableCodeMining<IJavaStackFrame> m = new JavaDebugElementCodeMining(
							(SimpleName) exp, fFrame, viewer, provider);
					minings.add(m);
				}
			}
		}
	}
	return super.visit(node);
}
 
Example #2
Source File: DebugPluginListener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public String findXtextSourceFileNameForClassFile(String simpleFileName) {
	if (!simpleFileName.endsWith(".class"))
		return null;
	String typename = simpleFileName.substring(0, simpleFileName.length() - ".class".length());
	synchronized (this) {
		try {
			List<IStackFrame> frames = Lists.newArrayList();
			if (lastFrame != null)
				frames.add(lastFrame);
			if (lastThread != null)
				frames.addAll(Lists.newArrayList(lastThread.getStackFrames()));
			for (IStackFrame frame : frames)
				if (frame instanceof IJavaStackFrame) {
					IJavaStackFrame jsf = (IJavaStackFrame) frame;
					String simpleName = Strings.lastToken(jsf.getDeclaringTypeName(), ".");
					if (simpleName.equals(typename))
						return jsf.getSourceName();
				}
		} catch (DebugException e) {
			log.error(e.getMessage(), e);
		}
		return null;
	}

}
 
Example #3
Source File: JavaDebugElementCodeMiningASTVisitor.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
public JavaDebugElementCodeMiningASTVisitor(IJavaStackFrame frame, CompilationUnit cu, ITextViewer viewer,
		List<ICodeMining> minings, AbstractDebugVariableCodeMiningProvider provider) {
	this.cu = cu;
	this.minings = minings;
	this.provider = provider;
	this.viewer = viewer;
	this.fFrame = frame;
}
 
Example #4
Source File: JavaDebugElementCodeMiningASTVisitor.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(MethodInvocation node) {
	if (inFrame) {
		List arguments = node.arguments();
		if (arguments.size() > 0) {
			for (int i = 0; i < arguments.size(); i++) {
				Expression exp = (Expression) arguments.get(i);
				if (exp instanceof SimpleName) {
					AbstractDebugVariableCodeMining<IJavaStackFrame> m = new JavaDebugElementCodeMining(
							(SimpleName) exp, fFrame, viewer, provider);
					minings.add(m);
				}
			}
		}
	}
	return super.visit(node);
}
 
Example #5
Source File: JavaDebugElementCodeMiningASTVisitor.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(VariableDeclaration node) {
	if (inFrame) {
		AbstractDebugVariableCodeMining<IJavaStackFrame> m = new JavaDebugElementCodeMining(node.getName(), fFrame,
				viewer, provider);
		minings.add(m);
	}
	return super.visit(node);
}
 
Example #6
Source File: JavaDebugElementCodeMiningProvider.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected List provideCodeMinings(ITextViewer viewer, IJavaStackFrame frame, IProgressMonitor monitor) {
	List<ICodeMining> minings = new ArrayList<>();
	ITextEditor textEditor = super.getAdapter(ITextEditor.class);
	ITypeRoot unit = EditorUtility.getEditorInputJavaElement(textEditor, true);
	if (unit == null) {
		return minings;
	}
	CompilationUnit cu = SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_YES, null);
	JavaDebugElementCodeMiningASTVisitor visitor = new JavaDebugElementCodeMiningASTVisitor(frame, cu, viewer,
			minings, this);
	cu.accept(visitor);
	return minings;
}
 
Example #7
Source File: JavaDebugElementCodeMiningProvider.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IJavaStackFrame getStackFrame(ITextViewer viewer, ITextEditor textEditor) {
	IAdaptable adaptable = DebugUITools.getPartDebugContext(textEditor.getSite());
	if (adaptable != null) {
		return adaptable.getAdapter(IJavaStackFrame.class);
	}
	return null;
}
 
Example #8
Source File: XbaseLineBreakpoint.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IJavaProject getJavaProject(IJavaStackFrame stackFrame) {
	IJavaProject javaProject = super.getJavaProject(stackFrame);
	if (javaProject == null) {
		javaProject = computeJavaProject(stackFrame);
	}
	return javaProject;
}
 
Example #9
Source File: JavaDebugElementCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 4 votes vote down vote up
public JavaDebugElementCodeMining(SimpleName node, IJavaStackFrame frame, ITextViewer viewer,
		AbstractDebugVariableCodeMiningProvider provider) {
	super(getPosition(node, viewer.getDocument()), node.getIdentifier(), frame, provider);
}
 
Example #10
Source File: XbaseLineBreakpoint.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private IJavaProject computeJavaProject(IJavaStackFrame stackFrame) {
	ILaunch launch = stackFrame.getLaunch();
	if (launch == null) {
		return null;
	}
	ISourceLocator locator = launch.getSourceLocator();
	if (locator == null)
		return null;

	Object sourceElement = null;
	try {
		if (locator instanceof ISourceLookupDirector
				&& !stackFrame.isStatic()) {
			IJavaType thisType = stackFrame.getThis().getJavaType();
			if (thisType instanceof IJavaReferenceType) {
				String[] sourcePaths = ((IJavaReferenceType) thisType)
						.getSourcePaths(null);
				if (sourcePaths != null && sourcePaths.length > 0) {
					sourceElement = ((ISourceLookupDirector) locator)
							.getSourceElement(sourcePaths[0]);
				}
			}
		}
	} catch (DebugException e) {
		DebugPlugin.log(e);
	}
	if (sourceElement == null) {
		sourceElement = locator.getSourceElement(stackFrame);
	}
	
	sourceElement = Adapters.adapt(sourceElement, IJavaElement.class);
	
	if (sourceElement instanceof IJavaElement) {
		return ((IJavaElement) sourceElement).getJavaProject();
	} else if (sourceElement instanceof IResource) {
		IJavaProject project = JavaCore.create(((IResource) sourceElement)
				.getProject());
		if (project.exists()) {
			return project;
		}
	}
	return null;
}