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


Java IJavaElement.isReadOnly方法代碼示例

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


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

示例1: isAvailable

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
private static boolean isAvailable(IJavaElement javaElement) throws JavaModelException {
	if (javaElement == null) {
		return false;
	}
	if (!javaElement.exists()) {
		return false;
	}
	if (javaElement.isReadOnly()) {
		return false;
	}
	// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=48422
	// the Java project is now cheating regarding its children so we shouldn't
	// call isStructureKnown if the project isn't open.
	// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=52474
	if (!(javaElement instanceof IJavaProject) && !(javaElement instanceof ILocalVariable) && !javaElement.isStructureKnown()) {
		return false;
	}
	if (javaElement instanceof IMember && ((IMember) javaElement).isBinary()) {
		return false;
	}
	return true;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:23,代碼來源:GetterSetterCorrectionSubProcessor.java

示例2: collectCompilationUnits

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
/**
 * A recursive traversal of the IJavaModel to collect all ICompilationUnits. Each compilation unit corresponds to
 * each java file.
 * 
 * @param javaElement a node in the IJavaModel that will be traversed
 * @return a list of compilation units
 */
private static List<ICompilationUnit> collectCompilationUnits(IJavaElement javaElement) {
	List<ICompilationUnit> list = null, temp = null;
	// We are traversing the JavaModel for COMPILATION_UNITs
	if (javaElement.getElementType() == IJavaElement.COMPILATION_UNIT) {
		list = new ArrayList<ICompilationUnit>();
		list.add((ICompilationUnit) javaElement);
		return list;
	}

	// Non COMPILATION_UNITs will have to be further traversed
	if (javaElement instanceof IParent) {
		IParent parent = (IParent) javaElement;

		// Do not traverse PACKAGE_FRAGMENT_ROOTs that are ReadOnly
		if ((javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT) && javaElement.isReadOnly()) {
			return null;
		}

		// Traverse
		try {
			if (parent.hasChildren()) {
				IJavaElement[] children = parent.getChildren();
				for (int i = 0; i < children.length; i++) {
					temp = WorkspaceUtilities.collectCompilationUnits(children[i]);
					if (temp != null) {
						if (list == null) {
							list = temp;
						}
						else {
							list.addAll(temp);
						}
					}
				}
			}
		}
		catch (JavaModelException jme) {
			System.out.println("JAVA MODEL EXCEPTION: " + jme);
			return null;
		}
	}
	else {
		throw new CrystalRuntimeException("There exists an IJavaElement that is not an instance of IParent!");
	}

	return list;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:54,代碼來源:WorkspaceUtilities.java


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