当前位置: 首页>>代码示例>>Java>>正文


Java IJavaVariable类代码示例

本文整理汇总了Java中org.eclipse.jdt.debug.core.IJavaVariable的典型用法代码示例。如果您正苦于以下问题:Java IJavaVariable类的具体用法?Java IJavaVariable怎么用?Java IJavaVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IJavaVariable类属于org.eclipse.jdt.debug.core包,在下文中一共展示了IJavaVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleVariables

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
private void handleVariables() throws DebugException {
	handleOutOfScopeVars();

	for(IVariable v : frame.getVariables()) {
		IJavaVariable jv = (IJavaVariable) v;
		String varName = v.getName();
		if(varName.equals("this")) {
			for (IVariable iv : jv.getValue().getVariables()) {
				IJavaVariable att = (IJavaVariable) iv;
				if(!att.isSynthetic() && !att.isStatic()) {
					handleVar(att, true);
				}
			}
		}

		else if(!jv.isSynthetic()) {
			handleVar(jv, false);
		}
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:21,代码来源:StackFrameModel.java

示例2: VariableModel

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public VariableModel(IJavaVariable variable, boolean isInstance, boolean isVisible, RuntimeModel runtime) throws DebugException {
	super(runtime);
	assert variable != null;

	T val = (T) variable.getValue();
	this.variable = variable;
	this.name = variable.getName();
	
	if(!((IJavaValue) val).isNull())
		this.type = variable.getReferenceTypeName();
	this.isInstance = isInstance; // !variable.isLocal() ?
	this.isVisible = isVisible;
	this.isStatic = variable.isStatic();
	history = new ArrayList<>();
	StepValue sv = new StepValue(val, runtime.getRunningStep());
	history.add(sv);
	stepPointer = 0;
	this.stepInit = runtime.getRunningStep();
	this.scopeEnd = Integer.MAX_VALUE;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:22,代码来源:VariableModel.java

示例3: visit

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
@Override
public boolean visit(SimpleName node) {
	try {
		if (parentIsName(node))
			return true;  // Ignore names.
		IJavaVariable var = stack.findVariable(node.getIdentifier());
		if (var != null) {
			preVariables.add(node.getIdentifier());
			/*preNodeValues.put(node.getID(), (IJavaValue)var.getValue());
			node.setStaticType(var.getJavaType());*/
		}
	} catch (DebugException e) {
		throw new RuntimeException(e);
	}
	return true;
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:17,代码来源:StateProperty.java

示例4: getTypeOfVariableAndLoadIfNeeded

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
/**
   * Gets the type of a variable, loading it if necessary.
   * @param var The variable whose type to get.
   * @param stack The current stack frame.
   * @return The type of the given variable.
   */
  public static IJavaType getTypeOfVariableAndLoadIfNeeded(IJavaVariable var, IJavaStackFrame stack) {
  	try {
	return var.getJavaType();
} catch (DebugException e1) {
	try {
		loadClassSlow(var.getReferenceTypeName(), stack);
		return var.getJavaType();
	} catch (DebugException e2) {
		try {
			loadClassSlow(var.getSignature().substring(1, var.getSignature().length() - 1).replace("/", "."), stack);
			return var.getJavaType();
		} catch (DebugException e3) {
			throw new RuntimeException(e1);
		}
	}
}
  }
 
开发者ID:jgalenson,项目名称:codehint,代码行数:24,代码来源:EclipseUtils.java

示例5: handle

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
private static void handle(IVariable variable, String path, Shell shell, Matcher matcher, IJavaStackFrame stack) throws DebugException {
IJavaType varType = EclipseUtils.getTypeOfVariableAndLoadIfNeeded((IJavaVariable)variable, stack);
String varTypeName = EclipseUtils.sanitizeTypename(varType.getName());
String initValue = "";
if (matcher != null) {
	if (!matcher.group(2).equals(variable.getName())) {
		EclipseUtils.showError("Illegal variable.", "The first argument to the pdspec method, " + matcher.group(2) + ", must be the same as the variable on which you right-clicked, " + variable.getName() + ".", null);
		return;
	}
	initValue = matcher.group(1);
	if (initValue == null)
		initValue = varTypeName;
} else
	initValue = varTypeName;
InitialSynthesisDialog dialog = new InitialSynthesisDialog(shell, varTypeName, varType, stack, new TypePropertyDialog(path, varTypeName, stack, initValue, null), new SynthesisWorker(path, varType));
  	Synthesizer.synthesizeAndInsertStatements(variable, path, dialog, stack, matcher != null);
  }
 
开发者ID:jgalenson,项目名称:codehint,代码行数:18,代码来源:DemonstrateTypeHandler.java

示例6: handle

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
private static void handle(IVariable variable, String path, Shell shell, Matcher matcher, IJavaStackFrame stack) throws DebugException {
String initValue = null;
if (matcher != null) {
	if (!matcher.group(1).equals(variable.getName())) {
		EclipseUtils.showError("Illegal variable.", "The first argument to the value method, " + matcher.group(1) + ", must be the same as the variable on which you right-clicked, " + variable.getName() + ".", null);
		return;
	}
	initValue = matcher.group(2);
} else
	initValue = "";
IJavaType varType = EclipseUtils.getTypeOfVariableAndLoadIfNeeded((IJavaVariable)variable, stack);
String varTypeName = EclipseUtils.sanitizeTypename(varType.getName());
PropertyDialog propertyDialog = null;
if (EclipseUtils.isObject(variable))
	propertyDialog = new ObjectValuePropertyDialog(path, varTypeName, stack, initValue, null);
else if (EclipseUtils.isArray(variable))
	propertyDialog = new ArrayValuePropertyDialog(path, varTypeName, stack, initValue, null);
else
	propertyDialog = new PrimitiveValuePropertyDialog(path, varTypeName, stack, initValue, null);
InitialSynthesisDialog dialog = new InitialSynthesisDialog(shell, varTypeName, varType, stack, propertyDialog, new SynthesisWorker(path, varType));
Synthesizer.synthesizeAndInsertStatements(variable, path, dialog, stack, initValue.length() > 0);
  }
 
开发者ID:jgalenson,项目名称:codehint,代码行数:23,代码来源:DemonstrateValueHandler.java

示例7: addSeeds

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
/**
 * Adds locals, constants, and imports to seed the search.
 * @param typeConstraint The type constraint.
 * @throws DebugException
 * @throws JavaModelException
 */
private void addSeeds(TypeConstraint typeConstraint) throws DebugException, JavaModelException {
	for (IJavaVariable l : stack.getLocalVariables())
		candidates.addWeighted(expressionMaker.makeVar(l.getName(), (IJavaValue)l.getValue(), EclipseUtils.getTypeOfVariableAndLoadIfNeeded(l, stack), thread));
	if (!stack.isStatic())
		objects.addWeighted(expressionMaker.makeThis(stack.getThis(), thisType, thread));
	if (!(typeConstraint instanceof MethodConstraint) && !(typeConstraint instanceof FieldConstraint))  // If we have a method or field constraint, we can't have null.)
		nulls.addWeighted(expressionMaker.makeNull(thread));
	if (stack.isStatic() || stack.isConstructor())
		names.addWeighted(expressionMaker.makeStaticName(stack.getReceivingTypeName(), thisType, thread));
	for (IImportDeclaration imp : imports) {
		// TODO: Handle static imports.
		// TODO: Decomp with deterministic version?
		if (!imp.isOnDemand()) {
			String fullName = imp.getElementName();
			String shortName = EclipseUtils.getUnqualifiedName(fullName);  // Use the unqualified typename for brevity.
			if (!Flags.isStatic(imp.getFlags())) {
				IJavaReferenceType importedType = (IJavaReferenceType)EclipseUtils.getTypeAndLoadIfNeeded(fullName, stack, target, typeCache);
				if (importedType != null) {
					if (hasPublicStaticFieldOrMethod(importedType))
						names.addWeighted(expressionMaker.makeStaticName(shortName, importedType, thread));
				}
			}
		}
	}
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:32,代码来源:StochasticExpressionGenerator.java

示例8: createVar

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
private IVariableModel<?> createVar(IJavaVariable jv, boolean isInstance, IJavaValue value)
		throws DebugException {
	String varName = jv.getName();
	boolean isField = !jv.isLocal();
	VariableInfo info = varParser != null ? varParser.locateVariable(varName, frame.getLineNumber(), isField) : null;
	//		System.out.println(frame.getDeclaringTypeName() + " -- " +  frame.getMethodName() + " " + (jv.isStatic() ? "static " : "") + varName + ": " + info);
	IVariableModel<?> newVar = value instanceof IJavaObject ?
		new ReferenceModel(jv, isInstance, true, info, this) :
		new ValueModel(jv, isInstance, true, info, this);
	
	Collection<String> tags = ParserManager.getTags(srcFile, jv.getName(), frame.getLineNumber(), isField);
	newVar.setTags(tags);
	return newVar;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:15,代码来源:StackFrameModel.java

示例9: calcString

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
private String calcString() {
	try {
		IJavaVariable[] localVariables = frame.getLocalVariables();
		int nArgs = frame.getArgumentTypeNames().size();
		List<String> args = new ArrayList<>(localVariables.length);
		for(int i = 0; i < localVariables.length && i < nArgs ; i++) {
			if(PrimitiveType.isPrimitive(localVariables[i].getReferenceTypeName())) {
				IJavaValue value = (IJavaValue) localVariables[i].getValue();
				args.add(valueToString(value));
			}
			else
				args.add(localVariables[i].getName());
		}

		if(frame.isStaticInitializer())
			return frame.getDeclaringTypeName() + " (static initializer)";
		else if(frame.isConstructor())
			return "new " + toSimpleName(frame.getReferenceType().getName()) + "(" + String.join(", ", args) + ")";
		else {
			String ret = frame.getMethodName() + "(" + String.join(", ", args) + ")";
			if(returnValue != null)
				ret += " = " + returnValue;
			return ret;
		}
	} catch (DebugException e) {
		//			e.printStackTrace();
		return super.toString();
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:30,代码来源:StackFrameModel.java

示例10: initArray

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
private void initArray(IJavaArray array, int length) throws DebugException {
	for(int i = 0; i < length - 1; i++)
		elementsModel.add(createElement((IJavaVariable) array.getVariable(i), i));

	if(length > 0)
		elementsModel.add(createElement((IJavaVariable) array.getVariable(array.getLength()-1), array.getLength()-1));
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:8,代码来源:ArrayModel.java

示例11: getTooltip

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
static String getTooltip(IVariableModel<?> model) {
	IJavaVariable javaVariable = model.getJavaVariable();
	String owner = null;
	if(javaVariable instanceof IJavaFieldVariable)
		try {
			owner = ((IJavaFieldVariable) javaVariable).getDeclaringType().getName();
		} catch (DebugException e) { }
	String tooltip = model.isStatic() ? "static field" : (owner == null ? "local variable" : "field");
	
	if(model.isStatic() && owner != null)
		tooltip += " of " + owner;
	
	tooltip += " (" + model.getTypeName() + ")";
	return tooltip;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:16,代码来源:Utils.java

示例12: getDetailPaneTypes

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
@Override
public Set<String> getDetailPaneTypes(IStructuredSelection selection) {
	IJavaVariable var = (IJavaVariable) selection.getFirstElement();
	Set<String> panes = new HashSet<String>();
	try {
		if (var.getJavaType().getName().equals(FImage.class.getName())) {
			panes.add(ImageDetailPane.ID);
		}
	} catch (DebugException e) {
		e.printStackTrace();
	}
	
	return panes;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:15,代码来源:ImageDetailPaneFactory.java

示例13: display

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
@Override
public void display(IStructuredSelection arg0) {
	if (arg0 == null || arg0.getFirstElement() == null) return;
	
	try {
		IJavaObject var = (IJavaObject) ((IJavaVariable) arg0.getFirstElement()).getValue();
		
		org.openimaj.image.Image<?, ?> img = readImage(var);
		ImageData imageData = convertToSWT(ImageUtilities.createBufferedImage(img));
		
		label.setImage(new Image(label.getDisplay(), imageData));
	} catch (DebugException e) {
		e.printStackTrace();
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:16,代码来源:ImageDetailPane.java

示例14: generateWatchExpression

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
/**
 * Generate a Java expression that represents the selection.
 * 
 * e.g. if we selected the "foo" field of the 3rd object in an array called
 * "bar" inside an object called "baz", build "baz.bar[2].foo"
 * 
 * @param treePath
 *            the selection {@link TreePath} object
 * @return a Java expression that represents the selection
 * @throws DebugException
 */
private String generateWatchExpression(TreePath treePath) throws DebugException {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < treePath.getSegmentCount(); i++) {
        Object part = treePath.getSegment(i);
        if (part instanceof IJavaFieldVariable) {
            sb.append('.');
            sb.append(((IJavaFieldVariable) part).getName());
        } else if (part instanceof IJavaVariable) {
            sb.append(((IJavaVariable) part).getName());
        }
    }
    return sb.toString();
}
 
开发者ID:danielrozenberg,项目名称:vebugger,代码行数:25,代码来源:VisualDetailPane.java

示例15: getSignature

import org.eclipse.jdt.debug.core.IJavaVariable; //导入依赖的package包/类
/**
* Gets the Java signature of the given variable.
* @param variable The variable.
* @return The signature of the given variable.
*/
  public static String getSignature(IVariable variable) {
  	try {
       IJavaVariable javaVariable = (IJavaVariable)variable.getAdapter(IJavaVariable.class);
       return javaVariable.getSignature();
} catch (DebugException e) {
	throw new RuntimeException(e);
}
  }
 
开发者ID:jgalenson,项目名称:codehint,代码行数:14,代码来源:EclipseUtils.java


注:本文中的org.eclipse.jdt.debug.core.IJavaVariable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。