diff --git a/pom.xml b/pom.xml index c40ad2d..5d12bc4 100644 --- a/pom.xml +++ b/pom.xml @@ -802,7 +802,7 @@ target/keystore RELEASE200 - 1.7 + 1.8 https://github.com/albilu/netbeansPython https://github.com/albilu/netbeansPython.git UTF-8 diff --git a/ppuc/13/updates.xml b/ppuc/13/updates.xml index 22d623a..a480b21 100644 --- a/ppuc/13/updates.xml +++ b/ppuc/13/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/14/updates.xml b/ppuc/14/updates.xml index b641f89..46762a5 100644 --- a/ppuc/14/updates.xml +++ b/ppuc/14/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/15/updates.xml b/ppuc/15/updates.xml index b35231e..dccfc40 100644 --- a/ppuc/15/updates.xml +++ b/ppuc/15/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/16/updates.xml b/ppuc/16/updates.xml index 321b918..f77bcaf 100644 --- a/ppuc/16/updates.xml +++ b/ppuc/16/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/17/updates.xml b/ppuc/17/updates.xml index fde88c3..8e3ebcc 100644 --- a/ppuc/17/updates.xml +++ b/ppuc/17/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/18/updates.xml b/ppuc/18/updates.xml index c024201..d7472de 100644 --- a/ppuc/18/updates.xml +++ b/ppuc/18/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/19/updates.xml b/ppuc/19/updates.xml index b2b6791..f0d6b59 100644 --- a/ppuc/19/updates.xml +++ b/ppuc/19/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/ppuc/20/updates.xml b/ppuc/20/updates.xml index 2ab5a19..455c48e 100644 --- a/ppuc/20/updates.xml +++ b/ppuc/20/updates.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/src/main/java/org/netbeans/modules/python/debugger/PythonDebugger.java b/src/main/java/org/netbeans/modules/python/debugger/PythonDebugger.java index ff739a8..934d76e 100644 --- a/src/main/java/org/netbeans/modules/python/debugger/PythonDebugger.java +++ b/src/main/java/org/netbeans/modules/python/debugger/PythonDebugger.java @@ -118,6 +118,7 @@ public static void startDebugger(Project owner, DataObject dob, boolean singleFi io = IOProvider.getDefault().getIO(String.format("%s (%s)", Bundle.CTL_SessionName(), sessionName), false); + io.setInputVisible(true); io.select(); pdbClient = new PdbClient(process, /*loggingPtyProcessTtyConnector,*/ io); diff --git a/src/main/java/org/netbeans/modules/python/debugger/pdb/PdbClient.java b/src/main/java/org/netbeans/modules/python/debugger/pdb/PdbClient.java index ff01e6f..d57e751 100644 --- a/src/main/java/org/netbeans/modules/python/debugger/pdb/PdbClient.java +++ b/src/main/java/org/netbeans/modules/python/debugger/pdb/PdbClient.java @@ -27,6 +27,7 @@ import org.openide.text.Annotatable; import org.openide.text.Line; import org.openide.util.Exceptions; +import org.openide.util.RequestProcessor; import org.openide.windows.IOColorLines; import org.openide.windows.InputOutput; @@ -45,12 +46,17 @@ public class PdbClient { InputOutput io; private final BufferedWriter writer; private final BufferedReader reader; + private final BufferedReader ioReader; public PdbClient(Process process, InputOutput io) { this.process = process; this.io = io; writer = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + ioReader = new BufferedReader(this.io.getIn()); + RequestProcessor.getDefault().post(() -> { + handleIoInput(); + }); } public Process getProcess() { @@ -215,4 +221,18 @@ public boolean isSuspended() { return isStopped; } + private void handleIoInput() { + try { + try (ioReader) { + String line; + while ((line = ioReader.readLine()) != null) { + // Process each line of input as needed + writeToStream(line); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } diff --git a/src/main/java/org/netbeans/modules/python/indexing/PythonCustomIndexer.java b/src/main/java/org/netbeans/modules/python/indexing/PythonCustomIndexer.java index 24a3a0a..9a83aef 100644 --- a/src/main/java/org/netbeans/modules/python/indexing/PythonCustomIndexer.java +++ b/src/main/java/org/netbeans/modules/python/indexing/PythonCustomIndexer.java @@ -1,154 +1,154 @@ -package org.netbeans.modules.python.indexing; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.MatchResult; -import java.util.regex.Pattern; -import javax.swing.text.BadLocationException; -import javax.swing.text.StyledDocument; -import org.apache.commons.lang3.StringUtils; -import org.netbeans.api.project.FileOwnerQuery; -import org.netbeans.api.project.Project; -import org.netbeans.modules.parsing.spi.indexing.Context; -import org.netbeans.modules.parsing.spi.indexing.CustomIndexer; -import org.netbeans.modules.parsing.spi.indexing.ErrorsCache; -import org.netbeans.modules.parsing.spi.indexing.Indexable; -import org.netbeans.modules.parsing.spi.indexing.support.IndexDocument; -import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport; -import org.netbeans.modules.python.PythonUtility; -import org.netbeans.modules.python.tasklist.PythonDiagCollector; -import org.openide.cookies.EditorCookie; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.util.Exceptions; - -/** - * - * @author albilu - */ -public class PythonCustomIndexer extends CustomIndexer { - - public static final Logger LOG = Logger.getLogger(PythonCustomIndexer.class.getName()); - static Pattern PYTHON_CLASS = Pattern.compile(".*\\nclass\\s+([^\\(|:]+).*:"); - static Pattern PYTHON_METHOD = Pattern.compile(".*def\\s+([^\\(|:]+).*:"); - public static final String TYPE_FIELD = "classes"; - public static final String SYMBOLS_FIELD = "methods"; - - @Override - protected void index(Iterable files, Context context) { - long startTime = System.currentTimeMillis(); - int cnt = 0; - if (context.isCancelled()) { - LOG.fine("Indexer cancelled"); - return; - } - FileObject root = context.getRoot(); - Project owner = root != null ? FileOwnerQuery.getOwner(root) : null; - boolean pyProject = owner != null && owner.getClass() - .getName().equals("org.netbeans.modules.python.project.PythonProject"); - boolean pyLibPath = root != null && (root.getName().endsWith("Lib") || (root.getParent() != null - && root.getParent().getName().equals("lib"))); - if (pyProject || pyLibPath) { - try { - IndexingSupport is = IndexingSupport.getInstance(context); - for (Indexable file : files) { - File toFile = Paths.get(file.getURL().toURI()).toFile(); - FileObject fo = FileUtil.toFileObject(toFile); - if (fo.getExt().equals("py")) { - boolean notSkipped = !StringUtils.containsAny(toFile.toPath().toString(), - PythonUtility.EXCLUDED_DIRS); - if (pyProject && notSkipped) { - String content = getContent(fo); - setErrors(fo, context, file); - setClasses(content, is, file); - setMethods(content, is, file); - cnt++; - } - if (pyLibPath && notSkipped) { - String content = getContent(fo); - setClasses(content, is, file); - //Not relevant to index python methods - //setMethods(content, is, file); - cnt++; - - } - } - } - } catch (BadLocationException | URISyntaxException | IOException ex) { - Exceptions.printStackTrace(ex); - } - } - long endTime = System.currentTimeMillis(); - if (LOG.isLoggable(Level.INFO)) { - LOG.log(Level.INFO, "Processed {0} files for {1} in {2}ms.", new Object[]{ - cnt, root != null ? root.getPath() : "null", endTime - startTime}); - } - } - - private String getContent(FileObject fo) throws BadLocationException, IOException { - EditorCookie lookup = fo.getLookup().lookup(EditorCookie.class); - StyledDocument openDocument = lookup.openDocument(); - return openDocument.getText(0, openDocument.getEndPosition().getOffset()); - } - - private void setClasses(String content, IndexingSupport is, Indexable file) throws IOException, BadLocationException { - - IndexDocument createDocument = is.createDocument(file); - PYTHON_CLASS.matcher(content).results() - .forEach((match) -> { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(match.group(1)); - stringBuilder.append("#"); - stringBuilder.append(match.start(1)); - createDocument.addPair(TYPE_FIELD, stringBuilder.toString(), true, true); - }); - - is.addDocument(createDocument); - } - - private void setErrors(FileObject fo, Context context, Indexable file) { - List errors = new ArrayList<>(); - boolean hasErrors = PythonDiagCollector.hasErrors(fo); - PythonDefaultError pythonDefaultError = new PythonDefaultError( - "PARSING", "badging_error", "badging_error", fo, 0, 0, org.netbeans.modules.csl.api.Severity.ERROR); - - errors.add(pythonDefaultError); - ErrorsCache - .setErrors(context.getRootURI(), file, - hasErrors ? errors : Collections.emptyList(), - new PythonErrorConvertor()); - } - - private void setMethods(String content, IndexingSupport is, Indexable file) throws IOException, BadLocationException { - IndexDocument createDocument = is.createDocument(file); - PYTHON_METHOD.matcher(content).results() - .forEach((methodMatch) -> { - String className = " "; - int startOffset = methodMatch.start(1); - MatchResult classGroup = PYTHON_CLASS.matcher(content).results() - .filter((classMatch) -> classMatch.end(1) < startOffset) - .reduce((first, second) -> second) - .orElse(null); - if (classGroup != null) { - className = classGroup.group(1); - } - - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(methodMatch.group(1)); - stringBuilder.append("#"); - stringBuilder.append(methodMatch.start(1)); - stringBuilder.append("#"); - stringBuilder.append(className); - createDocument.addPair(SYMBOLS_FIELD, stringBuilder.toString(), true, true); - }); - - is.addDocument(createDocument); - } -} +package org.netbeans.modules.python.indexing; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.MatchResult; +import java.util.regex.Pattern; +import javax.swing.text.BadLocationException; +import javax.swing.text.StyledDocument; +import org.apache.commons.lang3.StringUtils; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.parsing.spi.indexing.Context; +import org.netbeans.modules.parsing.spi.indexing.CustomIndexer; +import org.netbeans.modules.parsing.spi.indexing.ErrorsCache; +import org.netbeans.modules.parsing.spi.indexing.Indexable; +import org.netbeans.modules.parsing.spi.indexing.support.IndexDocument; +import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport; +import org.netbeans.modules.python.PythonUtility; +import org.netbeans.modules.python.tasklist.PythonDiagCollector; +import org.openide.cookies.EditorCookie; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; + +/** + * + * @author albilu + */ +public class PythonCustomIndexer extends CustomIndexer { + + public static final Logger LOG = Logger.getLogger(PythonCustomIndexer.class.getName()); + static Pattern PYTHON_CLASS = Pattern.compile(".*\\nclass\\s+([^\\(|:]+).*:"); + static Pattern PYTHON_METHOD = Pattern.compile(".*def\\s+([^\\(|:]+).*:"); + public static final String TYPE_FIELD = "classes"; + public static final String SYMBOLS_FIELD = "methods"; + + @Override + protected void index(Iterable files, Context context) { + long startTime = System.currentTimeMillis(); + int cnt = 0; + if (context.isCancelled()) { + LOG.fine("Indexer cancelled"); + return; + } + FileObject root = context.getRoot(); + Project owner = root != null ? FileOwnerQuery.getOwner(root) : null; + boolean pyProject = owner != null && owner.getClass() + .getName().equals("org.netbeans.modules.python.project.PythonProject"); + boolean pyLibPath = root != null && (root.getName().endsWith("Lib") || (root.getParent() != null + && root.getParent().getName().equals("lib"))); + if (pyProject || pyLibPath) { + try { + IndexingSupport is = IndexingSupport.getInstance(context); + for (Indexable file : files) { + File toFile = Paths.get(file.getURL().toURI()).toFile(); + FileObject fo = FileUtil.toFileObject(toFile); + if (fo != null && fo.getExt().equals("py")) { + boolean notSkipped = !StringUtils.containsAny(toFile.toPath().toString(), + PythonUtility.EXCLUDED_DIRS); + if (pyProject && notSkipped) { + String content = getContent(fo); + setErrors(fo, context, file); + setClasses(content, is, file); + setMethods(content, is, file); + cnt++; + } + if (pyLibPath && notSkipped) { + String content = getContent(fo); + setClasses(content, is, file); + //Not relevant to index python methods + //setMethods(content, is, file); + cnt++; + + } + } + } + } catch (BadLocationException | URISyntaxException | IOException ex) { + Exceptions.printStackTrace(ex); + } + } + long endTime = System.currentTimeMillis(); + if (LOG.isLoggable(Level.INFO)) { + LOG.log(Level.INFO, "Processed {0} files for {1} in {2}ms.", new Object[]{ + cnt, root != null ? root.getPath() : "null", endTime - startTime}); + } + } + + private String getContent(FileObject fo) throws BadLocationException, IOException { + EditorCookie lookup = fo.getLookup().lookup(EditorCookie.class); + StyledDocument openDocument = lookup.openDocument(); + return openDocument.getText(0, openDocument.getEndPosition().getOffset()); + } + + private void setClasses(String content, IndexingSupport is, Indexable file) throws IOException, BadLocationException { + + IndexDocument createDocument = is.createDocument(file); + PYTHON_CLASS.matcher(content).results() + .forEach((match) -> { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(match.group(1)); + stringBuilder.append("#"); + stringBuilder.append(match.start(1)); + createDocument.addPair(TYPE_FIELD, stringBuilder.toString(), true, true); + }); + + is.addDocument(createDocument); + } + + private void setErrors(FileObject fo, Context context, Indexable file) { + List errors = new ArrayList<>(); + boolean hasErrors = PythonDiagCollector.hasErrors(fo); + PythonDefaultError pythonDefaultError = new PythonDefaultError( + "PARSING", "badging_error", "badging_error", fo, 0, 0, org.netbeans.modules.csl.api.Severity.ERROR); + + errors.add(pythonDefaultError); + ErrorsCache + .setErrors(context.getRootURI(), file, + hasErrors ? errors : Collections.emptyList(), + new PythonErrorConvertor()); + } + + private void setMethods(String content, IndexingSupport is, Indexable file) throws IOException, BadLocationException { + IndexDocument createDocument = is.createDocument(file); + PYTHON_METHOD.matcher(content).results() + .forEach((methodMatch) -> { + String className = " "; + int startOffset = methodMatch.start(1); + MatchResult classGroup = PYTHON_CLASS.matcher(content).results() + .filter((classMatch) -> classMatch.end(1) < startOffset) + .reduce((first, second) -> second) + .orElse(null); + if (classGroup != null) { + className = classGroup.group(1); + } + + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(methodMatch.group(1)); + stringBuilder.append("#"); + stringBuilder.append(methodMatch.start(1)); + stringBuilder.append("#"); + stringBuilder.append(className); + createDocument.addPair(SYMBOLS_FIELD, stringBuilder.toString(), true, true); + }); + + is.addDocument(createDocument); + } +} diff --git a/src/main/java/org/netbeans/modules/python/options/PythonLspServerConfigsPanel.java b/src/main/java/org/netbeans/modules/python/options/PythonLspServerConfigsPanel.java index eed1f18..898006b 100644 --- a/src/main/java/org/netbeans/modules/python/options/PythonLspServerConfigsPanel.java +++ b/src/main/java/org/netbeans/modules/python/options/PythonLspServerConfigsPanel.java @@ -270,6 +270,7 @@ void store() { errroLabel.setText(""); try { String jsonSettings = lspEditorPane.getText(); + NbPreferences.root().putBoolean("autoUpdate", lspServerCheckBox.isSelected()); if (!settingsSchema.exists()) { Files.writeString(settingsSchema.toPath(), @@ -285,7 +286,6 @@ void store() { return; } - NbPreferences.root().putBoolean("autoUpdate", lspServerCheckBox.isSelected()); Files.writeString(PythonUtility.SETTINGS.toPath(), jsonSettings); Gson create = new GsonBuilder().setObjectToNumberStrategy(ToNumberPolicy.BIG_DECIMAL).create();