|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.tasklist.javaparser; import javax.swing.text.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.List; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import org.openide.ErrorManager; import org.openide.cookies.SourceCookie; import org.openide.explorer.view.*; import org.openide.nodes.*; import org.netbeans.modules.java.*; import org.openide.src.Identifier; import org.openide.src.Import; import org.openide.src.SourceElement; import org.openide.src.SourceException; import org.openide.util.NbBundle; import org.openide.util.Utilities; import org.openide.cookies.LineCookie; import org.openide.loaders.DataObject; import org.openide.text.Line; import org.openide.ErrorManager; import java.util.TreeSet; import java.lang.reflect.Modifier; import org.netbeans.editor.ext.java.*; import org.netbeans.modules.editor.java.*; import org.netbeans.modules.tasklist.core.ConfPanel; import org.netbeans.modules.tasklist.core.TLUtils; import org.netbeans.modules.tasklist.client.Suggestion; import org.netbeans.modules.tasklist.client.SuggestionPerformer; /** * This class performs symbol replacement suggestions * * @author Tor Norbye */ class ReplaceSymbolPerformer implements SuggestionPerformer { private int lineno; private int col; private Line line; private DataObject dobj; private Document doc; private String oldSymbol; private String newSymbol; private String beforeDesc; private String afterDesc; private JCClass importClass; private boolean makeMethod; ReplaceSymbolPerformer(int lineno, int col, Line line, DataObject dobj, Document doc, String oldSymbol, String newSymbol, String beforeDesc, String afterDesc, JCClass importClass, boolean makeMethod) { this.lineno = lineno; this.col = col; this.line = line; this.dobj = dobj; this.doc = doc; this.oldSymbol = oldSymbol; this.newSymbol = newSymbol; this.beforeDesc = beforeDesc; this.afterDesc = afterDesc; this.importClass = importClass; this.makeMethod = false; } // Yay - it's a casing-error public void perform(Suggestion s) { if (makeMethod) { makeMethod(); } else { replaceSymbol(); if (importClass != null) { ImportPerformer.importClass(doc, importClass); } } } public boolean hasConfirmation() { return true; } public Object getConfirmation(Suggestion s) { String filename = dobj.getPrimaryFile().getNameExt(); StringBuffer sb = new StringBuffer(200); Line l = line; String text = l.getText(); // Underline differences int fd = TLUtils.firstDiff(oldSymbol, newSymbol); int ldo = oldSymbol.length()- TLUtils.lastDiff(oldSymbol, newSymbol); int ldn = newSymbol.length() - TLUtils.lastDiff(oldSymbol, newSymbol); sb.append(""); // NOI18N TLUtils.appendSurroundingLine(sb, l, -1); JPUtils.replaceSymbol(sb, text, col, oldSymbol, oldSymbol, true, fd, ldo); TLUtils.appendSurroundingLine(sb, l, +1); sb.append(""); // NOI18N String beforeContents = sb.toString(); sb.setLength(0); sb.append(""); if (importClass != null) { sb.append("import "); // NOI18N sb.append(importClass.toString()); sb.append("; |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.