本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java AbstractVariableDeclaration类的具体用法?Java AbstractVariableDeclaration怎么用?Java AbstractVariableDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractVariableDeclaration类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了AbstractVariableDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resolveVariable
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
synchronized IVariableBinding resolveVariable(VariableDeclaration variable) {
final Object node = this.newAstToOldAst.get(variable);
if (node instanceof AbstractVariableDeclaration) {
AbstractVariableDeclaration abstractVariableDeclaration = (AbstractVariableDeclaration) node;
IVariableBinding variableBinding = null;
if (abstractVariableDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) abstractVariableDeclaration;
variableBinding = this.getVariableBinding(fieldDeclaration.binding, variable);
} else {
variableBinding = this.getVariableBinding(((LocalDeclaration) abstractVariableDeclaration).binding, variable);
}
if (variableBinding == null) {
return null;
}
this.bindingsToAstNodes.put(variableBinding, variable);
String key = variableBinding.getKey();
if (key != null) {
this.bindingTables.bindingKeysToBindings.put(key, variableBinding);
}
return variableBinding;
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:DefaultBindingResolver.java
示例2: updateOnClosingBrace
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){
if (this.bracketBalance > 0){ // was an array initializer
this.bracketBalance--;
if (this.bracketBalance == 0) {
if(this.fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
updateSourceEndIfNecessary(braceEnd - 1);
return this.parent;
} else {
if (this.fieldDeclaration.declarationSourceEnd > 0)
this.alreadyCompletedFieldInitialization = true;
}
}
return this;
} else if (this.bracketBalance == 0) {
this.alreadyCompletedFieldInitialization = true;
updateSourceEndIfNecessary(braceEnd - 1);
}
if (this.parent != null){
return this.parent.updateOnClosingBrace(braceStart, braceEnd);
}
return this;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:RecoveredField.java
示例3: updateOnOpeningBrace
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public RecoveredElement updateOnOpeningBrace(int braceStart, int braceEnd){
if (this.fieldDeclaration.declarationSourceEnd == 0) {
if (this.fieldDeclaration.type instanceof ArrayTypeReference || this.fieldDeclaration.type instanceof ArrayQualifiedTypeReference) {
if (!this.alreadyCompletedFieldInitialization) {
this.bracketBalance++;
return null; // no update is necessary (array initializer)
}
} else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=308980
// in case an initializer bracket is opened in a non-array field
// e.g. int field = {..
this.bracketBalance++;
return null; // no update is necessary (array initializer)
}
}
if (this.fieldDeclaration.declarationSourceEnd == 0
&& this.fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT){
this.bracketBalance++;
return null; // no update is necessary (enum constant)
}
// might be an array initializer
this.updateSourceEndIfNecessary(braceStart - 1, braceEnd - 1);
return this.parent.updateOnOpeningBrace(braceStart, braceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:RecoveredField.java
示例4: assignmentHasNoEffect
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name){
int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
if (severity == ProblemSeverities.Ignore) return;
String[] arguments = new String[] { new String(name) };
int start = location.sourceStart;
int end = location.sourceEnd;
if (location.initialization != null) {
end = location.initialization.sourceEnd;
}
this.handle(
IProblem.AssignmentHasNoEffect,
arguments,
arguments,
severity,
start,
end);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:ProblemReporter.java
示例5: generateSyntheticBodyForEnumInitializationMethod
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void generateSyntheticBodyForEnumInitializationMethod(SyntheticMethodBinding methodBinding) {
// no local used
this.maxLocals = 0;
// generate all enum constants
SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) methodBinding.declaringClass;
TypeDeclaration typeDeclaration = sourceTypeBinding.scope.referenceContext;
BlockScope staticInitializerScope = typeDeclaration.staticInitializerScope;
FieldDeclaration[] fieldDeclarations = typeDeclaration.fields;
for (int i = methodBinding.startIndex, max = methodBinding.endIndex; i < max; i++) {
FieldDeclaration fieldDecl = fieldDeclarations[i];
if (fieldDecl.isStatic()) {
if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
fieldDecl.generateCode(staticInitializerScope, this);
}
}
}
return_();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CodeStream.java
示例6: acceptLocalVariable
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void acceptLocalVariable(LocalVariableBinding binding) {
LocalDeclaration local = binding.declaration;
IJavaElement parent = findLocalElement(local.sourceStart); // findLocalElement() cannot find local variable
LocalVariable localVar = null;
if(parent != null) {
localVar = new LocalVariable(
(JavaElement)parent,
new String(local.name),
local.declarationSourceStart,
local.declarationSourceEnd,
local.sourceStart,
local.sourceEnd,
Util.typeSignature(local.type),
local.annotations,
local.modifiers,
local.getKind() == AbstractVariableDeclaration.PARAMETER);
}
if (localVar != null) {
addElement(localVar);
if(SelectionEngine.DEBUG){
System.out.print("SELECTION - accept local variable("); //$NON-NLS-1$
System.out.print(localVar.toString());
System.out.println(")"); //$NON-NLS-1$
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:SelectionRequestor.java
示例7: generateNullCheck
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
/**
* Generates a new statement that checks if the given variable is null, and if so, throws a {@code NullPointerException} with the
* variable name as message.
*/
public static Statement generateNullCheck(AbstractVariableDeclaration variable, ASTNode source) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
if (isPrimitive(variable.type)) return null;
AllocationExpression exception = new AllocationExpression();
setGeneratedBy(exception, source);
exception.type = new QualifiedTypeReference(fromQualifiedName("java.lang.NullPointerException"), new long[]{p, p, p});
setGeneratedBy(exception.type, source);
exception.arguments = new Expression[] { new StringLiteral(variable.name, pS, pE, 0)};
setGeneratedBy(exception.arguments[0], source);
ThrowStatement throwStatement = new ThrowStatement(exception, pS, pE);
setGeneratedBy(throwStatement, source);
SingleNameReference varName = new SingleNameReference(variable.name, p);
setGeneratedBy(varName, source);
NullLiteral nullLiteral = new NullLiteral(pS, pE);
setGeneratedBy(nullLiteral, source);
EqualExpression equalExpression = new EqualExpression(varName, nullLiteral, OperatorIds.EQUAL_EQUAL);
equalExpression.sourceStart = pS; equalExpression.statementEnd = equalExpression.sourceEnd = pE;
setGeneratedBy(equalExpression, source);
IfStatement ifStatement = new IfStatement(equalExpression, throwStatement, 0, 0);
setGeneratedBy(ifStatement, source);
return ifStatement;
}
开发者ID:redundent,项目名称:lombok,代码行数:30,代码来源:EclipseHandlerUtil.java
示例8: fixPositions
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
private void fixPositions(AbstractVariableDeclaration node) {
node.sourceEnd = sourceEnd;
node.sourceStart = sourceStart;
node.declarationEnd = sourceEnd;
node.declarationSourceEnd = sourceEnd;
node.declarationSourceStart = sourceStart;
node.modifiersSourceStart = sourceStart;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:9,代码来源:SetGeneratedByVisitor.java
示例9: resolve
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
@Override
@Nullable
public ResolvedNode resolve(@NonNull JavaContext context, @NonNull Node node) {
Object nativeNode = getNativeNode(node);
if (nativeNode == null) {
return null;
}
if (nativeNode instanceof NameReference) {
return resolve(((NameReference) nativeNode).binding);
} else if (nativeNode instanceof TypeReference) {
return resolve(((TypeReference) nativeNode).resolvedType);
} else if (nativeNode instanceof MessageSend) {
return resolve(((MessageSend) nativeNode).binding);
} else if (nativeNode instanceof AllocationExpression) {
return resolve(((AllocationExpression) nativeNode).binding);
} else if (nativeNode instanceof TypeDeclaration) {
return resolve(((TypeDeclaration) nativeNode).binding);
} else if (nativeNode instanceof ExplicitConstructorCall) {
return resolve(((ExplicitConstructorCall) nativeNode).binding);
} else if (nativeNode instanceof Annotation) {
return resolve(((Annotation) nativeNode).resolvedType);
} else if (nativeNode instanceof AbstractMethodDeclaration) {
return resolve(((AbstractMethodDeclaration) nativeNode).binding);
} else if (nativeNode instanceof AbstractVariableDeclaration) {
if (nativeNode instanceof LocalDeclaration) {
return resolve(((LocalDeclaration) nativeNode).binding);
} else if (nativeNode instanceof FieldDeclaration) {
return resolve(((FieldDeclaration) nativeNode).binding);
}
}
// TODO: Handle org.eclipse.jdt.internal.compiler.ast.SuperReference. It
// doesn't contain an actual method binding; the parent node call should contain
// it, but is missing a native node reference; investigate the ECJ bridge's super
// handling.
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:EcjParser.java
示例10: getJavaElement
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的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
示例11: consumeEnterVariable
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
protected void consumeEnterVariable() {
// EnterVariable ::= $empty
// do nothing by default
super.consumeEnterVariable();
AbstractVariableDeclaration variable = (AbstractVariableDeclaration) this.astStack[this.astPtr];
if (variable.type == this.assistNode){
if (!this.diet){
this.restartRecovery = true; // force to restart in recovery mode
this.lastIgnoredToken = -1;
}
this.isOrphanCompletionNode = false; // already attached inside variable decl
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:SelectionParser.java
示例12: consumeExitVariableWithInitialization
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
protected void consumeExitVariableWithInitialization() {
super.consumeExitVariableWithInitialization();
// does not keep the initialization if selection is not inside
AbstractVariableDeclaration variable = (AbstractVariableDeclaration) this.astStack[this.astPtr];
int start = variable.initialization.sourceStart;
int end = variable.initialization.sourceEnd;
if ((this.selectionStart < start) && (this.selectionEnd < start) ||
(this.selectionStart > end) && (this.selectionEnd > end)) {
variable.initialization = null;
}
triggerRecoveryUponLambdaClosure(variable, false);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:SelectionParser.java
示例13: acceptLocalVariable
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void acceptLocalVariable(LocalVariableBinding binding, org.eclipse.jdt.internal.compiler.env.ICompilationUnit unit) {
LocalDeclaration local = binding.declaration;
IJavaElement parent = null;
if (binding.declaringScope.isLambdaSubscope() && unit instanceof ICompilationUnit) {
HashSet existingElements = new HashSet();
HashMap knownScopes = new HashMap();
parent = this.handleFactory.createElement(binding.declaringScope, local.sourceStart, (ICompilationUnit) unit, existingElements, knownScopes);
} else {
parent = findLocalElement(local.sourceStart, binding.declaringScope.methodScope()); // findLocalElement() cannot find local variable
}
LocalVariable localVar = null;
if(parent != null) {
localVar = new LocalVariable(
(JavaElement)parent,
new String(local.name),
local.declarationSourceStart,
local.declarationSourceEnd,
local.sourceStart,
local.sourceEnd,
local.type == null ? Signature.createTypeSignature(binding.type.readableName(), true) : Util.typeSignature(local.type),
local.annotations,
local.modifiers,
local.getKind() == AbstractVariableDeclaration.PARAMETER);
}
if (localVar != null) {
addElement(localVar);
if(SelectionEngine.DEBUG){
System.out.print("SELECTION - accept local variable("); //$NON-NLS-1$
System.out.print(localVar.toString());
System.out.println(")"); //$NON-NLS-1$
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:SelectionRequestor.java
示例14: resolveConstructor
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) {
org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(enumConstantDeclaration);
if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node;
if (fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT && fieldDeclaration.initialization != null) {
AllocationExpression allocationExpression = (AllocationExpression) fieldDeclaration.initialization;
return getMethodBinding(allocationExpression.binding);
}
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:DefaultBindingResolver.java
示例15: consumeExitVariableWithInitialization
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
protected void consumeExitVariableWithInitialization() {
// ExitVariableWithInitialization ::= $empty
// do nothing by default
this.expressionLengthPtr--;
AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
variableDecl.initialization = this.expressionStack[this.expressionPtr--];
// we need to update the declarationSourceEnd of the local variable declaration to the
// source end position of the initialization expression
variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd;
variableDecl.declarationEnd = variableDecl.initialization.sourceEnd;
recoveryExitFromVariable();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:Parser.java
示例16: consumeExitVariableWithoutInitialization
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
protected void consumeExitVariableWithoutInitialization() {
// ExitVariableWithoutInitialization ::= $empty
// do nothing by default
AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
variableDecl.declarationSourceEnd = variableDecl.declarationEnd;
if(this.currentElement != null && this.currentElement instanceof RecoveredField) {
if(this.endStatementPosition > variableDecl.sourceEnd) {
this.currentElement.updateSourceEndIfNecessary(this.endStatementPosition);
}
}
recoveryExitFromVariable();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:Parser.java
示例17: possibleHeapPollutionFromVararg
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void possibleHeapPollutionFromVararg(AbstractVariableDeclaration vararg) {
String[] arguments = new String[] {new String(vararg.name)};
this.handle(
IProblem.PotentialHeapPollutionFromVararg,
arguments,
arguments,
vararg.sourceStart,
vararg.sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ProblemReporter.java
示例18: variableTypeCannotBeVoid
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
String[] arguments = new String[] {new String(varDecl.name)};
this.handle(
IProblem.VariableTypeCannotBeVoid,
arguments,
arguments,
varDecl.sourceStart,
varDecl.sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ProblemReporter.java
示例19: variableTypeCannotBeVoidArray
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
this.handle(
IProblem.CannotAllocateVoidArray,
NoArgument,
NoArgument,
varDecl.type.sourceStart,
varDecl.type.sourceEnd);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ProblemReporter.java
示例20: applyOffsetVariable
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; //导入依赖的package包/类
private void applyOffsetVariable(AbstractVariableDeclaration node) {
applyOffsetASTNode(node);
node.declarationEnd = newSourceEnd;
node.declarationSourceEnd = newSourceEnd;
node.declarationSourceStart = newSourceStart;
node.modifiersSourceStart = newSourceStart;
}
开发者ID:redundent,项目名称:lombok,代码行数:8,代码来源:SetGeneratedByVisitor.java
注:本文中的org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论