List of usage examples for org.eclipse.jdt.core IType getOpenable
IOpenable getOpenable();
From source file:com.siteview.mde.internal.ui.util.PDEJavaHelperUI.java
License:Open Source License
public static String getJavaDoc(String constant, IJavaProject jp, String className) { HashMap map = (HashMap) fDocMap.get(className); if (map == null) fDocMap.put(className, map = new HashMap()); String javaDoc = (String) map.get(constant); if (javaDoc == null) { try {//from w w w .j a va 2s . c o m IType type = jp.findType(className); if (type != null) { char[] chars = constant.toCharArray(); for (int i = 0; i < chars.length; i++) chars[i] = chars[i] == '-' ? '_' : Character.toUpperCase(chars[i]); IField field = type.getField(new String(chars)); ISourceRange range = field.getJavadocRange(); if (range == null) return null; IBuffer buff = type.getOpenable().getBuffer(); JavaDocCommentReader reader = new JavaDocCommentReader(buff, range.getOffset(), range.getOffset() + range.getLength() - 1); String text = getString(reader); javaDoc = formatJavaDoc(text); map.put(constant, javaDoc); } } catch (JavaModelException e) { } } return javaDoc; }
From source file:de.tobject.findbugs.reporter.MarkerUtil.java
License:Open Source License
@SuppressWarnings("restriction") private static char[] getContent(IType source) throws JavaModelException { char[] charContent = null; IOpenable op = source.getOpenable(); if (op instanceof CompilationUnit) { charContent = ((CompilationUnit) (op)).getContents(); }//w w w .j a v a 2 s.c o m if (charContent == null) { String content = source.getSource(); if (content != null) { charContent = content.toCharArray(); } } return charContent; }
From source file:org.eclipse.objectteams.otdt.core.search.OTSearchRequestor.java
License:Open Source License
public void acceptSearchMatch(SearchMatch match) throws CoreException { IType javaType = null; Object element = match.getElement(); if (element instanceof IType) javaType = (IType) element;// w w w. j a v a 2 s. c o m else if (match.getResource() != null) { IJavaElement jel = JavaCore.create(match.getResource()); if (jel.getElementType() == IJavaElement.TYPE) javaType = (IType) jel; } if (javaType != null) { IOTType otType = OTModelManager.getOTElement(javaType); if (otType == null) { try { int modifiers = javaType.getFlags(); if (Flags.isTeam(modifiers) || Flags.isRole(modifiers)) { javaType.getOpenable().open(null); otType = OTModelManager.getOTElement(javaType); } } catch (JavaModelException ex) { // ignore -- element probably not present (e.g. because of __OT__RoleClass looking for its source) } } if (otType != null) this.otTypes.add(otType); } }
From source file:org.eclipse.pde.internal.ui.util.PDEJavaHelperUI.java
License:Open Source License
public static String getJavaDoc(String constant, IJavaProject jp, String className) { HashMap<String, String> map = fDocMap.get(className); if (map == null) fDocMap.put(className, map = new HashMap<String, String>()); String javaDoc = map.get(constant); if (javaDoc == null) { try {/*from w w w . j ava2 s . c om*/ IType type = jp.findType(className); if (type != null) { char[] chars = constant.toCharArray(); for (int i = 0; i < chars.length; i++) chars[i] = chars[i] == '-' ? '_' : Character.toUpperCase(chars[i]); IField field = type.getField(new String(chars)); ISourceRange range = field.getJavadocRange(); if (range == null) return null; IBuffer buff = type.getOpenable().getBuffer(); JavaDocCommentReader reader = new JavaDocCommentReader(buff, range.getOffset(), range.getOffset() + range.getLength() - 1); String text = getString(reader); javaDoc = formatJavaDoc(text); map.put(constant, javaDoc); } } catch (JavaModelException e) { } } return javaDoc; }
From source file:org.seasar.resource.synchronizer.servlet.SelectionServlet.java
License:Apache License
private IDocument toDocument(final IType type) throws JavaModelException { IDocument document = null;/*from w ww . j a va 2s .co m*/ if (type.isBinary()) { IPackageFragmentRoot root = (IPackageFragmentRoot) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IPath path = root.getSourceAttachmentPath(); if (path != null) { IOpenable o = type.getOpenable(); IBuffer buf = o.getBuffer(); if (buf != null) { document = new Document(buf.getContents()); } } } else { document = new Document(type.getCompilationUnit().getSource()); } return document; }