本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.ImportReference类的典型用法代码示例。如果您正苦于以下问题:Java ImportReference类的具体用法?Java ImportReference怎么用?Java ImportReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImportReference类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了ImportReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isEqual
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
private static boolean isEqual(String packageName, ImportReference pkgOrStarImport) {
if (pkgOrStarImport == null || pkgOrStarImport.tokens == null || pkgOrStarImport.tokens.length == 0) return packageName.isEmpty();
int pos = 0;
int len = packageName.length();
for (int i = 0; i < pkgOrStarImport.tokens.length; i++) {
if (i != 0) {
if (pos >= len) return false;
if (packageName.charAt(pos++) != '.') return false;
}
for (int j = 0; j < pkgOrStarImport.tokens[i].length; j++) {
if (pos >= len) return false;
if (packageName.charAt(pos++) != pkgOrStarImport.tokens[i][j]) return false;
}
}
return true;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:EclipseImportList.java
示例2: format
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
private void format(ImportReference importRef, boolean isLast) {
this.scribe.printNextToken(TerminalTokens.TokenNameimport);
if (!isLast) this.scribe.blank_lines_between_import_groups = this.preferences.blank_lines_between_import_groups;
this.scribe.space();
if (importRef.isStatic()) {
this.scribe.printNextToken(TerminalTokens.TokenNamestatic);
this.scribe.space();
}
if ((importRef.bits & ASTNode.OnDemand) != 0) {
this.scribe.printQualifiedReference(importRef.sourceEnd, false/*do not expect parenthesis*/);
this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
this.scribe.printNextToken(TerminalTokens.TokenNameMULTIPLY);
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
} else {
this.scribe.printQualifiedReference(importRef.sourceEnd, false/*do not expect parenthesis*/);
this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
}
if (isLast) {
this.scribe.blank_lines_between_import_groups = -1;
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.IMPORT_TRAILING_COMMENT);
} else {
this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.NO_TRAILING_COMMENT);
this.scribe.blank_lines_between_import_groups = -1;
}
this.scribe.printNewLine();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:CodeFormatterVisitor.java
示例3: createImportReference
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected ImportReference createImportReference(
String[] importName,
int start,
int end,
boolean onDemand,
int modifiers) {
int length = importName.length;
long[] positions = new long[length];
long position = ((long) start << 32) + end;
char[][] qImportName = new char[length][];
for (int i = 0; i < length; i++) {
qImportName[i] = importName[i].toCharArray();
positions[i] = position; // dummy positions
}
return new ImportReference(
qImportName,
positions,
onDemand,
modifiers);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:TypeConverter.java
示例4: notifySourceElementRequestor
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected void notifySourceElementRequestor(
ImportReference importReference,
boolean isPackage) {
if (isPackage) {
this.requestor.acceptPackage(importReference);
} else {
final boolean onDemand = (importReference.bits & ASTNode.OnDemand) != 0;
this.requestor.acceptImport(
importReference.declarationSourceStart,
importReference.declarationSourceEnd,
importReference.sourceStart,
onDemand ? importReference.trailingStarPosition : importReference.sourceEnd,
importReference.tokens,
onDemand,
importReference.modifiers);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:SourceElementNotifier.java
示例5: add
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
public RecoveredElement add(ImportReference importReference, int bracketBalanceValue) {
resetPendingModifiers();
if (this.imports == null) {
this.imports = new RecoveredImport[5];
this.importCount = 0;
} else {
if (this.importCount == this.imports.length) {
System.arraycopy(
this.imports,
0,
(this.imports = new RecoveredImport[2 * this.importCount]),
0,
this.importCount);
}
}
RecoveredImport element = new RecoveredImport(importReference, this, bracketBalanceValue);
this.imports[this.importCount++] = element;
/* if import not finished, then import becomes current */
if (importReference.declarationSourceEnd == 0) return element;
return this;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:RecoveredUnit.java
示例6: consumeImportDeclaration
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected void consumeImportDeclaration() {
// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
ImportReference impt = (ImportReference) this.astStack[this.astPtr];
// flush annotations defined prior to import statements
impt.declarationEnd = this.endStatementPosition;
impt.declarationSourceEnd =
flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
// recovery
if (this.currentElement != null) {
this.lastCheckPoint = impt.declarationSourceEnd + 1;
this.currentElement = this.currentElement.add(impt, 0);
this.lastIgnoredToken = -1;
this.restartRecovery = true;
// used to avoid branching back into the regular automaton
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:Parser.java
示例7: installStubs
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
public void installStubs(final Resource resource) {
boolean _isInfoFile = this.isInfoFile(resource);
if (_isInfoFile) {
return;
}
final CompilationUnit compilationUnit = this.getCompilationUnit(resource);
IErrorHandlingPolicy _proceedWithAllProblems = DefaultErrorHandlingPolicies.proceedWithAllProblems();
CompilerOptions _compilerOptions = this.getCompilerOptions(resource);
DefaultProblemFactory _defaultProblemFactory = new DefaultProblemFactory();
ProblemReporter _problemReporter = new ProblemReporter(_proceedWithAllProblems, _compilerOptions, _defaultProblemFactory);
final Parser parser = new Parser(_problemReporter, true);
final CompilationResult compilationResult = new CompilationResult(compilationUnit, 0, 1, (-1));
final CompilationUnitDeclaration result = parser.dietParse(compilationUnit, compilationResult);
if ((result.types != null)) {
for (final TypeDeclaration type : result.types) {
{
ImportReference _currentPackage = result.currentPackage;
char[][] _importName = null;
if (_currentPackage!=null) {
_importName=_currentPackage.getImportName();
}
List<String> _map = null;
if (((List<char[]>)Conversions.doWrapArray(_importName))!=null) {
final Function1<char[], String> _function = (char[] it) -> {
return String.valueOf(it);
};
_map=ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(_importName)), _function);
}
String _join = null;
if (_map!=null) {
_join=IterableExtensions.join(_map, ".");
}
final String packageName = _join;
final JvmDeclaredType jvmType = this.createType(type, packageName);
resource.getContents().add(jvmType);
}
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:40,代码来源:JavaDerivedStateComputer.java
示例8: getFullyQualifiedNameForSimpleName
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
@Override public String getFullyQualifiedNameForSimpleName(String unqualified) {
if (imports != null) {
outer:
for (ImportReference imp : imports) {
if ((imp.bits & ASTNode.OnDemand) != 0) continue;
char[][] tokens = imp.tokens;
char[] token = tokens.length == 0 ? new char[0] : tokens[tokens.length - 1];
int len = token.length;
if (len != unqualified.length()) continue;
for (int i = 0; i < len; i++) if (token[i] != unqualified.charAt(i)) continue outer;
return LombokInternalAliasing.processAliases(toQualifiedName(tokens));
}
}
return null;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:16,代码来源:EclipseImportList.java
示例9: applyNameToStarImports
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
@Override public Collection<String> applyNameToStarImports(String startsWith, String name) {
List<String> out = Collections.emptyList();
if (pkg != null && pkg.tokens != null && pkg.tokens.length != 0) {
char[] first = pkg.tokens[0];
int len = first.length;
boolean match = true;
if (startsWith.length() == len) {
for (int i = 0; match && i < len; i++) {
if (startsWith.charAt(i) != first[i]) match = false;
}
if (match) out.add(toQualifiedName(pkg.tokens) + "." + name);
}
}
if (imports != null) {
outer:
for (ImportReference imp : imports) {
if ((imp.bits & ASTNode.OnDemand) == 0) continue;
if (imp.isStatic()) continue;
if (imp.tokens == null || imp.tokens.length == 0) continue;
char[] firstToken = imp.tokens[0];
if (firstToken.length != startsWith.length()) continue;
for (int i = 0; i < firstToken.length; i++) if (startsWith.charAt(i) != firstToken[i]) continue outer;
String fqn = toQualifiedName(imp.tokens) + "." + name;
if (out.isEmpty()) out = Collections.singletonList(fqn);
else if (out.size() == 1) {
out = new ArrayList<String>(out);
out.add(fqn);
} else {
out.add(fqn);
}
}
}
return out;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:37,代码来源:EclipseImportList.java
示例10: fixPositions
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
private void fixPositions(ImportReference node) {
node.sourceEnd = sourceEnd;
node.sourceStart = sourceStart;
node.declarationEnd = sourceEnd;
node.declarationSourceEnd = sourceEnd;
node.declarationSourceStart = sourceStart;
if (node.sourcePositions == null || node.sourcePositions.length != node.tokens.length) node.sourcePositions = new long[node.tokens.length];
Arrays.fill(node.sourcePositions, sourcePos);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:10,代码来源:SetGeneratedByVisitor.java
示例11: notifySourceElementRequestor
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected void notifySourceElementRequestor(ImportReference importReference, boolean isPackage) {
if (importReference instanceof CompletionOnKeyword2) return;
if (importReference instanceof CompletionOnImportReference ||
importReference instanceof CompletionOnPackageReference) {
if (importReference.tokens[importReference.tokens.length - 1].length == 0) return;
}
super.notifySourceElementRequestor(importReference, isPackage);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:CompletionElementNotifier.java
示例12: newImportReference
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected ImportReference newImportReference(char[][] tokens, long[] sourcePositions, boolean onDemand, int mod) {
ImportReference ref = this.importReference;
ref.tokens = tokens;
ref.sourcePositions = sourcePositions;
if (onDemand) {
ref.bits |= ASTNode.OnDemand;
}
ref.sourceEnd = (int) (sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFF);
ref.sourceStart = (int) (sourcePositions[0] >>> 32);
ref.modifiers = this.modifiers;
return ref;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:IndexingParser.java
示例13: matchLevelAndReportImportRef
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected void matchLevelAndReportImportRef(ImportReference importRef, Binding binding, MatchLocator locator) throws CoreException {
// for static import, binding can be a field binding or a member type binding
// verify that in this case binding is static and use declaring class for fields
Binding refBinding = binding;
if (importRef.isStatic()) {
if (binding instanceof FieldBinding) {
FieldBinding fieldBinding = (FieldBinding) binding;
if (!fieldBinding.isStatic()) return;
refBinding = fieldBinding.declaringClass;
} else if (binding instanceof MethodBinding) {
MethodBinding methodBinding = (MethodBinding) binding;
if (!methodBinding.isStatic()) return;
refBinding = methodBinding.declaringClass;
} else if (binding instanceof MemberTypeBinding) {
MemberTypeBinding memberBinding = (MemberTypeBinding) binding;
if (!memberBinding.isStatic()) return;
}
}
// Look for closest pattern
PatternLocator closestPattern = null;
int level = IMPOSSIBLE_MATCH;
for (int i = 0, length = this.patternLocators.length; i < length; i++) {
PatternLocator patternLocator = this.patternLocators[i];
int newLevel = patternLocator.referenceType() == 0 ? IMPOSSIBLE_MATCH : patternLocator.resolveLevel(refBinding);
if (newLevel > level) {
closestPattern = patternLocator;
if (newLevel == ACCURATE_MATCH) break;
level = newLevel;
}
}
if (closestPattern != null) {
closestPattern.matchLevelAndReportImportRef(importRef, binding, locator);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:OrLocator.java
示例14: matchReportImportRef
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected void matchReportImportRef(ImportReference importRef, Binding binding, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
PatternLocator closestPattern = null;
int level = IMPOSSIBLE_MATCH;
for (int i = 0, length = this.patternLocators.length; i < length; i++) {
int newLevel = this.patternLocators[i].matchLevel(importRef);
if (newLevel > level) {
closestPattern = this.patternLocators[i];
if (newLevel == ACCURATE_MATCH) break;
level = newLevel;
}
}
if (closestPattern != null)
closestPattern.matchReportImportRef(importRef, binding, element, accuracy, locator);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:OrLocator.java
示例15: matchReportImportRef
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
protected void matchReportImportRef(ImportReference importRef, Binding binding, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
PatternLocator weakestPattern = null;
int level = IMPOSSIBLE_MATCH;
for (int i = 0, length = this.patternLocators.length; i < length; i++) {
int newLevel = this.patternLocators[i].matchLevel(importRef);
if (newLevel == IMPOSSIBLE_MATCH) return;
if (weakestPattern == null || newLevel < level) {
weakestPattern = this.patternLocators[i];
level = newLevel;
}
}
weakestPattern.matchReportImportRef(importRef, binding, element, accuracy, locator);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:AndLocator.java
示例16: acceptPackage
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
/**
* @see ISourceElementRequestor
*/
public void acceptPackage(ImportReference importReference) {
Object parentInfo = this.infoStack.peek();
JavaElement parentHandle= (JavaElement) this.handleStack.peek();
PackageDeclaration handle = null;
if (parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT) {
char[] name = CharOperation.concatWith(importReference.getImportName(), '.');
handle = createPackageDeclaration(parentHandle, new String(name));
}
else {
Assert.isTrue(false); // Should not happen
}
resolveDuplicates(handle);
AnnotatableInfo info = new AnnotatableInfo();
info.setSourceRangeStart(importReference.declarationSourceStart);
info.setSourceRangeEnd(importReference.declarationSourceEnd);
info.setNameSourceStart(importReference.sourceStart);
info.setNameSourceEnd(importReference.sourceEnd);
addToChildren(parentInfo, handle);
this.newElements.put(handle, info);
if (importReference.annotations != null) {
for (int i = 0, length = importReference.annotations.length; i < length; i++) {
org.eclipse.jdt.internal.compiler.ast.Annotation annotation = importReference.annotations[i];
acceptAnnotation(annotation, info, handle);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:CompilationUnitStructureRequestor.java
示例17: buildImports
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
public ImportReference[] buildImports(ClassFileReader reader) {
// add remaining references to the list of type names
// (code extracted from BinaryIndexer#extractReferenceFromConstantPool(...))
int[] constantPoolOffsets = reader.getConstantPoolOffsets();
int constantPoolCount = constantPoolOffsets.length;
for (int i = 0; i < constantPoolCount; i++) {
int tag = reader.u1At(constantPoolOffsets[i]);
char[] name = null;
switch (tag) {
case ClassFileConstants.MethodRefTag :
case ClassFileConstants.InterfaceMethodRefTag :
int constantPoolIndex = reader.u2At(constantPoolOffsets[i] + 3);
int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 3)];
name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
break;
case ClassFileConstants.ClassTag :
utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[i] + 1)];
name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
break;
}
if (name == null || (name.length > 0 && name[0] == '['))
break; // skip over array references
this.typeNames.add(CharOperation.splitOn('/', name));
}
// convert type names into import references
int typeNamesLength = this.typeNames.size();
ImportReference[] imports = new ImportReference[typeNamesLength];
char[][][] set = this.typeNames.set;
int index = 0;
for (int i = 0, length = set.length; i < length; i++) {
char[][] typeName = set[i];
if (typeName != null) {
imports[index++] = new ImportReference(typeName, new long[typeName.length]/*dummy positions*/, false/*not on demand*/, 0);
}
}
return imports;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:BinaryTypeConverter.java
示例18: buildTypeDeclaration
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
/**
* Convert a binary type into an AST type declaration and put it in the given compilation unit.
*/
public TypeDeclaration buildTypeDeclaration(IType type, CompilationUnitDeclaration compilationUnit) throws JavaModelException {
PackageFragment pkg = (PackageFragment) type.getPackageFragment();
char[][] packageName = Util.toCharArrays(pkg.names);
if (packageName.length > 0) {
compilationUnit.currentPackage = new ImportReference(packageName, new long[]{0}, false, ClassFileConstants.AccDefault);
}
/* convert type */
TypeDeclaration typeDeclaration = convert(type, null, null);
IType alreadyComputedMember = type;
IType parent = type.getDeclaringType();
TypeDeclaration previousDeclaration = typeDeclaration;
while(parent != null) {
TypeDeclaration declaration = convert(parent, alreadyComputedMember, previousDeclaration);
alreadyComputedMember = parent;
previousDeclaration = declaration;
parent = parent.getDeclaringType();
}
compilationUnit.types = new TypeDeclaration[]{previousDeclaration};
return typeDeclaration;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:BinaryTypeConverter.java
示例19: resolvePackage
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
synchronized IPackageBinding resolvePackage(PackageDeclaration pkg) {
if (this.scope == null) return null;
try {
org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(pkg);
if (node instanceof ImportReference) {
ImportReference importReference = (ImportReference) node;
Binding binding = this.scope.getOnlyPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
if ((binding != null) && (binding.isValidBinding())) {
if (binding instanceof ReferenceBinding) {
// this only happens if a type name has the same name as its package
ReferenceBinding referenceBinding = (ReferenceBinding) binding;
binding = referenceBinding.fPackage;
}
if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
IPackageBinding packageBinding = getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
if (packageBinding == null) {
return null;
}
this.bindingsToAstNodes.put(packageBinding, pkg);
String key = packageBinding.getKey();
if (key != null) {
this.bindingTables.bindingKeysToBindings.put(key, packageBinding);
}
return packageBinding;
}
}
}
} catch (AbortCompilation e) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:DefaultBindingResolver.java
示例20: add
import org.eclipse.jdt.internal.compiler.ast.ImportReference; //导入依赖的package包/类
public RecoveredElement add(ImportReference importReference, int bracketBalanceValue){
/* default behavior is to delegate recording to parent if any */
resetPendingModifiers();
if (this.parent == null) return this; // ignore
this.updateSourceEndIfNecessary(previousAvailableLineEnd(importReference.declarationSourceStart - 1));
return this.parent.add(importReference, bracketBalanceValue);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:RecoveredElement.java
注:本文中的org.eclipse.jdt.internal.compiler.ast.ImportReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论