当前位置: 首页>>代码示例>>Java>>正文


Java QualifiedNameable类代码示例

本文整理汇总了Java中javax.lang.model.element.QualifiedNameable的典型用法代码示例。如果您正苦于以下问题:Java QualifiedNameable类的具体用法?Java QualifiedNameable怎么用?Java QualifiedNameable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QualifiedNameable类属于javax.lang.model.element包,在下文中一共展示了QualifiedNameable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMemberSelect

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
public Tree visitMemberSelect(MemberSelectTree tree, Object p) {
    if (tree instanceof QualIdentTree) {
        QualIdentTree qit = (QualIdentTree) tree;
        Element el = qit.sym;

        if (el == null) {
            el = overlay.resolve(model, elements, qit.getFQN());
        } else {
            if (el.getKind().isClass() || el.getKind().isInterface() || el.getKind() == ElementKind.PACKAGE) {
                el = overlay.resolve(model, elements, ((QualifiedNameable) el).getQualifiedName().toString(), elements.getModuleOf(el));
            }
        }

        return importAnalysis.resolveImport(tree, el);
    } else {
        return rewriteChildren(tree);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ImmutableTreeTranslator.java

示例2: fqnFor

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
private String fqnFor(Tree t) {
    Element el = ASTService.getElementImpl(t);

    if (el != null) {
        if (el.getKind().isClass() || el.getKind().isInterface() || el.getKind() == ElementKind.PACKAGE) {
            return ((QualifiedNameable) el).getQualifiedName().toString();
        } else {
            Logger.getLogger(ElementOverlay.class.getName()).log(Level.SEVERE, "Not a QualifiedNameable: {0}", el);
            return null;
        }
    } else if (t instanceof QualIdentTree) {
        return ((QualIdentTree) t).getFQN();
    } else if (t.getKind() == Kind.PARAMETERIZED_TYPE) {
        return fqnFor(((ParameterizedTypeTree) t).getType());
    } else {
        Logger.getLogger(ElementOverlay.class.getName()).log(Level.FINE, "No element and no QualIdent");
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ElementOverlay.java

示例3: serialize

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
private void serialize( Path root, DsvConfiguration configuration, Collection<MethodPartition> partitions,
        Function<ExecutableElement,QualifiedNameable> keyFunction )
{
    partitions.forEach( partition ->
    {
        String fileSuffix = partition.getFileSuffix();
        partition.getMethods().stream().collect( Collectors.groupingBy( keyFunction ) ).entrySet().forEach( kv ->
        {
            Either<DsvExportError,List<String>> headerParsingResult =
                    fieldExporter.exportHeaders( configuration.getFieldDelimiter(), configuration.getRawHeaders() );

            headerParsingResult.consume( messagePrinter::print, ( headers ) ->
            {
                File file = new File( root.toFile(),
                        String.format( "%s%s.csv", kv.getKey().getQualifiedName(), fileSuffix ) );

                serializeWithHeaders( file, configuration, kv.getValue(), headers );
            } );
        } );
    } );
}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:22,代码来源:DsvSerializer.java

示例4: resolvePackage

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
@Override
protected TreeBackedResolvedType resolvePackage(
    TreePath referencingPath,
    PackageElement referencedPackage,
    QualifiedNameable canonicalPackage) {
  // PackageElements are not considered to be enclosed by their parent elements, but
  // our logic is a lot simpler if we can pretend they are.
  TreeBackedResolvedType enclosingElement = null;
  String qualifiedName = canonicalPackage.getQualifiedName().toString();
  int lastDot = qualifiedName.lastIndexOf('.');
  if (lastDot > 0) {
    String enclosingPackageQualifiedName = qualifiedName.substring(0, lastDot);
    PackageElement enclosingPackage =
        Preconditions.checkNotNull(elements.getPackageElement(enclosingPackageQualifiedName));
    enclosingElement = resolveEnclosingElement(enclosingPackage);
  }

  return new TreeBackedResolvedType(referencingPath, canonicalPackage, enclosingElement);
}
 
开发者ID:facebook,项目名称:buck,代码行数:20,代码来源:TreeBackedTypeResolutionSimulator.java

示例5: onImport

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
@Override
public void onImport(
    boolean isStatic,
    boolean isStarImport,
    TreePath leafmostElementPath,
    QualifiedNameable leafmostElement,
    Name memberName) {
  if (!isStatic) {
    if (isStarImport) {
      starImportedElements.add(leafmostElement);
    } else {
      importedTypes.add((TypeElement) leafmostElement);
    }
  } else if (!isStarImport) {
    staticImportOwners.put(memberName.toString(), (TypeElement) leafmostElement);
  } else {
    staticStarImports.add((TypeElement) leafmostElement);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:20,代码来源:InterfaceScannerTest.java

示例6: getAnnotationMirror

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
@Nullable
private AnnotationMirror getAnnotationMirror(final Class<? extends Annotation> annotationClass,
                                             final Element element) {
  Optional<? extends AnnotationMirror> annotationMirror = FluentIterable
      .from(element.getAnnotationMirrors())
      .filter(new Predicate<AnnotationMirror>() {
        @Override
        public boolean apply(@Nullable AnnotationMirror o) {
          String qualifiedName = ((QualifiedNameable) (o.getAnnotationType().asElement())).getQualifiedName()
                                                                                          .toString();
          return qualifiedName.equals(annotationClass.getName());
        }
      }
      ).first();
  if (annotationMirror.isPresent()) {
    return annotationMirror.get();
  }
  return null;
}
 
开发者ID:lesaint,项目名称:damapping,代码行数:20,代码来源:ProcessingEnvironmentWrapper.java

示例7: groupByFileBasename

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
private Function<ExecutableElement,QualifiedNameable> groupByFileBasename( DsvGroupingStrategy grouping )
{
    switch ( grouping )
    {

    case SINGLE:
        return ( ignored ) -> new ConstantQualifiedNameable( "documentation" );
    case PACKAGE:
        return elements::getPackageOf;
    case CLASS:
        return method -> enclosingTypeVisitor.visit( method.getEnclosingElement() );
    }
    throw new IllegalArgumentException( "Unknown grouping strategy: " + grouping );
}
 
开发者ID:fbiville,项目名称:neo4j-sproc-compiler,代码行数:15,代码来源:DsvSerializer.java

示例8: isEmulated

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
public static boolean isEmulated(QualifiedNameable nameable) {
    String name = nameable.getQualifiedName().toString();
    for(String emul : emuls) {
        if (name.startsWith(emul)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:BenDol,项目名称:Databind,代码行数:10,代码来源:Emulation.java

示例9: getQualifiedName

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
private static String getQualifiedName(Element element) {
    switch (element.getKind()) {
        case CLASS:
            // Mirror API sucks, return proper qualified name for inner classes
            if (element.getEnclosingElement().getKind() == ElementKind.CLASS) {
                return getQualifiedName(element.getEnclosingElement()) + '$' + element.getSimpleName();
            } else {
                return ((QualifiedNameable) element).getQualifiedName().toString();
            }
        case METHOD:
            return getQualifiedName(element.getEnclosingElement()) + ':' + element.getSimpleName().toString();
        default:
            throw new UnsupportedOperationException(element.getClass().toString());
    }
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:16,代码来源:EventProcessor.java

示例10: resolveType

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
@Override
protected TreeBackedResolvedType resolveType(
    TreePath referencingPath, TypeElement referencedType, QualifiedNameable canonicalType) {
  if (canonicalType == null) {
    canonicalType = referencedType;
  }
  return new TreeBackedResolvedType(
      referencingPath,
      canonicalType,
      resolveEnclosingElement((QualifiedNameable) canonicalType.getEnclosingElement()));
}
 
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:TreeBackedTypeResolutionSimulator.java

示例11: getFullyQualifiedName

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
private Name getFullyQualifiedName(
    @Nullable QualifiedNameable enclosingElement, Name simpleName) {
  for (int i = 0; i < simpleName.length(); i++) {
    if (simpleName.charAt(i) == '.') {
      throw new IllegalArgumentException(String.format("%s is not a simple name", simpleName));
    }
  }

  if (enclosingElement == null || enclosingElement.getQualifiedName().length() == 0) {
    return simpleName;
  } else {
    return getName(String.format("%s.%s", enclosingElement.getQualifiedName(), simpleName));
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:15,代码来源:TreeBackedElements.java

示例12: handleImport

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
private static void handleImport(Trees trees, ImportsTracker imports, TreePath importTreePath) {
  ImportTree importTree = (ImportTree) importTreePath.getLeaf();
  MemberSelectTree importedExpression = (MemberSelectTree) importTree.getQualifiedIdentifier();
  TreePath importedExpressionPath = new TreePath(importTreePath, importedExpression);
  Name simpleName = importedExpression.getIdentifier();
  boolean isStarImport = simpleName.contentEquals("*");

  if (!isStarImport && !importTree.isStatic()) {
    TypeElement importedType = (TypeElement) trees.getElement(importedExpressionPath);
    imports.importType(importedType, importedExpressionPath);
  } else {
    ExpressionTree containingElementExpression = importedExpression.getExpression();
    TreePath containingElementExpressionPath =
        new TreePath(importedExpressionPath, containingElementExpression);
    QualifiedNameable containingElement =
        (QualifiedNameable) trees.getElement(containingElementExpressionPath);

    if (importTree.isStatic()) {
      TypeElement containingType = (TypeElement) containingElement;
      if (isStarImport) {
        imports.importStaticMembers((TypeElement) containingElement);
      } else {
        imports.importStatic(containingType, simpleName);
      }
    } else {
      // Normal star import
      imports.importMembers(containingElement, containingElementExpressionPath);
    }
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:31,代码来源:ImportsTrackerTestHelper.java

示例13: registerClass

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
public void registerClass(String parent, String clazz, ClassTree tree, boolean modified) {
    if (clazz == null) return;
    
    Element myself = ASTService.getElementImpl(tree);

    boolean newOrModified =    myself == null
                            || (!myself.getKind().isClass() && !myself.getKind().isInterface())
                            || !((QualifiedNameable) myself).getQualifiedName().contentEquals(clazz);

    if (newOrModified || class2Enclosed.containsKey(parent)) {
        List<String> c = class2Enclosed.get(parent);

        if (c == null) {
            class2Enclosed.put(parent, c = new ArrayList<String>());
        }

        c.add(clazz);
    }

    if (modified) {
        class2Enclosed.put(clazz, new ArrayList<String>());
    }

    Set<String> superFQNs = superFQNs(tree);

    boolean hadObject = superFQNs.remove("java.lang.Object");

    Set<String> original;

    if (!newOrModified) {
        original = new LinkedHashSet<String>();

        TypeElement tel = (TypeElement) myself;

        if (tel.getSuperclass() != null && tel.getSuperclass().getKind() == TypeKind.DECLARED) {
            original.add(((TypeElement) ((DeclaredType) tel.getSuperclass()).asElement()).getQualifiedName().toString());
        }

        for (TypeMirror intf : tel.getInterfaces()) {
            original.add(((TypeElement) ((DeclaredType) intf).asElement()).getQualifiedName().toString());
        }

        original.remove("java.lang.Object");
    } else {
        original = null;
    }

    if (!superFQNs.equals(original)) {
        if (hadObject) superFQNs.add("java.lang.Object");
        
        Set<Modifier> mods = EnumSet.noneOf(Modifier.class);

        mods.addAll(tree.getModifiers().getFlags());
        classes.put(clazz, mods);
        class2SuperElementTrees.put(clazz, superFQNs);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:ElementOverlay.java

示例14: getEnclosingElement

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
@Override
public Element getEnclosingElement() {
    return ElementOverlay.this.resolve(ast, elements, ((QualifiedNameable/*XXX*/) delegateTo.getEnclosingElement()).getQualifiedName().toString(), moduleOf(elements, delegateTo));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ElementOverlay.java

示例15: toPropertyMetadata

import javax.lang.model.element.QualifiedNameable; //导入依赖的package包/类
protected CompiledPropertyMetadata toPropertyMetadata(VariableElement element, AnnotationMirror propertyAnnotation)
{
	Map<? extends ExecutableElement, ? extends AnnotationValue> annotationValues = processingEnv.getElementUtils().getElementValuesWithDefaults(propertyAnnotation);
	
	CompiledPropertyMetadata property = new CompiledPropertyMetadata();
	
	String propName = (String) annotationValue(annotationValues, "name").getValue();
	if (propName == null || propName.isEmpty())
	{
		propName = (String) element.getConstantValue();
		if (propName == null)
		{
			processingEnv.getMessager().printMessage(Kind.WARNING, "Failed to read constant value for " + element, 
					element);
			return null;
		}
	}
	property.setName(propName);
	
	boolean deprecated = processingEnv.getElementUtils().isDeprecated(element);
	property.setDeprecated(deprecated);
	
	QualifiedNameable enclosingElement = (QualifiedNameable) element.getEnclosingElement();
	property.setConstantDeclarationClass(enclosingElement.getQualifiedName().toString());
	property.setConstantFieldName(element.getSimpleName().toString());
	
	property.setCategory((String) annotationValue(annotationValues, "category").getValue());
	property.setDefaultValue((String) annotationValue(annotationValues, "defaultValue").getValue());
	property.setSinceVersion((String) annotationValue(annotationValues, "sinceVersion").getValue());
	property.setValueType(((TypeMirror) annotationValue(annotationValues, "valueType").getValue()).toString());
	
	@SuppressWarnings("unchecked")
	List<? extends AnnotationValue> scopeValues = (List<? extends AnnotationValue>) annotationValue(annotationValues, "scopes").getValue();
	List<PropertyScope> propertyScopes = new ArrayList<>(scopeValues.size());
	for (AnnotationValue scopeValue : scopeValues)
	{
		PropertyScope scope = Enum.valueOf(PropertyScope.class, ((VariableElement) scopeValue.getValue()).getSimpleName().toString());
		propertyScopes.add(scope); 
	}
	
	//automatically adding Global if Context is present
	int contextIndex = propertyScopes.indexOf(PropertyScope.CONTEXT);
	if (contextIndex >= 0 && !propertyScopes.contains(PropertyScope.GLOBAL))
	{
		propertyScopes.add(contextIndex, PropertyScope.GLOBAL);
	}
	property.setScopes(propertyScopes);
	
	@SuppressWarnings("unchecked")
	List<? extends AnnotationValue> scopeQualificationValues = (List<? extends AnnotationValue>) annotationValue(annotationValues, "scopeQualifications").getValue();
	List<String> scopeQualifications = new ArrayList<>(scopeValues.size());
	for (AnnotationValue qualificationValue : scopeQualificationValues)
	{
		String qualification = (String) qualificationValue.getValue();
		scopeQualifications.add(qualification);
	}
	property.setScopeQualifications(scopeQualifications);
	
	return property;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:61,代码来源:PropertyProcessor.java


注:本文中的javax.lang.model.element.QualifiedNameable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。