本文整理汇总了Java中org.eclipse.jdt.core.IInitializer类的典型用法代码示例。如果您正苦于以下问题:Java IInitializer类的具体用法?Java IInitializer怎么用?Java IInitializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInitializer类属于org.eclipse.jdt.core包,在下文中一共展示了IInitializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getInitializes
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
private List<Initializer> getInitializes(Object parent) throws JavaModelException {
List<Initializer> result = new ArrayList<>();
Set<Object> objects = childrens.get(parent);
if (objects == null) {
return result;
}
for (Object object : objects) {
if (object instanceof IInitializer) {
IInitializer initializer = (IInitializer) object;
Initializer init = DtoFactory.newDto(Initializer.class);
init.setElementName(initializer.getElementName());
init.setHandleIdentifier(initializer.getHandleIdentifier());
init.setFlags(initializer.getFlags());
init.setLabel(
JavaElementLabels.getElementLabel(initializer, JavaElementLabels.ALL_DEFAULT));
result.add(init);
}
}
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JavaElementToDtoConverter.java
示例2: MemberVisibilityAdjustor
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Creates a new java element visibility adjustor.
*
* @param referencing the referencing element used to compute the visibility
* @param referenced the referenced member which causes the visibility changes
*/
public MemberVisibilityAdjustor(final IJavaElement referencing, final IMember referenced) {
Assert.isTrue(!(referenced instanceof IInitializer));
Assert.isTrue(
referencing instanceof ICompilationUnit
|| referencing instanceof IType
|| referencing instanceof IPackageFragment);
fScope =
RefactoringScopeFactory.createReferencedScope(
new IJavaElement[] {referenced},
IJavaSearchScope.REFERENCED_PROJECTS
| IJavaSearchScope.SOURCES
| IJavaSearchScope.APPLICATION_LIBRARIES);
fReferencing = referencing;
fReferenced = referenced;
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:MemberVisibilityAdjustor.java
示例3: getDeclarationNodes
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
public static ASTNode[] getDeclarationNodes(IJavaElement element, CompilationUnit cuNode)
throws JavaModelException {
switch (element.getElementType()) {
case IJavaElement.FIELD:
return new ASTNode[] {getFieldOrEnumConstantDeclaration((IField) element, cuNode)};
case IJavaElement.IMPORT_CONTAINER:
return getImportNodes((IImportContainer) element, cuNode);
case IJavaElement.IMPORT_DECLARATION:
return new ASTNode[] {getImportDeclarationNode((IImportDeclaration) element, cuNode)};
case IJavaElement.INITIALIZER:
return new ASTNode[] {getInitializerNode((IInitializer) element, cuNode)};
case IJavaElement.METHOD:
return new ASTNode[] {
getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) element, cuNode)
};
case IJavaElement.PACKAGE_DECLARATION:
return new ASTNode[] {getPackageDeclarationNode((IPackageDeclaration) element, cuNode)};
case IJavaElement.TYPE:
return new ASTNode[] {getAbstractTypeDeclarationNode((IType) element, cuNode)};
default:
Assert.isTrue(false, String.valueOf(element.getElementType()));
return null;
}
}
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ASTNodeSearchUtil.java
示例4: transplantHandle
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
protected IType transplantHandle(IJavaElement parent, IType element) {
switch (parent.getElementType()) {
case IJavaElement.COMPILATION_UNIT:
return ((ICompilationUnit) parent).getType(element.getElementName());
case IJavaElement.CLASS_FILE:
return ((IClassFile) parent).getType();
case IJavaElement.METHOD:
return ((IMethod) parent).getType(element.getElementName(), element.getOccurrenceCount());
case IJavaElement.FIELD:
return ((IField) parent).getType(element.getElementName(), element.getOccurrenceCount());
case IJavaElement.INITIALIZER:
return ((IInitializer) parent)
.getType(element.getElementName(), element.getOccurrenceCount());
case IJavaElement.TYPE:
return ((IType) parent).getType(element.getElementName(), element.getOccurrenceCount());
default:
throw new IllegalStateException(element.toString());
}
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:GenericRefactoringHandleTransplanter.java
示例5: appendInitializerLabel
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Appends the label for a initializer. Considers the I_* flags.
*
* @param initializer the element to render
* @param flags the rendering flags. Flags with names starting with 'I_' are considered.
*/
public void appendInitializerLabel(IInitializer initializer, long flags) {
// qualification
if (getFlag(flags, JavaElementLabels.I_FULLY_QUALIFIED)) {
appendTypeLabel(
initializer.getDeclaringType(),
JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
fBuffer.append('.');
}
fBuffer.append(JavaUIMessages.JavaElementLabels_initializer);
// post qualification
if (getFlag(flags, JavaElementLabels.I_POST_QUALIFIED)) {
int offset = fBuffer.length();
fBuffer.append(JavaElementLabels.CONCAT_STRING);
appendTypeLabel(
initializer.getDeclaringType(),
JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:JavaElementLabelComposer.java
示例6: getUnresolvedJavaElement
import org.eclipse.jdt.core.IInitializer; //导入依赖的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
示例7: appendInitializerLabel
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Appends the label for a initializer. Considers the I_* flags.
*
* @param initializer the element to render
* @param flags the rendering flags. Flags with names starting with 'I_' are considered.
*/
public void appendInitializerLabel(IInitializer initializer, long flags) {
// qualification
if (getFlag(flags, I_FULLY_QUALIFIED)) {
appendTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
fBuffer.append('.');
}
fBuffer.append("{...}");
// post qualification
if (getFlag(flags, I_POST_QUALIFIED)) {
int offset= fBuffer.length();
fBuffer.append(CONCAT_STRING);
appendTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
}
}
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:22,代码来源:JavaElementLabelComposer.java
示例8: checkMovedMemberAvailability
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
private RefactoringStatus checkMovedMemberAvailability(IMember memberToMove, IProgressMonitor pm) throws JavaModelException{
RefactoringStatus result= new RefactoringStatus();
if (memberToMove instanceof IType) { // recursively check accessibility of member type's members
IJavaElement[] typeMembers= ((IType) memberToMove).getChildren();
pm.beginTask(RefactoringCoreMessages.MoveMembersRefactoring_checking, typeMembers.length + 1);
for (int i= 0; i < typeMembers.length; i++) {
if (typeMembers[i] instanceof IInitializer)
pm.worked(1);
else
result.merge(checkMovedMemberAvailability((IMember) typeMembers[i], new SubProgressMonitor(pm, 1)));
}
} else {
pm.beginTask(RefactoringCoreMessages.MoveMembersRefactoring_checking, 1);
}
IType[] blindAccessorTypes= getTypesNotSeeingMovedMember(memberToMove, new SubProgressMonitor(pm, 1), result);
for (int k= 0; k < blindAccessorTypes.length; k++) {
String message= createNonAccessibleMemberMessage(memberToMove, blindAccessorTypes[k],/*moved*/true);
result.addError(message, JavaStatusContext.create(memberToMove));
}
pm.done();
return result;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:MoveStaticMembersProcessor.java
示例9: getDeclarationNodes
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
public static ASTNode[] getDeclarationNodes(IJavaElement element, CompilationUnit cuNode) throws JavaModelException {
switch(element.getElementType()){
case IJavaElement.FIELD:
return new ASTNode[]{getFieldOrEnumConstantDeclaration((IField) element, cuNode)};
case IJavaElement.IMPORT_CONTAINER:
return getImportNodes((IImportContainer)element, cuNode);
case IJavaElement.IMPORT_DECLARATION:
return new ASTNode[]{getImportDeclarationNode((IImportDeclaration)element, cuNode)};
case IJavaElement.INITIALIZER:
return new ASTNode[]{getInitializerNode((IInitializer)element, cuNode)};
case IJavaElement.METHOD:
return new ASTNode[]{getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) element, cuNode)};
case IJavaElement.PACKAGE_DECLARATION:
return new ASTNode[]{getPackageDeclarationNode((IPackageDeclaration)element, cuNode)};
case IJavaElement.TYPE:
return new ASTNode[]{getAbstractTypeDeclarationNode((IType) element, cuNode)};
default:
Assert.isTrue(false, String.valueOf(element.getElementType()));
return null;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:ASTNodeSearchUtil.java
示例10: transplantHandle
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
protected IType transplantHandle(IJavaElement parent, IType element) {
switch (parent.getElementType()) {
case IJavaElement.COMPILATION_UNIT:
return ((ICompilationUnit) parent).getType(element.getElementName());
case IJavaElement.CLASS_FILE:
return ((IClassFile) parent).getType();
case IJavaElement.METHOD:
return ((IMethod) parent).getType(element.getElementName(), element.getOccurrenceCount());
case IJavaElement.FIELD:
return ((IField) parent).getType(element.getElementName(), element.getOccurrenceCount());
case IJavaElement.INITIALIZER:
return ((IInitializer) parent).getType(element.getElementName(), element.getOccurrenceCount());
case IJavaElement.TYPE:
return ((IType) parent).getType(element.getElementName(), element.getOccurrenceCount());
default:
throw new IllegalStateException(element.toString());
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GenericRefactoringHandleTransplanter.java
示例11: getDestinationNode
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
private ASTNode getDestinationNode(IJavaElement destination, CompilationUnit target) throws JavaModelException {
switch (destination.getElementType()) {
case IJavaElement.INITIALIZER:
return ASTNodeSearchUtil.getInitializerNode((IInitializer) destination, target);
case IJavaElement.FIELD:
return ASTNodeSearchUtil.getFieldOrEnumConstantDeclaration((IField) destination, target);
case IJavaElement.METHOD:
return ASTNodeSearchUtil.getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) destination, target);
case IJavaElement.TYPE:
IType typeDestination= (IType) destination;
if (typeDestination.isAnonymous()) {
return ASTNodeSearchUtil.getClassInstanceCreationNode(typeDestination, target).getAnonymousClassDeclaration();
} else {
return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(typeDestination, target);
}
case IJavaElement.COMPILATION_UNIT:
IType mainType= JavaElementUtil.getMainType((ICompilationUnit) destination);
if (mainType != null) {
return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(mainType, target);
}
//$FALL-THROUGH$
default:
return null;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ReorgPolicyFactory.java
示例12: isPotentialNLSAccessor
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
private static boolean isPotentialNLSAccessor(ICompilationUnit unit) throws JavaModelException {
IType type= unit.getTypes()[0];
if (!type.exists())
return false;
IField bundleNameField= getBundleNameField(type.getFields());
if (bundleNameField == null)
return false;
if (!importsOSGIUtil(unit))
return false;
IInitializer[] initializers= type.getInitializers();
for (int i= 0; i < initializers.length; i++) {
if (Modifier.isStatic(initializers[0].getFlags()))
return true;
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:NLSAccessorFieldRenameParticipant.java
示例13: isPotentialNLSAccessor
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
private static boolean isPotentialNLSAccessor(ICompilationUnit unit) throws JavaModelException {
IType type= unit.getTypes()[0];
if (!type.exists())
return false;
IField bundleNameField= getBundleNameField(type.getFields());
if (bundleNameField == null)
return false;
if (importsOSGIUtil(unit)) { //new school
IInitializer[] initializers= type.getInitializers();
for (int i= 0; i < initializers.length; i++) {
if (Modifier.isStatic(initializers[0].getFlags()))
return true;
}
} else { //old school
IMethod[] methods= type.getMethods();
for (int i= 0; i < methods.length; i++) {
IMethod method= methods[i];
if (isValueAccessor(method))
return true;
}
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:FindBrokenNLSKeysAction.java
示例14: appendInitializerLabel
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Appends the label for a initializer. Considers the I_* flags.
*
* @param initializer the element to render
* @param flags the rendering flags. Flags with names starting with 'I_' are considered.
*/
public void appendInitializerLabel(IInitializer initializer, long flags) {
// qualification
if (getFlag(flags, JavaElementLabels.I_FULLY_QUALIFIED)) {
appendTypeLabel(initializer.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
fBuffer.append('.');
}
fBuffer.append(JavaUIMessages.JavaElementLabels_initializer);
// post qualification
if (getFlag(flags, JavaElementLabels.I_POST_QUALIFIED)) {
int offset= fBuffer.length();
fBuffer.append(JavaElementLabels.CONCAT_STRING);
appendTypeLabel(initializer.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:JavaElementLabelComposer.java
示例15: getMemberFromOffset
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
public static IMember getMemberFromOffset(ITextEditor javaEditor, int offset) throws JavaModelException {
ITypeRoot element= JavaUI.getEditorInputTypeRoot(javaEditor.getEditorInput());
CompilationUnit ast = SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, null);
NodeFinder finder= new NodeFinder(ast, offset, 0);
ASTNode node= finder.getCoveringNode();
while(node != null) {
if(node instanceof Initializer) {
TypeDeclaration typeDeclaration = (TypeDeclaration) node.getParent();
IType type = (IType) typeDeclaration.resolveBinding().getJavaElement();
for(IInitializer initializer : type.getInitializers()) {
if(node.getStartPosition() == initializer.getSourceRange().getOffset()
&& Flags.isStatic(initializer.getFlags())) {
return initializer;
}
}
}
if(node instanceof MethodDeclaration) {
IMethodBinding binding = ((MethodDeclaration) node).resolveBinding();
return (IMethod) binding.getJavaElement();
}
node = node.getParent();
}
return null;
}
开发者ID:masao-kunii,项目名称:byteman-editor,代码行数:26,代码来源:JavaUtils.java
示例16: getMember
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Returns {@code IMethod} if the current selection is a method. When the selection is a static initializer returns {@code IInitializer}.
* If it is neither of them, returns null.
* @param event an {@code ExecutionEvent}
* @return {@code IMethod} or {@code IInitializer}
* @throws JavaModelException
*/
protected IMember getMember(ExecutionEvent event) throws JavaModelException {
ISelection selection = getSelection(event);
if(selection instanceof ITextSelection) {
ITextEditor editor = (ITextEditor) getEditor(event);
ITextSelection textSelection = (ITextSelection) editor.getSelectionProvider().getSelection();
return JavaUtils.getMemberFromOffset(editor, textSelection.getOffset());
} else {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
IMember member = (IMember) structuredSelection.getFirstElement();
if(member instanceof IInitializer
&& !Flags.isStatic(((IInitializer) member).getFlags())) {
return null;
}
return member;
}
}
开发者ID:masao-kunii,项目名称:byteman-editor,代码行数:24,代码来源:AbstractTemplateHandler.java
示例17: appendInitializerLabel
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Appends the label for a initializer. Considers the I_* flags.
*
* @param initializer the element to render
* @param flags the rendering flags. Flags with names starting with 'I_' are considered.
*/
public void appendInitializerLabel(IInitializer initializer, long flags) {
// qualification
if (getFlag(flags, JavaElementLabels.I_FULLY_QUALIFIED)) {
appendTypeLabel(initializer.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
fBuilder.append('.');
}
fBuilder.append("{...}");
// post qualification
if (getFlag(flags, JavaElementLabels.I_POST_QUALIFIED)) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
appendTypeLabel(initializer.getDeclaringType(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
}
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:JavaElementLabelComposer.java
示例18: convertToDTOInitializer
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
private Initializer convertToDTOInitializer(IInitializer iInitializer) throws JavaModelException {
Initializer initializer = DtoFactory.newDto(Initializer.class);
initializer.setFileRegion(convertToDTORegion(iInitializer.getSourceRange()));
initializer.setElementName(iInitializer.getElementName());
initializer.setHandleIdentifier(iInitializer.getHandleIdentifier());
initializer.setFlags(iInitializer.getFlags());
initializer.setLabel(
org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(
iInitializer, org.eclipse.jdt.ui.JavaElementLabels.ALL_DEFAULT));
return initializer;
}
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:JavaNavigation.java
示例19: IncomingMemberVisibilityAdjustment
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Creates a new incoming member visibility adjustment.
*
* @param member the member which is adjusted
* @param keyword the keyword representing the adjusted visibility
* @param status the associated status, or <code>null</code>
*/
public IncomingMemberVisibilityAdjustment(
final IMember member, final ModifierKeyword keyword, final RefactoringStatus status) {
Assert.isNotNull(member);
Assert.isTrue(!(member instanceof IInitializer));
Assert.isTrue(isVisibilityKeyword(keyword));
fMember = member;
fKeyword = keyword;
fRefactoringStatus = status;
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:MemberVisibilityAdjustor.java
示例20: adjustMemberVisibility
import org.eclipse.jdt.core.IInitializer; //导入依赖的package包/类
/**
* Check whether anyone accesses the members of the moved type from the outside. Those may need to
* have their visibility adjusted.
*
* @param member the member
* @param monitor the progress monitor to use
* @throws JavaModelException if an error occurs
*/
private void adjustMemberVisibility(final IMember member, final IProgressMonitor monitor)
throws JavaModelException {
if (member instanceof IType) {
// recursively check accessibility of member type's members
final IJavaElement[] typeMembers = ((IType) member).getChildren();
for (int i = 0; i < typeMembers.length; i++) {
if (!(typeMembers[i] instanceof IInitializer))
adjustMemberVisibility((IMember) typeMembers[i], monitor);
}
}
if (member.equals(fReferenced) || Modifier.isPublic(member.getFlags())) return;
final SearchResultGroup[] references = findReferences(member, monitor);
for (int i = 0; i < references.length; i++) {
final SearchMatch[] searchResults = references[i].getSearchResults();
for (int k = 0; k < searchResults.length; k++) {
final IJavaElement referenceToMember = (IJavaElement) searchResults[k].getElement();
if (fAdjustments.get(member) == null
&& referenceToMember instanceof IMember
&& !isInsideMovedMember(referenceToMember)) {
// check whether the member is still visible from the
// destination. As we are moving a type, the destination is
// a package or another type.
adjustIncomingVisibility(fReferencing, member, new SubProgressMonitor(monitor, 1));
}
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:MemberVisibilityAdjustor.java
注:本文中的org.eclipse.jdt.core.IInitializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论