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


Java ILocalVariable类代码示例

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


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

示例1: getNameRange

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
private static ISourceRange getNameRange(IJavaElement element) throws JavaModelException {
	ISourceRange nameRange = null;
	if (element instanceof IMember) {
		IMember member = (IMember) element;
		nameRange = member.getNameRange();
		if ( (!SourceRange.isAvailable(nameRange))) {
			nameRange = member.getSourceRange();
		}
	} else if (element instanceof ITypeParameter || element instanceof ILocalVariable) {
		nameRange = ((ISourceReference) element).getNameRange();
	} else if (element instanceof ISourceReference) {
		nameRange = ((ISourceReference) element).getSourceRange();
	}
	if (!SourceRange.isAvailable(nameRange) && element.getParent() != null) {
		nameRange = getNameRange(element.getParent());
	}
	return nameRange;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:JDTUtils.java

示例2: appendLocalVariableLabel

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
/**
 * Appends the styled label for a local variable.
 *
 * @param localVariable the element to render
 * @param flags the rendering flags. Flags with names starting with 'F_' are considered.
 */
public void appendLocalVariableLabel(ILocalVariable localVariable, long flags) {
	if (getFlag(flags, JavaElementLabels.F_PRE_TYPE_SIGNATURE)) {
		appendTypeSignatureLabel(localVariable, localVariable.getTypeSignature(), flags);
		fBuilder.append(' ');
	}

	if (getFlag(flags, JavaElementLabels.F_FULLY_QUALIFIED)) {
		appendElementLabel(localVariable.getDeclaringMember(), JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
		fBuilder.append('.');
	}

	fBuilder.append(getElementName(localVariable));

	if (getFlag(flags, JavaElementLabels.F_APP_TYPE_SIGNATURE)) {
		fBuilder.append(JavaElementLabels.DECL_STRING);
		appendTypeSignatureLabel(localVariable, localVariable.getTypeSignature(), flags);
	}

	// post qualification
	if (getFlag(flags, JavaElementLabels.F_POST_QUALIFIED)) {
		fBuilder.append(JavaElementLabels.CONCAT_STRING);
		appendElementLabel(localVariable.getDeclaringMember(), JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:31,代码来源:JavaElementLabelComposer.java

示例3: isAvailable

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
private static boolean isAvailable(IJavaElement javaElement) throws JavaModelException {
	if (javaElement == null) {
		return false;
	}
	if (!javaElement.exists()) {
		return false;
	}
	if (javaElement.isReadOnly()) {
		return false;
	}
	// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=48422
	// the Java project is now cheating regarding its children so we shouldn't
	// call isStructureKnown if the project isn't open.
	// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=52474
	if (!(javaElement instanceof IJavaProject) && !(javaElement instanceof ILocalVariable) && !javaElement.isStructureKnown()) {
		return false;
	}
	if (javaElement instanceof IMember && ((IMember) javaElement).isBinary()) {
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:GetterSetterCorrectionSubProcessor.java

示例4: parameterListMatches

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
private static boolean parameterListMatches(ILocalVariable[] parameters, IMethod method,
		ILocalVariable[] sourceParameters, IMethod sourceMethod) throws JavaModelException {
	if (parameters.length == sourceParameters.length) {
		for (int i = 0; i < parameters.length; i++) {
			String paramString = Util.getQualifiedNameFromTypeSignature(parameters[i].getTypeSignature(),
					method.getDeclaringType());
			String sourceParamString = Util.getQualifiedNameFromTypeSignature(
					sourceParameters[i].getTypeSignature(), sourceMethod.getDeclaringType());

			if (!paramString.equals(sourceParamString))
				return false;
		}
		return true;
	} else
		return false;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:17,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例5: createParamList

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
public static String createParamList(IMethod method, boolean withParamTypes)
		throws JavaModelException {
	StringBuilder params = new StringBuilder();
	String comma = "";
	for (ILocalVariable variable : method.getParameters()) {
		params.append(comma);
		comma = ", ";

		if (withParamTypes) {
			params.append(
					Signature.getSignatureSimpleName(variable
							.getTypeSignature())).append(" ");
		}

		params.append(variable.getElementName());
	}

	return params.toString();
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:20,代码来源:JDTUtils.java

示例6: getMethodParametersAsString

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
private String getMethodParametersAsString(IMethod method) throws JavaModelException {
  ILocalVariable[] parameters = method.getParameters();

  int paramsLength = parameters.length;
  int index = 0;

  StringBuffer buffer = new StringBuffer();

  for (ILocalVariable parameter : parameters) {
    JavaElementLabels.getLocalVariableLabel(
        parameter, JavaElementLabels.F_PRE_TYPE_SIGNATURE, buffer);
    index++;

    if (index < paramsLength) {
      buffer.append(", ");
    }
  }

  return buffer.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ParametersHints.java

示例7: createRenameSupport

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
private static RenameSupport createRenameSupport(IJavaElement element, String newName, int flags)
    throws CoreException {
  switch (element.getElementType()) {
    case IJavaElement.PACKAGE_FRAGMENT:
      return RenameSupport.create((IPackageFragment) element, newName, flags);
    case IJavaElement.COMPILATION_UNIT:
      return RenameSupport.create((ICompilationUnit) element, newName, flags);
    case IJavaElement.TYPE:
      return RenameSupport.create((IType) element, newName, flags);
    case IJavaElement.METHOD:
      final IMethod method = (IMethod) element;
      if (method.isConstructor())
        return createRenameSupport(method.getDeclaringType(), newName, flags);
      else return RenameSupport.create((IMethod) element, newName, flags);
    case IJavaElement.FIELD:
      return RenameSupport.create((IField) element, newName, flags);
    case IJavaElement.TYPE_PARAMETER:
      return RenameSupport.create((ITypeParameter) element, newName, flags);
    case IJavaElement.LOCAL_VARIABLE:
      return RenameSupport.create((ILocalVariable) element, newName, flags);
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:RefactoringManager.java

示例8: isGeneralizeTypeAvailable

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final IJavaElement element)
    throws JavaModelException {
  if (element != null && element.exists()) {
    String type = null;
    if (element instanceof IMethod) type = ((IMethod) element).getReturnType();
    else if (element instanceof IField) {
      final IField field = (IField) element;
      if (JdtFlags.isEnum(field)) return false;
      type = field.getTypeSignature();
    } else if (element instanceof ILocalVariable) return true;
    else if (element instanceof IType) {
      final IType clazz = (IType) element;
      if (JdtFlags.isEnum(clazz)) return false;
      return true;
    }
    if (type == null || PrimitiveType.toCode(Signature.toString(type)) != null) return false;
    return true;
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RefactoringAvailabilityTester.java

示例9: appendLocalVariableLabel

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
/**
 * Appends the styled label for a local variable.
 *
 * @param localVariable the element to render
 * @param flags the rendering flags. Flags with names starting with 'F_' are considered.
 */
public void appendLocalVariableLabel(ILocalVariable localVariable, long flags) {
	if (getFlag(flags, F_PRE_TYPE_SIGNATURE)) {
		appendTypeSignatureLabel(localVariable, localVariable.getTypeSignature(), flags);
		fBuffer.append(' ');
	}

	if (getFlag(flags, F_FULLY_QUALIFIED)) {
		appendElementLabel(localVariable.getDeclaringMember(), M_PARAMETER_TYPES | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
		fBuffer.append('.');
	}

	fBuffer.append(getElementName(localVariable));

	if (getFlag(flags, F_APP_TYPE_SIGNATURE)) {
		int offset= fBuffer.length();
		fBuffer.append(DECL_STRING);
		appendTypeSignatureLabel(localVariable, localVariable.getTypeSignature(), flags);
	}

	// post qualification
	if (getFlag(flags, F_POST_QUALIFIED)) {
		fBuffer.append(CONCAT_STRING);
		appendElementLabel(localVariable.getDeclaringMember(), M_PARAMETER_TYPES | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:32,代码来源:JavaElementLabelComposer.java

示例10: isGeneralizeTypeAvailable

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final IJavaElement element) throws JavaModelException {
	if (element != null && element.exists()) {
		String type= null;
		if (element instanceof IMethod)
			type= ((IMethod) element).getReturnType();
		else if (element instanceof IField) {
			final IField field= (IField) element;
			if (JdtFlags.isEnum(field))
				return false;
			type= field.getTypeSignature();
		} else if (element instanceof ILocalVariable)
			return true;
		else if (element instanceof IType) {
			final IType clazz= (IType) element;
			if (JdtFlags.isEnum(clazz))
				return false;
			return true;
		}
		if (type == null || PrimitiveType.toCode(Signature.toString(type)) != null)
			return false;
		return true;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:RefactoringAvailabilityTester.java

示例11: isAvailable

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
public static boolean isAvailable(IJavaElement javaElement) throws JavaModelException {
	if (javaElement == null)
		return false;
	if (! javaElement.exists())
		return false;
	if (javaElement.isReadOnly())
		return false;
	// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=48422
	// the Java project is now cheating regarding its children so we shouldn't
	// call isStructureKnown if the project isn't open.
	// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=52474
	if (!(javaElement instanceof IJavaProject) && !(javaElement instanceof ILocalVariable) && !javaElement.isStructureKnown())
		return false;
	if (javaElement instanceof IMember && ((IMember)javaElement).isBinary())
		return false;
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Checks.java

示例12: getHandleMemento

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
public void getHandleMemento(StringBuffer buff, boolean serializeParent) {
	if (serializeParent) {
		((LambdaExpression) getParent()).getHandleMemento(buff, true, false);
	}
	appendEscapedDelimiter(buff, getHandleMementoDelimiter());
	escapeMementoName(buff, getElementName());
	buff.append(JEM_COUNT);
	buff.append(this.parameterTypes.length);
	for (int i = 0, length = this.parameterTypes.length; i < length; i++) {
		appendEscapedDelimiter(buff, JEM_STRING);
		escapeMementoName(buff, this.parameterTypes[i]);
		appendEscapedDelimiter(buff, JEM_STRING);
		escapeMementoName(buff, this.parameterNameStrings[i]);
	}
	appendEscapedDelimiter(buff, JEM_STRING);
	escapeMementoName(buff, this.returnTypeString);
	appendEscapedDelimiter(buff, JEM_STRING);
	escapeMementoName(buff, this.key);
	ILocalVariable[] arguments = this.elementInfo.arguments;
	for (int i = 0, length = arguments.length; i < length; i++) {
		LocalVariable local = (LocalVariable) arguments[i];
		local.getHandleMemento(buff, false);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:LambdaMethod.java

示例13: tokenize

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
/**
 * Tokenizes the supplied {@code IJavaElement} depending on its type.
 * 
 * @param element
 *          the element to tokenize
 * @throws JavaModelException
 *           if there is a failure in the Java model
 */
private void tokenize(final IJavaElement element) throws JavaModelException
{
  switch (element.getElementType())
  {
    case IJavaElement.PACKAGE_FRAGMENT:
      initialize((IPackageFragment) element);
      break;
    case IJavaElement.TYPE:
      initialize((IType) element);
      break;
    case IJavaElement.FIELD:
      initialize((IField) element);
      break;
    case IJavaElement.METHOD:
      initialize((IMethod) element);
      break;
    case IJavaElement.LOCAL_VARIABLE:
      initialize((ILocalVariable) element);
      break;
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:30,代码来源:SelectionTokenizer.java

示例14: createDisplayString

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
/**
 * Creates string to display for the specified method.
 */
protected String createDisplayString(IMethod method) throws JavaModelException {
	StringBuilder sb = new StringBuilder();
	sb.append(method.getElementName()).append("(");
	ILocalVariable[] parameters = method.getParameters();
	if(parameters.length > 0) {
		StringBuilder variables = new StringBuilder();
		for(ILocalVariable variable : parameters) {
			if(variables.length() != 0) {
				variables.append(", ");
			}
			variables.append(
					Signature.toString(variable.getTypeSignature())).append(" ").append(variable.getElementName());
		}
		sb.append(variables);
	}
	sb.append(")");
	if(method.isConstructor()) {
		sb.append(DESC_CONSTRUCTOR);
	} else {
		sb.append(" : ").append(Signature.toString(method.getReturnType()));
	}
	return sb.toString();
}
 
开发者ID:masao-kunii,项目名称:byteman-editor,代码行数:27,代码来源:AbstractBytemanAssistProcessor.java

示例15: computeSignature

import org.eclipse.jdt.core.ILocalVariable; //导入依赖的package包/类
private MarkedString computeSignature(IJavaElement element)  {
	if (element == null) {
		return null;
	}
	String elementLabel = null;
	if (element instanceof ILocalVariable) {
		elementLabel = JavaElementLabels.getElementLabel(element,LOCAL_VARIABLE_FLAGS);
	} else {
		elementLabel = JavaElementLabels.getElementLabel(element,COMMON_SIGNATURE_FLAGS);
	}

	return new MarkedString(LANGUAGE_ID, elementLabel);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:HoverInfoProvider.java


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