• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JavaElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getUnresolvedJavaElement

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
/** Returns the IInitializer that contains the given local variable in the given type */
public static JavaElement getUnresolvedJavaElement(
    int localSourceStart, int localSourceEnd, JavaElement type) {
  try {
    if (!(type instanceof IType)) return null;
    IInitializer[] initializers = ((IType) type).getInitializers();
    for (int i = 0; i < initializers.length; i++) {
      IInitializer initializer = initializers[i];
      ISourceRange sourceRange = initializer.getSourceRange();
      if (sourceRange != null) {
        int initializerStart = sourceRange.getOffset();
        int initializerEnd = initializerStart + sourceRange.getLength();
        if (initializerStart <= localSourceStart && localSourceEnd <= initializerEnd) {
          return (JavaElement) initializer;
        }
      }
    }
    return null;
  } catch (JavaModelException e) {
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:Util.java


示例2: newMethodReferenceMatch

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
public MethodReferenceMatch newMethodReferenceMatch(
		IJavaElement enclosingElement,
		Binding enclosingBinding,
		int accuracy,
		int offset,
		int length,
		boolean isConstructor,
		boolean isSynthetic,
		ASTNode reference) {
	SearchParticipant participant = getParticipant();
	IResource resource = this.currentPossibleMatch.resource;
	boolean insideDocComment = (reference.bits & ASTNode.InsideJavadoc) != 0;
	if (enclosingBinding != null)
		enclosingElement = ((JavaElement) enclosingElement).resolved(enclosingBinding);
	boolean isOverridden = (accuracy & PatternLocator.SUPER_INVOCATION_FLAVOR) != 0;
	return new MethodReferenceMatch(enclosingElement, accuracy, offset, length, isConstructor, isSynthetic, isOverridden, insideDocComment, participant, resource);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:MatchLocator.java


示例3: toString

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
public String toString() {
	StringBuffer buffer = new StringBuffer();
	buffer.append("Search match"); //$NON-NLS-1$
	buffer.append("\n  accuracy="); //$NON-NLS-1$
	buffer.append(this.accuracy == A_ACCURATE ? "ACCURATE" : "INACCURATE"); //$NON-NLS-1$ //$NON-NLS-2$
	buffer.append("\n  rule="); //$NON-NLS-1$
	if ((this.rule & SearchPattern.R_FULL_MATCH) != 0) {
		buffer.append("EXACT"); //$NON-NLS-1$
	} else if ((this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0) {
		buffer.append("EQUIVALENT"); //$NON-NLS-1$
	} else if ((this.rule & SearchPattern.R_ERASURE_MATCH) != 0) {
		buffer.append("ERASURE"); //$NON-NLS-1$
	}
	buffer.append("\n  raw="); //$NON-NLS-1$
	buffer.append(this.raw);
	buffer.append("\n  offset="); //$NON-NLS-1$
	buffer.append(this.offset);
	buffer.append("\n  length="); //$NON-NLS-1$
	buffer.append(this.length);
	if (this.element != null) {
		buffer.append("\n  element="); //$NON-NLS-1$
		buffer.append(((JavaElement)getElement()).toStringWithAncestors());
	}
	buffer.append("\n"); //$NON-NLS-1$
	return buffer.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:SearchMatch.java


示例4: addChange

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
private void addChange(IMember member, IJavaElementDelta newDelta) throws JavaModelException {
	int newKind = newDelta.getKind();
	switch (newKind) {
		case IJavaElementDelta.ADDED:
			ArrayList allTypes = new ArrayList();
			getAllTypesFromElement(member, allTypes);
			for (int i = 0, length = allTypes.size(); i < length; i++) {
				IType innerType = (IType)allTypes.get(i);
				addTypeAddition(innerType, (SimpleDelta)this.changes.get(innerType));
			}
			break;
		case IJavaElementDelta.REMOVED:
			allTypes = new ArrayList();
			getAllTypesFromHierarchy((JavaElement)member, allTypes);
			for (int i = 0, length = allTypes.size(); i < length; i++) {
				IType type = (IType)allTypes.get(i);
				addTypeRemoval(type, (SimpleDelta)this.changes.get(type));
			}
			break;
		case IJavaElementDelta.CHANGED:
			addAffectedChildren(newDelta);
			break;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:ChangeCollector.java


示例5: getAllTypesFromHierarchy

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
private void getAllTypesFromHierarchy(JavaElement element, ArrayList allTypes) {
	switch (element.getElementType()) {
		case IJavaElement.COMPILATION_UNIT:
			ArrayList types = (ArrayList)this.hierarchy.files.get(element);
			if (types != null) {
				allTypes.addAll(types);
			}
			break;
		case IJavaElement.TYPE:
		case IJavaElement.INITIALIZER:
		case IJavaElement.FIELD:
		case IJavaElement.METHOD:
			types = (ArrayList)this.hierarchy.files.get(((IMember)element).getCompilationUnit());
			if (types != null) {
				for (int i = 0, length = types.size(); i < length; i++) {
					IType type = (IType)types.get(i);
					if (element.isAncestorOf(type)) {
						allTypes.add(type);
					}
				}
			}
			break;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:ChangeCollector.java


示例6: initializeRegions

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected void initializeRegions() {
	super.initializeRegions();
	IJavaElement[] roots = this.region.getElements();
	for (int i = 0; i < roots.length; i++) {
		IJavaElement root = roots[i];
		if (root instanceof IOpenable) {
			this.files.put(root, new ArrayList());
		} else {
			Openable o = (Openable) ((JavaElement) root).getOpenableParent();
			if (o != null) {
				this.files.put(o, new ArrayList());
			}
		}
		checkCanceled();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:RegionBasedTypeHierarchy.java


示例7: getUnresolvedJavaElement

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
/**
 * Returns the IInitializer that contains the given local variable in the given type
 */
public static JavaElement getUnresolvedJavaElement(int localSourceStart, int localSourceEnd, JavaElement type) {
	try {
		if (!(type instanceof IType))
			return null;
		IInitializer[] initializers = ((IType) type).getInitializers();
		for (int i = 0; i < initializers.length; i++) {
			IInitializer initializer = initializers[i];
			ISourceRange sourceRange = initializer.getSourceRange();
			if (sourceRange != null) {
				int initializerStart = sourceRange.getOffset();
				int initializerEnd = initializerStart + sourceRange.getLength();
				if (initializerStart <= localSourceStart && localSourceEnd <= initializerEnd) {
					return (JavaElement) initializer;
				}
			}
		}
		return null;
	} catch (JavaModelException e) {
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:Util.java


示例8: getJavaElement

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
public IJavaElement getJavaElement() {
	JavaElement element = getUnresolvedJavaElement();
	if (element != null)
		return element.resolved(this.binding);
	if (isRecovered()) {
		IPackageBinding packageBinding = getPackage();
		if (packageBinding != null) {
			final IJavaElement javaElement = packageBinding.getJavaElement();
			if (javaElement != null && javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
				// best effort: we don't know if the recovered binding is a binary or source binding, so go with a simple source type
				return ((PackageFragment) javaElement).getCompilationUnit(new String(this.binding.sourceName()) + SuffixConstants.SUFFIX_STRING_java).getType(this.getName());
			}
		}
		return null;
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:TypeBinding.java


示例9: assertElementsEqual

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected void assertElementsEqual(String message, String expected, IJavaElement[] elements, boolean showResolvedInfo) {
	StringBuffer buffer = new StringBuffer();
	if (elements != null) {
		for (int i = 0, length = elements.length; i < length; i++){
			JavaElement element = (JavaElement)elements[i];
			if (element == null) {
				buffer.append("<null>");
			} else {
				buffer.append(element.toStringWithAncestors(showResolvedInfo));
			}
			if (i != length-1) buffer.append("\n");
		}
	} else {
		buffer.append("<null>");
	}
	String actual = buffer.toString();
	if (!expected.equals(actual)) {
		if (this.displayName) System.out.println(getName()+" actual result is:");
		System.out.println(displayString(actual, this.tabs) + this.endChar);
	}
	assertEquals(message, expected, actual);
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:23,代码来源:AbstractJavaModelTests.java


示例10: sortElements

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected void sortElements(IJavaElement[] elements) {
	Util.Comparer comparer = new Util.Comparer() {
		public int compare(Object a, Object b) {
			JavaElement elementA = (JavaElement)a;
			JavaElement elementB = (JavaElement)b;
			char[] tempJCLPath = "<externalJCLPath>".toCharArray();
    		String idA = new String(CharOperation.replace(
    			elementA.toStringWithAncestors().toCharArray(),
    			getExternalJCLPathString().toCharArray(),
    			tempJCLPath));
    		String idB = new String(CharOperation.replace(
    			elementB.toStringWithAncestors().toCharArray(),
    			getExternalJCLPathString().toCharArray(),
    			tempJCLPath));
			return idA.compareTo(idB);
		}
	};
	Util.sort(elements, comparer);
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:20,代码来源:AbstractJavaModelTests.java


示例11: shortDescription

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
private String shortDescription(String javadoc) throws Exception {
	IMember member = mock(IMember.class);
	IOpenable openable = (IOpenable)mock(JavaElement.class, withSettings().extraInterfaces(IOpenable.class));
	when(member.getOpenable()).thenReturn(openable);
	IBuffer buffer = BufferManager.createBuffer(openable);
	buffer.setContents(javadoc);
	when(openable.getBuffer()).thenReturn(buffer);
	when(member.getJavadocRange()).thenReturn(new SourceRange(0, javadoc.length()));
	return javadocCommentProvider.getJavadocCommentShortDescription(member);
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:11,代码来源:JavadocCommentProviderTest.java


示例12: getAnnotation

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
public static IAnnotation getAnnotation(
    JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) {
  char[] typeName =
      org.eclipse.jdt.core.Signature.toCharArray(
          CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.'));
  return new Annotation(parent, new String(typeName), memberValuePairName);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:Util.java


示例13: getJavaElement

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
private JavaElement getJavaElement(LocalVariableBinding binding) {
	LocalDeclaration local = binding.declaration;

	JavaElement parent = null;
	ReferenceContext referenceContext = binding.declaringScope.referenceContext();
	if (referenceContext instanceof AbstractMethodDeclaration) {
		AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext;
		parent = this.getJavaElementOfCompilationUnit(methodDeclaration, methodDeclaration.binding);
	} else if (referenceContext instanceof TypeDeclaration){
		// Local variable is declared inside an initializer
		TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext;

		JavaElement type = this.getJavaElementOfCompilationUnit(typeDeclaration, typeDeclaration.binding);
		parent = Util.getUnresolvedJavaElement(local.sourceStart, local.sourceEnd, type);
	}
	if (parent == null) return null;

	return new LocalVariable(
			parent,
			new String(local.name),
			local.declarationSourceStart,
			local.declarationSourceEnd,
			local.sourceStart,
			local.sourceEnd,
			Util.typeSignature(local.type),
			binding.declaration.annotations,
			local.modifiers,
			local.getKind() == AbstractVariableDeclaration.PARAMETER);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:InternalExtendedCompletionContext.java


示例14: getJavaElementOfCompilationUnit

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
private JavaElement getJavaElementOfCompilationUnit(Binding binding) {
	if (!this.hasComputedEnclosingJavaElements) {
		computeEnclosingJavaElements();
	}
	if (this.bindingsToHandles == null) return null;
	return (JavaElement)this.bindingsToHandles.get(binding);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:InternalExtendedCompletionContext.java


示例15: createField

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected SourceField createField(JavaElement parent, FieldInfo fieldInfo) {
	String fieldName = JavaModelManager.getJavaModelManager().intern(new String(fieldInfo.name));
	AssistSourceField field = new AssistSourceField(parent, fieldName, this.bindingCache, this.newElements);
	if (fieldInfo.node.binding != null) {
		this.bindingCache.put(field, fieldInfo.node.binding);
		this.elementCache.put(fieldInfo.node.binding, field);
	} else {
		this.elementWithProblemCache.put(fieldInfo.node, field);
	}
	return field;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:CompletionUnitStructureRequestor.java


示例16: createMethodHandle

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected SourceMethod createMethodHandle(JavaElement parent, MethodInfo methodInfo) {
	String selector = JavaModelManager.getJavaModelManager().intern(new String(methodInfo.name));
	String[] parameterTypeSigs = convertTypeNamesToSigs(methodInfo.parameterTypes);
	AssistSourceMethod method = new AssistSourceMethod(parent, selector, parameterTypeSigs, this.bindingCache, this.newElements);
	if (methodInfo.node.binding != null) {
		this.bindingCache.put(method, methodInfo.node.binding);
		this.elementCache.put(methodInfo.node.binding, method);
	} else {
		this.elementWithProblemCache.put(methodInfo.node, method);
	}
	return method;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:CompletionUnitStructureRequestor.java


示例17: createTypeHandle

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected SourceType createTypeHandle(JavaElement parent, TypeInfo typeInfo) {
	String nameString= new String(typeInfo.name);
	AssistSourceType type = new AssistSourceType(parent, nameString, this.bindingCache, this.newElements);
	if (typeInfo.node.binding != null) {
		this.bindingCache.put(type, typeInfo.node.binding);
		this.elementCache.put(typeInfo.node.binding, type);
	} else {
		this.elementWithProblemCache.put(typeInfo.node, type);
	}
	return type;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:CompletionUnitStructureRequestor.java


示例18: acceptAnnotation

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
protected IAnnotation acceptAnnotation(
		org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
		AnnotatableInfo parentInfo,
		JavaElement parentHandle) {
	if (annotation instanceof CompletionOnMarkerAnnotationName) {
		if (hasEmptyName(annotation.type, this.assistNode)) {
			super.acceptAnnotation(annotation, null, parentHandle);
			return null;
		}
	}
	return super.acceptAnnotation(annotation, parentInfo, parentHandle);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:CompletionUnitStructureRequestor.java


示例19: createHandle

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
/**
 * Creates an IMethod from the given lambda declaration and type.
 */
protected IJavaElement createHandle(LambdaExpression lambdaExpression, IJavaElement parent) {
	org.eclipse.jdt.internal.core.LambdaExpression lambdaElement = LambdaFactory.createLambdaExpression((JavaElement) parent, lambdaExpression);
	IMethod lambdaMethodElement = lambdaElement.getMethod();
	this.methodHandles.add(lambdaMethodElement);
	return lambdaMethodElement;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:MatchLocator.java


示例20: newDeclarationMatch

import org.eclipse.jdt.internal.core.JavaElement; //导入依赖的package包/类
public SearchMatch newDeclarationMatch(
		IJavaElement element,
		Binding binding,
		int accuracy,
		int offset,
		int length,
		SearchParticipant participant,
		IResource resource) {
	switch (element.getElementType()) {
		case IJavaElement.PACKAGE_FRAGMENT:
			return new PackageDeclarationMatch(element, accuracy, offset, length, participant, resource);
		case IJavaElement.TYPE:
			return new TypeDeclarationMatch(binding == null ? element : ((JavaElement) element).resolved(binding), accuracy, offset, length, participant, resource);
		case IJavaElement.FIELD:
			return new FieldDeclarationMatch(binding == null ? element : ((JavaElement) element).resolved(binding), accuracy, offset, length, participant, resource);
		case IJavaElement.METHOD:
			return new MethodDeclarationMatch(binding == null ? element : ((JavaElement) element).resolved(binding), accuracy, offset, length, participant, resource);
		case IJavaElement.LOCAL_VARIABLE:
			return new LocalVariableDeclarationMatch(element, accuracy, offset, length, participant, resource);
		case IJavaElement.PACKAGE_DECLARATION:
			return new PackageDeclarationMatch(element, accuracy, offset, length, participant, resource);
		case IJavaElement.TYPE_PARAMETER:
			return new TypeParameterDeclarationMatch(element, accuracy, offset, length, participant, resource);
		default:
			return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:MatchLocator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FieldMap类代码示例发布时间:2022-05-22
下一篇:
Java ModifiableFacetModel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap