Java Code Examples for org.eclipse.jdt.core.dom.VariableDeclaration#getStartPosition()

The following examples show how to use org.eclipse.jdt.core.dom.VariableDeclaration#getStartPosition() . 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: PromoteTempToFieldRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new promote temp to field refactoring.
 * @param declaration the variable declaration node to convert to a field
 */
public PromoteTempToFieldRefactoring(VariableDeclaration declaration) {
	Assert.isTrue(declaration != null);
	fTempDeclarationNode= declaration;
	IVariableBinding resolveBinding= declaration.resolveBinding();
	Assert.isTrue(resolveBinding != null && !resolveBinding.isParameter() && !resolveBinding.isField());

	ASTNode root= declaration.getRoot();
	Assert.isTrue(root instanceof CompilationUnit);
	fCompilationUnitNode= (CompilationUnit) root;

	IJavaElement input= fCompilationUnitNode.getJavaElement();
	Assert.isTrue(input instanceof ICompilationUnit);
	fCu= (ICompilationUnit) input;

	fSelectionStart= declaration.getStartPosition();
	fSelectionLength= declaration.getLength();

       fFieldName= ""; //$NON-NLS-1$
       fVisibility= Modifier.PRIVATE;
       fDeclareStatic= false;
       fDeclareFinal= false;
       fInitializeIn= INITIALIZE_IN_METHOD;
       fLinkedProposalModel= null;
}
 
Example 2
Source File: TempDeclarationFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean visitVariableDeclaration(VariableDeclaration vd) {
	if (vd.getInitializer() != null){
		int start= vd.getStartPosition();
		IRegion declarationRange= new Region(start, vd.getInitializer().getStartPosition() - start);
		if (getSelection().coveredBy(declarationRange))
			return addNodeAndStop(vd);
		else
			return super.visitNode(vd);
	} else {
		if (getSelection().coveredBy(vd))
			return addNodeAndStop(vd);
		else
			return super.visitNode(vd);
	}
}
 
Example 3
Source File: InlineTempRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public InlineTempRefactoring(VariableDeclaration decl) {
	fVariableDeclaration= decl;
	ASTNode astRoot= decl.getRoot();
	Assert.isTrue(astRoot instanceof CompilationUnit);
	fASTRoot= (CompilationUnit) astRoot;
	Assert.isTrue(fASTRoot.getJavaElement() instanceof ICompilationUnit);

	fSelectionStart= decl.getStartPosition();
	fSelectionLength= decl.getLength();
	fCu= (ICompilationUnit) fASTRoot.getJavaElement();
}
 
Example 4
Source File: ScopeAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(VariableDeclaration node) {
	if (hasFlag(VARIABLES, fFlags) && node.getStartPosition() < fPosition) {
		fBreak= fRequestor.acceptBinding(node.resolveBinding());
	}
	return !fBreak;
}
 
Example 5
Source File: ScopeAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(VariableDeclaration node) {
	if (hasFlag(VARIABLES, fFlags) && fPosition < node.getStartPosition()) {
		fBreak= fRequestor.acceptBinding(node.resolveBinding());
	}
	return false;
}