本文整理汇总了Java中org.openide.text.PositionBounds类的典型用法代码示例。如果您正苦于以下问题:Java PositionBounds类的具体用法?Java PositionBounds怎么用?Java PositionBounds使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PositionBounds类属于org.openide.text包,在下文中一共展示了PositionBounds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPosition
import org.openide.text.PositionBounds; //导入依赖的package包/类
@Override
public PositionBounds getPosition() {
try {
DataObject dobj = DataObject.find(getParentFile());
if (dobj != null) {
EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getLookup().lookup(EditorCookie.Observable.class);
if (obs != null && obs instanceof CloneableEditorSupport) {
CloneableEditorSupport supp = (CloneableEditorSupport)obs;
PositionBounds bounds = new PositionBounds(
supp.createPositionRef(loc[0], Position.Bias.Forward),
supp.createPositionRef(Math.max(loc[0], loc[1]), Position.Bias.Forward)
);
return bounds;
}
}
} catch (DataObjectNotFoundException ex) {
LOG.log(Level.INFO, "Can't resolve", ex);//NOI18N
}
return null;
}
示例2: getPositionBounds
import org.openide.text.PositionBounds; //导入依赖的package包/类
/**
*@return PositionBounds representing the position of the name of the entity that is being
* refactored or PostionBounds representing the start of the file if the position
* of the entity could not be resolved.
*/
public PositionBounds getPositionBounds(){
if (elementName != null){
try {
BaseDocument doc = getDocument();
String text = doc.getText(0, doc.getLength());
int offset = text.indexOf(elementName);
if (offset > -1){
PositionRef start = editorSupport.createPositionRef(offset, Bias.Forward);
PositionRef end = editorSupport.createPositionRef(offset + elementName.length(), Bias.Backward);
return new PositionBounds(start, end);
}
} catch (BadLocationException ex) {
ErrorManager.getDefault().notify(ex);
}
}
return getDefaultPositionBounds();
}
示例3: linePart
import org.openide.text.PositionBounds; //导入依赖的package包/类
public static PositionBounds linePart(FileObject file, int start, int end) {
try {
DataObject od = DataObject.find(file);
if (od == null)
return null;
EditorCookie ec = od.getCookie(EditorCookie.class);
if (!(ec instanceof CloneableEditorSupport)) {
return null;
}
final CloneableEditorSupport ces = (CloneableEditorSupport) ec;
checkOffsetsAndLog(start, end);
return new PositionBounds(ces.createPositionRef(start, Position.Bias.Forward), ces.createPositionRef(end, Position.Bias.Backward));
} catch (IOException e) {
LOG.log(Level.INFO, null, e);
return null;
}
}
示例4: getToolTip
import org.openide.text.PositionBounds; //导入依赖的package包/类
public String getToolTip() {
if (tooltip==null) {
if (userObject instanceof TreeElement) {
Object re = ((TreeElement) userObject).getUserObject();
if (re instanceof RefactoringElement) {
RefactoringElement ree = (RefactoringElement) re;
PositionBounds bounds = getPosition();
FileObject file = ree.getParentFile();
if (bounds != null && file!=null) {
int line;
try {
line = bounds.getBegin().getLine() + 1;
} catch (IOException ioe) {
return null;
}
tooltip = FileUtil.getFileDisplayName(file) + ':' + line;
}
}
}
}
return tooltip;
}
示例5: createClassOccurrence
import org.openide.text.PositionBounds; //导入依赖的package包/类
private Occurrence createClassOccurrence(String matched, SpringBean bean) throws BadLocationException {
Location loc = bean.getLocation();
if (loc == null) {
return null;
}
int startOffset = loc.getOffset();
if (startOffset == -1) {
return null;
}
AttributeValueFinder finder = new AttributeValueFinder(syntaxSupport, startOffset); // NOI18N
if (!finder.find("class")) {
return null;
}
int foundOffset = finder.getFoundOffset();
String foundValue = finder.getValue();
int index = foundValue.indexOf(matched);
if (index == -1) {
return null;
}
String displayText = createClassDisplayText(finder, foundValue, index, matched.length());
PositionRef startRef = docAccess.createPositionRef(foundOffset + index, Bias.Forward);
PositionRef endRef = docAccess.createPositionRef(foundOffset + index + matched.length(), Bias.Backward);
return new JavaElementRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef));
}
示例6: getPosition
import org.openide.text.PositionBounds; //导入依赖的package包/类
public PositionBounds getPosition() {
try {
DataObject dobj = DataObject.find(getParentFile());
if (dobj != null) {
EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getCookie(EditorCookie.Observable.class);
if (obs != null && obs instanceof CloneableEditorSupport) {
CloneableEditorSupport supp = (CloneableEditorSupport)obs;
if (loc == null) {
loc = location();
}
PositionBounds bounds = new PositionBounds(
supp.createPositionRef(loc[0], Position.Bias.Forward),
supp.createPositionRef(Math.max(loc[0], loc[1]), Position.Bias.Forward)
);
return bounds;
}
}
} catch (DataObjectNotFoundException ex) {
ex.printStackTrace();
}
return null;
}
示例7: ErrorDescriptionNode
import org.openide.text.PositionBounds; //导入依赖的package包/类
public ErrorDescriptionNode(AnalyzerFactory provider, final ErrorDescription ed) {
super(Children.LEAF, Lookups.fixed(ed, new OpenErrorDescription(provider, ed), new DescriptionReader() {
@Override public CharSequence getDescription() {
return ed.getDetails();
}
}));
int line = -1;
try {
final PositionBounds range = ed.getRange();
if (range != null) {
line = range.getBegin().getLine();
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
setDisplayName((line != (-1) ? (line + 1 + ":") : "") + ed.getDescription());
icon = SPIAccessor.ACCESSOR.getAnalyzerIcon(provider);
}
示例8: WhereUsedElement
import org.openide.text.PositionBounds; //导入依赖的package包/类
public WhereUsedElement(PositionBounds bounds, String htmlText, String elementText, FileObject parentFile, TreePath tp, CompilationInfo info, ReadWrite access, boolean inTestclass, boolean inPlatform, boolean inDependency, boolean inComment, boolean inImport) {
this.bounds = bounds;
this.htmlText = htmlText;
this.elementText = elementText;
this.parentFile = parentFile;
if (tp != null) {
ElementGripFactory.getDefault().put(parentFile, tp, info);
}
ElementGripFactory.getDefault().put(parentFile, inTestclass);
this.access = access;
this.inTestclass = inTestclass;
this.inPlatform = inPlatform;
this.inDependency = inDependency;
this.inComment = inComment;
this.inImport = inImport;
}
示例9: checkChange
import org.openide.text.PositionBounds; //导入依赖的package包/类
private boolean checkChange(FileObject bifile, final PositionBounds span) {
final boolean[] result = new boolean[]{false};
JavaSource js = JavaSource.forFileObject(bifile);
if (js != null) {
try {
js.runUserActionTask(new Task<CompilationController>() {
public void run(CompilationController javac) throws Exception {
javac.toPhase(JavaSource.Phase.RESOLVED);
result[0] = checkChange(javac, span);
}
}, true);
} catch (IOException ex) {
// XXX create Problem?
Exceptions.printStackTrace(ex);
}
}
return result[0];
}
示例10: prepareSpansFor
import org.openide.text.PositionBounds; //导入依赖的package包/类
public static List<PositionBounds> prepareSpansFor(FileObject file, Iterable<? extends int[]> spans) {
List<PositionBounds> result = new ArrayList<PositionBounds>();
try {
DataObject d = DataObject.find(file);
EditorCookie ec = d.getLookup().lookup(EditorCookie.class);
CloneableEditorSupport ces = (CloneableEditorSupport) ec;
result = new LinkedList<PositionBounds>();
for (int[] span : spans) {
PositionRef start = ces.createPositionRef(span[0], Bias.Forward);
PositionRef end = ces.createPositionRef(span[1], Bias.Forward);
result.add(new PositionBounds(start, end));
}
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
return result;
}
示例11: getPosition
import org.openide.text.PositionBounds; //导入依赖的package包/类
public final PositionBounds getPosition() {
try {
return new PositionBoundsResolver(DataObject.find(parentFile), clazz).getPositionBounds();
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}
示例12: fullLine
import org.openide.text.PositionBounds; //导入依赖的package包/类
public static PositionBounds fullLine(final Document doc, final int lineNumber) {
final PositionBounds[] result = new PositionBounds[1];
doc.render(new Runnable() {
@Override public void run() {
result[0] = fullLineImpl(doc, lineNumber);
}
});
return result[0];
}
示例13: fullLineImpl
import org.openide.text.PositionBounds; //导入依赖的package包/类
private static PositionBounds fullLineImpl(Document doc, int lineNumber) {
DataObject file = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
if (file == null)
return null;
try {
int[] span = computeLineSpan(doc, lineNumber);
return linePart(file.getPrimaryFile(), span[0], span[1]);
} catch (BadLocationException e) {
Exceptions.printStackTrace(e);
return null;
}
}
示例14: ErrorDescription
import org.openide.text.PositionBounds; //导入依赖的package包/类
/**
* The constructor is intentionally not public. Use
* {@link ErrorDescriptionFactory} when you need an instance of this class.
*/
ErrorDescription(FileObject file, String id, String description, CharSequence details, Severity severity, LazyFixList fixes, PositionBounds span) {
this.id = id;
this.description = description;
this.details = details;
this.severity = severity;
this.customType = null;
this.fixes = fixes;
this.span = span;
this.file = file;
}
示例15: getPosition
import org.openide.text.PositionBounds; //导入依赖的package包/类
public PositionBounds getPosition() {
if (userObject instanceof TreeElement) {
Object re = ((TreeElement) userObject).getUserObject();
if (re instanceof RefactoringElement)
return ((RefactoringElement) re).getPosition();
}
return null;
}