org.eclipse.jdt.core.IInitializer Java Examples

The following examples show how to use org.eclipse.jdt.core.IInitializer. 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: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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;
	}
}
 
Example #2
Source File: MoveStaticMembersProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: ASTNodeSearchUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
	}
}
 
Example #4
Source File: GenericRefactoringHandleTransplanter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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());
	}
}
 
Example #5
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
	}
}
 
Example #6
Source File: NLSAccessorFieldRenameParticipant.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: FindBrokenNLSKeysAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: GenericRefactoringHandleTransplanter.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
protected IType transplantHandle(IJavaElement parent, IType element) {
	switch (parent.getElementType()) {
		case IJavaElement.COMPILATION_UNIT:
			return ((ICompilationUnit) parent).getType(element.getElementName());
		case IJavaElement.CLASS_FILE:
			if (parent instanceof IOrdinaryClassFile) {
				return ((IOrdinaryClassFile) parent).getType();
			}
			throw new IllegalStateException(element.toString());
		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());
	}
}
 
Example #9
Source File: JavaElementLabelComposer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #10
Source File: ASTNodeSearchUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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;
	}
}
 
Example #11
Source File: GoToNextPreviousMemberAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static int firstOpeningBraceOffset(IInitializer iInitializer) throws JavaModelException {
	try {
		IScanner scanner= ToolFactory.createScanner(false, false, false, false);
		scanner.setSource(iInitializer.getSource().toCharArray());
		int token= scanner.getNextToken();
		while (token != ITerminalSymbols.TokenNameEOF && token != ITerminalSymbols.TokenNameLBRACE)
			token= scanner.getNextToken();
		if (token == ITerminalSymbols.TokenNameLBRACE)
			return iInitializer.getSourceRange().getOffset() + scanner.getCurrentTokenStartPosition() + scanner.getRawTokenSource().length;
		return iInitializer.getSourceRange().getOffset();
	} catch (InvalidInputException e) {
		return iInitializer.getSourceRange().getOffset();
	}
}
 
Example #12
Source File: GoToNextPreviousMemberAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static int getOffset(IMember iMember) throws JavaModelException {
	//special case
	if (iMember.getElementType() == IJavaElement.INITIALIZER)
		return firstOpeningBraceOffset((IInitializer)iMember);

	if (iMember.getNameRange() != null && iMember.getNameRange().getOffset() >= 0)
		return iMember.getNameRange().getOffset();
	return iMember.getSourceRange().getOffset();
}
 
Example #13
Source File: ASTNodeSearchUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static Initializer getInitializerNode(IInitializer initializer, CompilationUnit cuNode) throws JavaModelException {
	ASTNode node= findNode(initializer.getSourceRange(), cuNode);
	if (node instanceof Initializer)
		return (Initializer) node;
	if (node instanceof Block && node.getParent() instanceof Initializer)
		return (Initializer) node.getParent();
	return null;
}
 
Example #14
Source File: OpenCallHierarchyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IJavaElement getEnclosingMethod(ITypeRoot input, ITextSelection selection) {
	try {
		IJavaElement enclosingElement= input.getElementAt(selection.getOffset());
		if (enclosingElement instanceof IMethod || enclosingElement instanceof IInitializer || enclosingElement instanceof IField) {
			// opening on the enclosing type would be too confusing (since the type resolves to the constructors)
			return enclosingElement;
		}
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
	}

	return null;
}
 
Example #15
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void copyToDestination(IJavaElement element, CompilationUnitRewrite targetRewriter, CompilationUnit sourceCuNode, CompilationUnit targetCuNode) throws CoreException {
	final ASTRewrite rewrite= targetRewriter.getASTRewrite();
	switch (element.getElementType()) {
		case IJavaElement.FIELD:
			copyMemberToDestination((IMember) element, targetRewriter, sourceCuNode, targetCuNode, createNewFieldDeclarationNode(((IField) element), rewrite, sourceCuNode));
			break;
		case IJavaElement.IMPORT_CONTAINER:
			copyImportsToDestination((IImportContainer) element, rewrite, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.IMPORT_DECLARATION:
			copyImportToDestination((IImportDeclaration) element, rewrite, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.INITIALIZER:
			copyInitializerToDestination((IInitializer) element, targetRewriter, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.METHOD:
			copyMethodToDestination((IMethod) element, targetRewriter, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.PACKAGE_DECLARATION:
			copyPackageDeclarationToDestination((IPackageDeclaration) element, rewrite, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.TYPE:
			copyTypeToDestination((IType) element, targetRewriter, sourceCuNode, targetCuNode);
			break;

		default:
			Assert.isTrue(false);
	}
}
 
Example #16
Source File: DOMFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public ASTNode search() throws JavaModelException {
	ISourceRange range = null;
	if (this.element instanceof IMember && !(this.element instanceof IInitializer))
		range = ((IMember) this.element).getNameRange();
	else
		range = this.element.getSourceRange();
	this.rangeStart = range.getOffset();
	this.rangeLength = range.getLength();
	this.ast.accept(this);
	return this.foundNode;
}
 
Example #17
Source File: JavaElementRequestor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see IJavaElementRequestor
 */
public void acceptInitializer(IInitializer initializer) {
	if (this.initializers == null) {
		this.initializers= new ArrayList();
	}
	this.initializers.add(initializer);
}
 
Example #18
Source File: MemberVisibilityAdjustor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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));
			}
		}
	}
}
 
Example #19
Source File: MemberVisibilityAdjustor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: JavaElementRequestor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see IJavaElementRequestor
 */
public IInitializer[] getInitializers() {
	if (this.initializers == null) {
		return EMPTY_INITIALIZER_ARRAY;
	}
	int size = this.initializers.size();
	IInitializer[] results = new IInitializer[size];
	this.initializers.toArray(results);
	return results;
}
 
Example #21
Source File: MemberVisibilityAdjustor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #22
Source File: HierarchyProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected static String createLabel(final IMember member) {
	if (member instanceof IType)
		return JavaElementLabels.getTextLabel(member, JavaElementLabels.ALL_FULLY_QUALIFIED);
	else if (member instanceof IMethod)
		return JavaElementLabels.getTextLabel(member, JavaElementLabels.ALL_FULLY_QUALIFIED);
	else if (member instanceof IField)
		return JavaElementLabels.getTextLabel(member, JavaElementLabels.ALL_FULLY_QUALIFIED);
	else if (member instanceof IInitializer)
		return RefactoringCoreMessages.HierarchyRefactoring_initializer;
	Assert.isTrue(false);
	return null;
}
 
Example #23
Source File: ASTNodeSearchUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static Initializer getInitializerNode(IInitializer initializer, CompilationUnit cuNode) throws JavaModelException {
	ASTNode node= findNode(initializer.getSourceRange(), cuNode);
	if (node instanceof Initializer) {
		return (Initializer) node;
	}
	if (node instanceof Block && node.getParent() instanceof Initializer) {
		return (Initializer) node.getParent();
	}
	return null;
}
 
Example #24
Source File: CallHierarchyHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private IMember getEnclosingMember(ITypeRoot root, int offset) {
	Assert.isNotNull(root, "root");
	try {
		IJavaElement enclosingElement = root.getElementAt(offset);
		if (enclosingElement instanceof IMethod || enclosingElement instanceof IInitializer || enclosingElement instanceof IField) {
			// opening on the enclosing type would be too confusing (since the type resolves to the constructors)
			return (IMember) enclosingElement;
		}
	} catch (JavaModelException e) {
		JavaLanguageServerPlugin.log(e);
	}
	return null;
}
 
Example #25
Source File: JavaElementLabelComposer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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));
	}
}
 
Example #26
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
protected void copyToDestination(IJavaElement element, CompilationUnitRewrite targetRewriter, CompilationUnit sourceCuNode, CompilationUnit targetCuNode) throws CoreException {
	final ASTRewrite rewrite= targetRewriter.getASTRewrite();
	switch (element.getElementType()) {
		case IJavaElement.FIELD:
			copyMemberToDestination((IMember) element, targetRewriter, sourceCuNode, targetCuNode, createNewFieldDeclarationNode(((IField) element), rewrite, sourceCuNode));
			break;
		case IJavaElement.IMPORT_CONTAINER:
			copyImportsToDestination((IImportContainer) element, rewrite, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.IMPORT_DECLARATION:
			copyImportToDestination((IImportDeclaration) element, rewrite, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.INITIALIZER:
			copyInitializerToDestination((IInitializer) element, targetRewriter, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.METHOD:
			copyMethodToDestination((IMethod) element, targetRewriter, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.PACKAGE_DECLARATION:
			copyPackageDeclarationToDestination((IPackageDeclaration) element, rewrite, sourceCuNode, targetCuNode);
			break;
		case IJavaElement.TYPE:
			copyTypeToDestination((IType) element, targetRewriter, sourceCuNode, targetCuNode);
			break;

		default:
			Assert.isTrue(false);
	}
}
 
Example #27
Source File: HierarchyProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean canBeAccessedFrom(final IMember member, final IType target, final ITypeHierarchy hierarchy) throws JavaModelException {
	Assert.isTrue(!(member instanceof IInitializer));
	return member.exists();
}
 
Example #28
Source File: DeclaringType.java    From jdt-codemining with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IInitializer getInitializer(int occurrenceCount) {
	// TODO Auto-generated method stub
	return null;
}
 
Example #29
Source File: DeclaringType.java    From jdt-codemining with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IInitializer[] getInitializers() throws JavaModelException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #30
Source File: SingleTypeRequestor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see IJavaElementRequestor
 */
public void acceptInitializer(IInitializer initializer) {
	// implements interface method
}