@Override public Color getForeground(Object element) { if (element instanceof ISourceReference) { ISourceReference sref = (ISourceReference) element; if (!sref.isActive()) { if (fInactiveColor == null && Display.getCurrent() != null) { fInactiveColor = CUIPlugin.getStandardDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); } return fInactiveColor; } } return null; }
/** * Method getPosition. Get position for workspace C and C++ source files * * @param aSelectedElement org.eclipse.cdt.core.model.ISourceReference * @param aFile IFile * @return TextPosition * @throws CoreException */ public static R4EUITextPosition getPosition( org.eclipse.cdt.core.model.ISourceReference aSelectedElement, IFile aFile) // $codepro.audit.disable overloadedMethods throws CoreException { int startPos = 0; int length = 0; int startLine = 0; int endLine = 0; String name = ""; if (null != aSelectedElement) { final org.eclipse.cdt.core.model.ISourceRange sourceRange = aSelectedElement.getSourceRange(); if (null != sourceRange) { startPos = sourceRange.getStartPos(); length = sourceRange.getLength(); startLine = sourceRange.getStartLine(); endLine = sourceRange.getEndLine(); } name = ((org.eclipse.cdt.core.model.ICElement) aSelectedElement).getElementName(); } final R4EUITextPosition position = new R4EUITextPosition(startPos, length, aFile); position.setStartLine(startLine); position.setEndLine(endLine); position.setName(name); return position; }
private String getLocationSignature(ISourceReference elem) { ITranslationUnit tu = elem.getTranslationUnit(); ISourceRange sourceRange; try { sourceRange = elem.getSourceRange(); if (tu != null && sourceRange != null) { return tu.getPath().toString() + IPath.SEPARATOR + sourceRange.getIdStartPos() + IPath.SEPARATOR + sourceRange.getIdLength(); } } catch (CoreException e) { CUIPlugin.log(e); } return null; }