當前位置: 首頁>>代碼示例>>Java>>正文


Java IJavaElement.PACKAGE_DECLARATION屬性代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.IJavaElement.PACKAGE_DECLARATION屬性的典型用法代碼示例。如果您正苦於以下問題:Java IJavaElement.PACKAGE_DECLARATION屬性的具體用法?Java IJavaElement.PACKAGE_DECLARATION怎麽用?Java IJavaElement.PACKAGE_DECLARATION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.eclipse.jdt.core.IJavaElement的用法示例。


在下文中一共展示了IJavaElement.PACKAGE_DECLARATION屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTarget

/**
 * Returns the target of this resource change.
 * @param elem the changed element
 * @return the target of the change, or an empty string if the target is not either a project, package, or file
 */
private String getTarget(IJavaElement elem) {
    if (elem == null) {
        return "";
    }
    
    int type = elem.getElementType();
    if (type == IJavaElement.JAVA_PROJECT) {
        return "Project";
        
    } else if (type == IJavaElement.PACKAGE_DECLARATION) {
        return "Package";
        
    } else if (type == IJavaElement.COMPILATION_UNIT) {
        return "File";
    }
    
    return elem.getElementName() + "@" + elem.getElementType();
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:23,代碼來源:ResourceMacro.java

示例2: getName

/**
 * Obtains the name of the specified element.
 * @param elem the element
 * @param type the type of the element
 * @return the name string
 */
public static String getName(IJavaElement elem) {
    int type = elem.getElementType();
    if (type == IJavaElement.JAVA_PROJECT) {
        return elem.getResource().getName();
        
    } else if (type == IJavaElement.PACKAGE_DECLARATION) {
        IPackageFragment jpackage = (IPackageFragment)elem;
        return jpackage.getElementName();
        
    } else if (type == IJavaElement.COMPILATION_UNIT) {
        return elem.getResource().getName();
    }
    
    return "";
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:21,代碼來源:ResourceMacro.java

示例3: mapKind

public static SymbolKind mapKind(IJavaElement element) {
	switch (element.getElementType()) {
	case IJavaElement.ANNOTATION:
		return SymbolKind.Property; // TODO: find a better mapping
	case IJavaElement.CLASS_FILE:
	case IJavaElement.COMPILATION_UNIT:
		return SymbolKind.File;
	case IJavaElement.FIELD:
		return SymbolKind.Field;
	case IJavaElement.IMPORT_CONTAINER:
	case IJavaElement.IMPORT_DECLARATION:
		return SymbolKind.Module;
	case IJavaElement.INITIALIZER:
		return SymbolKind.Constructor;
	case IJavaElement.LOCAL_VARIABLE:
	case IJavaElement.TYPE_PARAMETER:
		return SymbolKind.Variable;
	case IJavaElement.METHOD:
		return SymbolKind.Method;
	case IJavaElement.PACKAGE_DECLARATION:
		return SymbolKind.Package;
	case IJavaElement.TYPE:
		try {
			return ( ((IType)element).isInterface() ? SymbolKind.Interface : SymbolKind.Class);
		} catch (JavaModelException e) {
			return SymbolKind.Class;
		}
	}
	return SymbolKind.String;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:30,代碼來源:DocumentSymbolHandler.java

示例4: appendElementLabel

/**
 * Appends the label for a Java element with the flags as defined by this class.
 *
 * @param element the element to render
 * @param flags the rendering flags.
 */
public void appendElementLabel(IJavaElement element, long flags) {
	int type= element.getElementType();
	IPackageFragmentRoot root= null;

	if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
		root= JavaModelUtil.getPackageFragmentRoot(element);
	}
	if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) {
		appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
		fBuilder.append(JavaElementLabels.CONCAT_STRING);
	}

	switch (type) {
	case IJavaElement.METHOD:
		appendMethodLabel((IMethod) element, flags);
		break;
	case IJavaElement.FIELD:
		appendFieldLabel((IField) element, flags);
		break;
	case IJavaElement.LOCAL_VARIABLE:
		appendLocalVariableLabel((ILocalVariable) element, flags);
		break;
	case IJavaElement.TYPE_PARAMETER:
		appendTypeParameterLabel((ITypeParameter) element, flags);
		break;
	case IJavaElement.INITIALIZER:
		appendInitializerLabel((IInitializer) element, flags);
		break;
	case IJavaElement.TYPE:
		appendTypeLabel((IType) element, flags);
		break;
	case IJavaElement.CLASS_FILE:
		appendClassFileLabel((IClassFile) element, flags);
		break;
	case IJavaElement.COMPILATION_UNIT:
		appendCompilationUnitLabel((ICompilationUnit) element, flags);
		break;
	case IJavaElement.PACKAGE_FRAGMENT:
		appendPackageFragmentLabel((IPackageFragment) element, flags);
		break;
	case IJavaElement.PACKAGE_FRAGMENT_ROOT:
		appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags);
		break;
	case IJavaElement.IMPORT_CONTAINER:
	case IJavaElement.IMPORT_DECLARATION:
	case IJavaElement.PACKAGE_DECLARATION:
		appendDeclarationLabel(element, flags);
		break;
	case IJavaElement.JAVA_PROJECT:
	case IJavaElement.JAVA_MODEL:
		fBuilder.append(element.getElementName());
		break;
	default:
		fBuilder.append(element.getElementName());
	}

	if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) {
		fBuilder.append(JavaElementLabels.CONCAT_STRING);
		appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:67,代碼來源:JavaElementLabelComposer.java


注:本文中的org.eclipse.jdt.core.IJavaElement.PACKAGE_DECLARATION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。