Java Code Examples for org.eclipse.jdt.core.dom.ThisExpression#getQualifier()

The following examples show how to use org.eclipse.jdt.core.dom.ThisExpression#getQualifier() . 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: MoveInnerToTopRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean visit(final ThisExpression node) {
	Assert.isNotNull(node);
	Name name= node.getQualifier();
	if (fCreateInstanceField && name != null) {
		ITypeBinding binding= node.resolveTypeBinding();
		if (binding != null && Bindings.equals(binding, fTypeBinding.getDeclaringClass())) {
			AST ast= node.getAST();
			Expression expression= null;
			if (fCodeGenerationSettings.useKeywordThis || fEnclosingInstanceFieldName.equals(fNameForEnclosingInstanceConstructorParameter)) {
				FieldAccess access= ast.newFieldAccess();
				access.setExpression(ast.newThisExpression());
				access.setName(ast.newSimpleName(fEnclosingInstanceFieldName));
				expression= access;
			} else {
				expression= ast.newSimpleName(fEnclosingInstanceFieldName);
			}
			fSourceRewrite.getASTRewrite().replace(node, expression, null);
		}
	}
	return super.visit(node);
}
 
Example 2
Source File: MethodObject.java    From JDeodorant with MIT License 6 votes vote down vote up
public boolean containsFieldAccessOfEnclosingClass() {
	//check for field access like SegmentedTimeline.this.segmentsIncluded
	List<FieldInstructionObject> fieldInstructions = getFieldInstructions();
	for(FieldInstructionObject fieldInstruction : fieldInstructions) {
		SimpleName simpleName = fieldInstruction.getSimpleName();
		if(simpleName.getParent() instanceof FieldAccess) {
			FieldAccess fieldAccess = (FieldAccess)simpleName.getParent();
			Expression fieldAccessExpression = fieldAccess.getExpression();
			if(fieldAccessExpression instanceof ThisExpression) {
				ThisExpression thisExpression = (ThisExpression)fieldAccessExpression;
				if(thisExpression.getQualifier() != null) {
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 3
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final ThisExpression it) {
  Name _qualifier = it.getQualifier();
  boolean _tripleNotEquals = (_qualifier != null);
  if (_tripleNotEquals) {
    it.getQualifier().accept(this);
    this.appendToBuffer(".");
  }
  this.appendToBuffer("this");
  return false;
}
 
Example 4
Source File: MoveInnerToTopRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(ThisExpression node) {
	final Name qualifier= node.getQualifier();
	if (qualifier != null) {
		final ITypeBinding binding= qualifier.resolveTypeBinding();
		if (binding != null && binding != fCurrentType.getTypeDeclaration()) {
			fSimpleNames.add(qualifier);
		}
	}
	return super.visit(node);
}
 
Example 5
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final boolean visit(final ThisExpression node) {
	Assert.isNotNull(node);
	if (node.getQualifier() != null) {
		fStatus.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_refers_enclosing_instances, JavaStatusContext.create(fMethod.getCompilationUnit(), node)));
		fResult.add(node);
	}
	return false;
}
 
Example 6
Source File: SourceAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(ThisExpression node) {
	if (node.getQualifier() != null) {
		status.addFatalError(
			RefactoringCoreMessages.InlineMethodRefactoring_SourceAnalyzer_qualified_this_expressions,
			JavaStatusContext.create(fTypeRoot, node));
		return false;
	}
	return true;
}
 
Example 7
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean visit(ThisExpression expr) {
	/*
	 * ThisExpression: [ ClassName . ] this
	 */
	activateDiffStyle(expr);
	if (expr.getQualifier() != null) {
		handleExpression(expr.getQualifier());
		appendPeriod();
	}
	styledString.append("this", determineDiffStyle(expr, new StyledStringStyler(keywordStyle)));
	deactivateDiffStyle(expr);
	return false;
}
 
Example 8
Source File: LambdaExpressionsFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean visit(ThisExpression node) {
	if (node.getQualifier() == null)
		throw new AbortSearchException();
	return true; // references to outer scope are harmless
}